Game replay?

  • Is there a way to save a replay of a users game, You know like racing games a ghost lap ect?

    Could you record its x,y,angle, rotation every tick the save that into web storage? I'm quite familiar with web storage, but the logic behind getting the x and y position every tick overwhelms me :S

    Im sure Yann has a genius solution to this.. Challenge?

  • outch....every tick would mean some HUGHE amount of data I would think....

  • yeah i can imagine so, But is there a way to record the screen with html5?

    I know there is a spritebank plugin, Which might be able to be used.. But This is a feature i really want to implement in my game :(

  • First of all, what are you trying to archive with the play back?

    Second, storing it within the "webstorage" seems - in my mind - not really "save" and depending on the ammount of data, I doubt that it will be performant enough.

  • Using your tutorial :)!! Im making a racing game, 2D. And i want the user to be able to view/share there replay. and save it locally so they can view it any time they want.

  • Well I already did that in construct classic to test the Stack,Queue,Deque plugins. So it's not much of a challenge. Also I never used webstorage.

    I'm not really sure how (in a design sens) I would use it. You know, webstorage seems like storage that can be wiped out anytime, so I don't know how to design something with that level of reliability

    Should it only just be for temporary stuff? Is a replay a temporary stuff? If it's just temporary why not storing it in a global variable?

    So to design a permanent save system, I'm not really sure webstorage is a good tool.

    Anyway, logging x,y,angle and rotation could be done really easily by :

    Global Variable log = ""  // each lines is a string formatted as "X,Y,Angle"
    Global Variable replay = 0  // is on replay mode?
    Global Variable iterator = 0  // position of in the log during replay
    System: replay = 0
      -> System: set log to log&Sprite.X&","&Sprite.Y&","&Sprite.Angle&newline
    System: replay = 1
      Local Variable state="" //current state "X,Y,Angle"
      -> System: set state to tokenat(log,iterator,newline)
      -> Sprite: set X to tokenat(state,0,",")
      -> Sprite: set Y to tokenat(state,1,",")
      -> Sprite: set Angle to tokenat(state,2,",")
      -> System: add 1 to iterator

    That should work.

  • Thanks Yann, I will give that a go soon. The webstorage is not something im completely in love with. It just makes sense for the user to be able to save replay and then view it somehow.

  • Yann, I couldn't get this working on the second part, It wont let me set state ect, as a sub event

  • I think it would be helpful to see the CAPX....

  • I'll try to fix the CAPX...

  • Here you go...

    <img src="http://quak.laurig.de/replay.PNG" border="0" />

  • Thanks Weishaupt, you guys really helped me out.

    If only there was a way to save this, and view it at anytime :o

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • i don?t think that this will work

    but... try it

    Make a checkpoint object with 2 private variables X and Y . it will be a point sprite and set invisible

    add to your script:

    during all the race:

    spawn CheckPoint object on sprite player 2

    for each instance

    set local value

    awwww... i cant do it :(

    maybe you can figure out how you can save each instance value

  • , I don't really understand..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)