0

I am creating a football simulation game and I would like to make a 2D view of match. My match is 90 minutes long and there are 22 players on the field. How could I save a movements/path for players so that it wouldn't take lots of space. I know I could save it something like

Minute: min, 
Player: id, 
X: xCoord, 
Y: yCoord

and then just move objects with jQuery from point A to point B, but I am sure it isn't the best solution, because it would require lots of space and database entries. I am using MongoDB, but all suggestions are welcome.

1
  • Anyone? :( Any help would be appreciated Oct 22, 2013 at 7:32

1 Answer 1

1

How do the players move? They move a little in each step of the main loop? Or they go in long straight lines and then make sudden turns and go in other straight lines? In the first case you would probably need to save each milisecond or so (each step of the main loop), or you could save their positions every ten steps or every second, etc. And the replay could interpolate the saved points (thought the replay would look "gross" like that, it could save a lot of space in your db). In the second case (straight lines), you could just save the points where the players turn in another direction. In this case you'll save their position, angle and speed (along with time, obviously).

The first table could be (the intervals could be more than 1ms, depending on the power of the machine):

PLAYER  TIME(ms)  X  Y
   1       0      0  0
   1       1      0  2
   1       2      0  4
   1       3      0  7
   1       4      0 10
   1       5      4 13

While the second table would be:

PLAYER  TIME(ms)  X  Y  Dir  Speed
   1       0      0  0   90    2
   1       2      0  4   90    3
   1       4      0 10   60    5

or something like that. Dir is the direction in degrees. Hope that helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.