Tag Info

New answers tagged

1

Look at what's happening. SaveX is 300, SaveY is 0. When you normalize moveVec you take the Vector (300,0) and resize it to be a length of 1, which makes it (1,0). You test to see if 300 > your position, if so you add moveVec.getX(), otherwise you subtract. So you move 1 to the right. You then test to see if 0 > your position, if so you add ...


1

The white vector is the correct vector with the code you have. If you're only ever adding integers to your position, the movement is going to be at increments of 45 degrees. That's restricted to orthogonal and diagonal movement only. If you want free movement you should be normalizing the movement vector. Check to see if the libraries you're using have a ...


0

Don't use JFrame, instead use BasicGame subclass and AppGameContainer (it's much better than JFrame). And to your problem, you have to create a Camera class. That's all already covered here.


1

from looking at the docs I have found your issue public static void rotateM (float[] m, int mOffset, float a, float x, float y, float z) Added in API level 1 Rotates matrix m in place by angle a (in degrees) around the axis (x, y, z). Parameters: m source matrix mOffset index into m where the matrix starts a angle to rotate in ...


4

As long as your movement space isn't Euclidean and things can block an entire grid space, you'll have this problem. If you want people to not "play the grid" you're probably going to have to not use a grid.


1

If I understand, your question is about the building of the formation (arrival of the enemies from outside the screen into a "space-invaders like" formation (aka end-formation)). Having played this game a lot, here is how I think they have done it: They have a handful of "incoming trajectories" which come from out of the screen to an end-point roughly in ...


-1

1) Use Breadth First Search (BFS) to calculate the path http://en.m.wikipedia.org/wiki/Breadth-first_search 2) Highlight path 3) Move the object Pathfinding: http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html


0

Actually this is like any tile based movement from a turn based strategy game. You can simply flood fill the tiles from the selected character to find which should be highlighted. Psuedo code: Set<Tile> getTilesInRange(Character character, int range){ Set<Tile> highlighted; highlighted.add (character.tile); Set<Tile> ...


3

Fly along circular arcs You start at x1, moving in the direction v1 and want to end up at x2 facing in v2, then the shortest path (assuming a finite turning radius, which realistically should be proportional to the square of the velocity) takes you along an arc of radius r1around m1, followed by a straight line segment and then another arc of radius ...


1

I would add some AI (artificial intelligence) checks. A first thing to do would be to check if the distance to travel, in comparison with the distance to the enemy makes sense to apply the Bezier curves. For example, you could make the weight (i.e.: distance from the end point to the control point of the Bezier curve) depend on the distance travelled and the ...


4

Yes, you'll want to define an "origin" tile for the player (for example, the top-left of his 2x2 set of tiles) and interpret the player's position as being the position of that origin tile. You will then want to take the tile size of the player's avatar into account when determining if it can be moved to a partition position. For example, if you have a ...


11

The "normalized direction vector" is how this task is usually approached, and how I often do it, but lately I've simply been clamping the resulting movement vector. It usually achieves the same end result and the code is a lot simpler: var moveSpeed = 6.0f; function Update() { var movement = Vector3.zero; movement.x = Input.GetAxis("Horizontal") * ...


28

You need to take the sum of the directions, normalize that, then multiply by the speed. I tangentially answered this as part of my response to Preventing diagonal movement Specifically: velX = 0; velY = 0; if(keyLeft) velX += -1; if(keyRight) velX += 1; if(keyUp) velY += -1; if(keyDown) velY += 1; // Normalize to prevent high speed diagonals length = ...


13

Separate your direction selection code from actual movement code. Choose Direction by checking which keys are pressed. Store it as a unit (normalized) vector. Multiply your Direction with Speed and with DeltaTime. Apply resulting transform to your object/camera.



Top 50 recent answers are included