Tag Info

Hot answers tagged

2

Obtaining multiple key presses can be found in this answer: How do I handle multiple key presses in Java? Assign each one to a boolean variable and then check each key and add to the movement vector. Opposite keys will cancel out, and you can also test whether a key is already in use based on that. if(noDiagonal) { velX = 0; velY = 0; ...


1

There is nothing wrong with moving multiple pixels per frame. In fact, that's typical of most games. Even 2D games often store the character's position using floats, typically in a different space (world space), and then translate that to view space and then to pixels before rendering. The main problem you might run into is that is the character moves ...


1

First code, code the normal movement of the character to progress a constant distance toward the target position every frame (ie. inside the Update() function). Then put that movement code inside an if statement for if the character is being knocked back. Only move toward the target if not being knocked back. If being knocked back, move toward the ...


1

Size and fit can be taken care of the heuristic that declares whether a move is valid during the path finding. Once the path itself is generated it's then up to a localized movement function to handle not bumping into things on the way, called path smoothing. Maybe paths with smoothing will help generate some ideas that work for you. The last time I did ...


1

By computing the velocity as some factor of the difference between the start and end position, you can achieve the association you want: var velocity = (endPosition - startPosition) * scale; The hard part be will choosing a value for scale. You can initially try constants -- such as 1.0f or 0.5f. This makes the velocity directly proportional to the start ...



Only top voted, non community-wiki answers of a minimum length are eligible