C
C
chinpokomon2015-05-31 23:52:47
C++ / C#
chinpokomon, 2015-05-31 23:52:47

How to implement the movement of units and their interaction with each other?

Good day. I am writing a game in SDL2 + C++. Now there is already a location in the form of a grid of tiles and sprite animation. The size of a unit is equal to the size of the map cell. For calculation I use A* algorithm. The problem is that you need to move a smaller distance than the size of the tile/grid. How to make movement smooth? And another question. How to properly interact between units? Now I imagine it like this:
1. I switch the animation to "attack animation".
2. Waiting for the animation to reach the last frame.
3. I calculate damage, etc.
Can this be done more intelligently?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2015-06-01
@Nipheris

It would be wise to break this question into several and indicate the necessary details for each, or throw out all the husks from it and leave something alone.
In order for the movement to be smooth, you need to smoothly animate this movement (i.e. redraw the position and appearance of the object N times per second).
The process of interaction between units depends on the architecture of your game and its target functionality. If it's a single player, I think it's not always a good idea to wait until the end of the animation to calculate damage (for example, it's natural for a player to detect damage being dealt the moment their sword touches an opponent, not when they finish moving). If this is a network game, then you have an interesting and difficult task of compensating for ping.
If you think I'm impersonating Captain Obvious, then you need to ask more precise and specific questions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question