Tag Info

New answers tagged

0

Your player has two points for each direction, so 8 points in total. For each point do the following: Check where the point is, where it wants to go. I use a line draw algorithm to determine the tiles the point crosses. Pick the nearest collidable tile from the tiles you found. If a collidable tile is found: stop movement to that direction. The ...


0

this picture adds the symmetry needed to solve the question easier. Just project L along the vector CL so that |P-O|=|T-O|. Now it's obviously just two identical triangles (CPO and C'TO) rotated by your desired angle. I.E. ang(OT)-ang(OP) C' and L' are both the same as C and L after rotating, about O, by the same amount.


1

https://www.youtube.com/watch?v=DOpqkaX9844 This is a great tutorial on tilemap collision, but you can also use Box2d. That is what I ended up doing because tilemap based collision only works if your character moves in increments of 1 tile at a time. If he can move fractions of a tile it doesn't really work.


2

Since m_VAO is valid in constructor but not in draw(), it seems that the destructor was called before draw(), perhaps by copying an instance of the Polygon class. P.S. Errors like these could be prevented by following the Rule of three.


1

You need to check two things: 1.Texture and Shader ETC1 doesn't support alpha. You'd have to use a separate texture read (which you seem to be doing on texture2D(CC_Texture1, v_texCoord2). You can use tools to extract alpha channel from a RGBA texture and use a single texCoord for both samplers. Your code could be something like this: vec3 tex = ...


1

Another way you could go about it by using a "generic" map for your parameters: int HashStringToInt(const std::string& aStringToHash) { // Hash your string here } union Value { int _int; double _double; bool _bool; }; struc Event { int _id; std::map<int, Value> _parameters; }; void boom() { static const int EVENT_EXPLOSION = ...


1

You're right, it can be done in two ways: -Moving the player -Moving the world This seems like a 50-50 deal. It doesn't matter how you do it, right? I don't agree. I would ALWAYS suggest moving the player. Because if you choose to move the world now, and a few months further on in development, when you have enemies, npc's, and other entities on screen, ...


3

Don't shove all the events into one type. You are using C++, a language that supports Abstract Data Types. Use them! Inheritance/Interfaces struct Event { TYPE type; virtual void Handle() = 0; }; struct DamageEvent : Event { float damage; int target; void Handle() final { FindTarget(target).TakeDamage(damage); } }; void ...


1

Use an influence map for target searching. Have a grid and on each node, reserve a spot in a collection of units for each team. For each unit, generate a collection of coordinates within range and offset these coordinates as the unit moves. When a unit searches for a new target, enumerate over its coordinates within range. If another unit is on one of ...


1

gl_TexCoord[0].stp = normalize(gl_Vertex.xyz); Is your problem, I believe you need: gl_TexCoord[0].stp = normalize(gl_Normal.xyz * gl_ModelViewMatrix); Possibly without the matrix multiplier -- I'm a bit rusty. Note that the meaning of 'normal' can be a bit confusing here -- The 'vertex normal' (gl_Normal) is a vector pointing directly 'away' from the ...


0

I just figured it out. The mGridPositionOffset is pointing to the top-most corner of the grid. So that makes it (grid.height + mGridPositionOffset.height). As you can notice. That was very wrong. The mGridPositionOffset is already accounting the height of the gridBox plus the grid height. I just figured it out when I make realtime and actual measurement. ...


1

I can't quite spot the error in your code, but this looks odd. cocos2d::Size gridPixelSize = cocos2d::Size(mGridSize.width * mOffset, (mGridSize.height-1) * mOffset); Why the - 1 on height? Also, in general to do something like this, you should abstract away the screen coordinates entirely. Make a hierarchical system so that when handling clicks, you ...


1

The fast and simple solution is just to increment all returned Y values by 2. I'm not seeing an obvious error although I can't see the whole situation. I suspect when you subtract 74 pixels to offset the grid you either did or didn't also subtract 74 pixels from every pixel input to methods. It may also have something to do with your offsets or your ...


1

In a client/server architecture it is not required that client and server are implemented in the same programming language. They usually communicate by sending raw data via network sockets. So you can choose the technology for each component separately, depending on your requirements, skillset and personal preferences. An exception would be when you want to ...


0

Probably the .lib file was compiled on a different version of Visual Studio. I don't know about DirextXTK but some library distributions contain multiple versions of libs for different compilers.


3

Loading: To expand on what Sandalfoot said: You must create you models in an external application, (Blender is popular and free, 3DSMax is free for non-commercial use) and then export them in a suitable format. There are many different model formats which target different things. Here are some: The Wavefront .OBJ format is very simple and easy to load, ...


2

It depends. Generally speaking, yes; you will create your models in an external program (Blender, 3DSMax, etc.) and export them into a format that your game can read. Unless you feel like writing a parser for an existing format from scratch, though, chances are you will be able to find a library to load any kind of model format your software can export. ...


0

Did you tried launching your eclipse from the new Cygwin-X xterm window. it seems the eclipse takes the paths and relative paths automatically. Even if your c:\cygwin\bin is not in PATH, if you launch eclipse from cygwin-X terminal window the eclipse will take all the relative unix style paths as well as windows path. Don't try to install cygwin64 and ...


0

In SDL 2, you must set the scaling interpolation algorithm for the whole renderer, using SDL_SetHint (SDL_HINT_RENDER_SCALE_QUALITY, Value); where Value should be, in your case (pixel art) 0. 1 means linear interpolation, and 2 is anistropic (only supported if the app runs on D3D/Windows) (documentation) As far as saying itself is concerned, you can do ...


1

It is possible though inconvenient. You'd have to write managed C++ to achieve it. And yes, there is such thing as managed C++. Managed doesn't specifically mean C# and unmanaged C++. To achieve it you'll need to import UnityEngine DLL file. When you're finished you put it in the (Unity Project Name)/Plugins folder. Here would be the code you'd use: In the ...


-2

Export the model as an .obj file, and write a parser. Heres a good video tutorial. Written in Java, but the logic should be about the same. Part 1 https://www.youtube.com/watch?v=KMWUjNE0fYI&list=PLRIWtICgwaX0u7Rf9zkZhLoLuZVfUksDP&index=9 Part 2 https://www.youtube.com/watch?v=YKFYtekgnP8&index=10&list=PLRIWtICgwaX0u7Rf9zkZhLoLuZVfUksDP


-2

In general, you can't. The typical development environments only give you visibility on the C/C++ side. So, I say "you can't" but that's obviously not exactly true. You can't step through the shader and print variables, but still we all develop and debug shaders. But it's a lot of intuiting indirectly what's going on, by repeated runs. Some of the things I ...


0

here there's an example how incapsulate coords inside Creatures and access the fom outside class Creature{ public: // constructor Creature(int _x = 0, int _y =0) { x=_x; y=_y; } // interface to outside world void setPosition(int _x,int _y) { x=_x; y=_y; } // ...


2

Here's a function that interpolates between Start and End quadratically by T. float Qerp (float Start, float End, T) { //The quadratic stuff T = 1 - T; T = 1 - (T * T); float Difference = End - Start; return (Start + (Difference * T)); } I.e.: float Elapsed = 0; const float Length = 2.5f; while (true) { Time.timeScale = Qerp ...


1

The reason for you getting a black screen when you put the camera inside the cube is most likely back face culling. Try calling: glDisable(GL_CULL_FACE); In the beginning of your display function or in main (after enabling depth test) to disable back face culling. If that is helpful you can either change the winding order of your polygons or change ...


1

Here how I 've done it (c#) private static float[] grad = new float[256]; private static int[] p = {151,160,137,91,90,15, 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, 88,237,149,56,87,174,20,125,136,171,168, ...


8

For HDR (high dynamic range) rendering, you would want to use more than 8 bits usually - since you are not only encoding color, but also intensity of the light much more precisely (and thus over a greater range) than 8 bit RGB can do. Of course, your monitor can likely only display 8 bit RGB (if even that), so this only matters if you are actually doing ...


1

@Richard Byron explained well and gave a well-made sample code. I think it's better to add additional information about the basic math. I leaved out the wall collision. Sorry for bad hand writing an drawing.


-1

Found a solution with help from Exitgames. Hi again, thanks for the answer over at exitgames. Found a solution so far with this: DALGameInstance.h /* ToDo: Find a way to get nByte as UPROPERTY! */ //UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = DALGameInstancePhoton) nByte* ApplicationName = reinterpret_cast<nByte*>("MMOServer"); ...


1

I got answer for my own question. refer to this link http://discuss.cocos2d-x.org/t/can-someone-tell-me-how-to-setup-cocos2d-x-on-code-blocks/10144/2 I follow these steps. 1) Create cbp file with the command cmake ../ -G "CodeBlocks - Unix Makefiles" 2) Open it in Codeblocks This solved my problem.


2

Like Pieter mentioned, you can use 1D kinetic equation for height, which in your case will come to: h = p + vt + 0.5at^2 where a is the acceleration due to gravity. You can then use the quadratic equation to solve for t. Once you have t, you can use the kinetic equations again to calculate how far the ball has travelled width ways. This would tell you ...


1

I would personally use the keyboard class that allows you to query the state of keys instead of waiting for an event. The documentation is here One of the reasons I prefer this method is that you can check the status of the key from almost anywhere in the code, and you don't have to store the state of the keys yourself. f::Keyboard can retrieve the ...


-1

Rotate vice-versa input arabic text. #define COCOS2D_DEBUG 1 // At the beginning of file CCFileUtils *fileUtils = CCFileUtils::sharedFileUtils(); std::string text = fileUtils->getStringFromFile("data.txt"); std::string label_text = ""; char *c; c = (char *)&(*text.end()); c--;c--; while (c > (char *)&(*text.begin())){ while (*c == ...


0

Your getters (getCTwoInst, getCOneInst and getOne) return copies so you're calling the animate function on a copy of a copy of your sprite. This modified copy is then left unused. Return references instead: Two& getCTwoInst() {return cTwoInst;}


0

DirectX and OpenGl have different coordinate systems for their texture coordinates. OpenGl uses a origin in the lower left but your model assumes that the origin is in the upper left. Because of that you need to mirror the UV coordinates or your images along the y axis. You can do so by setting the v component to 1 - loadedV.


1

Your main character class should not have a reference to the keyboard or any input-related class. Input should be handled in the game loop, or preferably a dedicated input class, decoupled from other entities so they'll only need to respond to abstract actions, not raw input. Not all input is related to your characters and and not all types of input devices ...


5

The approach I prefer treats handles as simple unique integers. In order to access the data via a handle you must pass the handle to its appropriate manager. For instance, if you have an ObjectId, and you want to get the position of the object with that id, you call a function akin to GetPositionOf(ObjectId id) -> Vector3f. Because you are always ...


3

What you are looking for is really similar to a type of smart pointer, called a weak pointer. A weak pointer lets you have a pointer to something, but if that something goes away, that pointer will then point at null automatically. I mention that because you can search the net for different smart pointer implementations to find more info and techniques if ...


0

The fastest code to compile is the code that has not been written. If you don't intend to modify the libraries (which is the typical way to use 3rd party open source libraries), you should not include them in your solution. You should compile them in a separate solution and make them available for your main project, whether they'll be statically linked or ...


0

Your ghost will possess different Entities and use their actions. But will you ever change the actions of these Entities while the program runs? If not, you could create a map for each "class" of entities and have the controller point to the current map to use. Say you have an enemy that's a Spider, so all spiders use the same actions' map. You could use a ...


5

One way to go is to model Weather as Random Process using Hidden Markov Model(HMM). For full explanation of it, check Hidden Markov Model - Wikipedia This will solve the following problem: I'm in state A. From state A, which is the next state i should go into.In other words, if you are in Cloudy State, where should you go next:Remain in Cloudy state or go ...


0

First thing you should do is to refactor your code, to have a clear view about what's being done. So get out of thee loop the values that won't change, and cache any re-used value. Below is some pseudo-code that should get you in the right direction. The principle is : get the aimAngle, the angle between player and target (mouse). Then randomly pick ...


1

You could also think about "crossfading" from one weather state to the next when they switch. Basically the weighting of the old state will go from 1.0 to 0.0 over time while the new state goes from 0.0 to 1.0 over the same amount of time. This is used of course in audio to switch from one audio track to another but its also used in skeletal animation ...


1

It's been a while since this question was asked but I hope this will help people who have the same question as you. I got started with OpenGL by reading a minibook on arcsynthesis.org. Not sure who wrote it. It looks like the site's registration has lapsed or something but you should be able to find it here: ...


0

Usually in DirectX you need 2 textures, one allocated on "dynamic" zone (hint during create resource). And one created in "static" zone, which you copy remotely using CopyResource from D3DContext. So you map/unmap the dynamic texture, then post a copy order, this way you limit the change of blocking the rendering.



Top 50 recent answers are included