-1

I am coding a very simple RTS in java and here is my problem, I need to code a replay file which save every actions made by the player and must be able to be read to watch a game (Only the actions need to be saved, the mouse movement are not important and the time between every action does not need to be saved, I will put the same delay between every actions). How could I do that knowing that I need to save the x and y position of the implicit element, the action(attack, move, porduct ...) and the x and y position of the unit in my program parameters. For exemple : archer.attack(beast), so in this exemple I need to save the x and y of the archer, it's action so here attack and the x an the y of the beast. Thank you very much to every answer, it would help me a lot !

Jordan Repovy
  • 152
  • 1
  • 11
  • 1
    Why don't you just write these details to file? – SamTebbs33 May 30 '15 at 12:39
  • Don't be afraid to try something/anything before coming here as you've nothing to lose and all to gain. Also then you could show us what you've tried, giving us a much greater understanding of exactly what you need help with. -1 – Hovercraft Full Of Eels May 30 '15 at 12:57
  • Because I have absolutly none knowledge about exporting infomations in a file and re-use those information later in the programs so I have absolutly nothing to try. And every example I've found on internet aren't specific enough to solve my problem. – Jordan Repovy May 30 '15 at 13:45

1 Answers1

-1

A good API will allow you record the moves, in a simple string format and then using the TIMESTAMP saved with it, pass that back to the API by using a Thread.Sleep where the sleep time will be the time 'next action' minus 'current action'.

Example String File (Player|TIME|ACTION|DATA)

Player1|1|Move|-

Player1|4|Click|-

Player1|12|Click|-

You then create a game loop where you carry out the first action (Move) and then call 'Thread.Sleep(4000-1000)' (Where 1000 is 1 second) and then repeat the loop. The next action will be 'Click' and then sleep for 8 seconds.

Peter_James
  • 647
  • 4
  • 14
  • First, thank you for the answer ! Could you just give me the name of the package for the API I would need and the name of the command that read informations from the file so I can use them. If you can give me those informations it would be perfect, else that's ok you still helped me a lot ! – Jordan Repovy May 30 '15 at 13:05