Game replay?

Get help using Construct 2

Post » Fri Jan 06, 2012 4:52 pm

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?
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Fri Jan 06, 2012 4:55 pm

outch....every tick would mean some HUGHE amount of data I would think....
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Jan 06, 2012 4:59 pm

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 :(
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Fri Jan 06, 2012 5:02 pm

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.
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Jan 06, 2012 5:04 pm

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.
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Fri Jan 06, 2012 5:06 pm

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 :
[code]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[/code]

That should work.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 06, 2012 5:11 pm

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.

B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Fri Jan 06, 2012 5:17 pm

@Yann, I couldn't get this working on the second part, It wont let me set state ect, as a sub event
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Fri Jan 06, 2012 5:18 pm

I think it would be helpful to see the CAPX....
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Jan 06, 2012 5:35 pm

@Weishaupt, Here's the capx: http://dl.dropbox.com/u/51270524/ReplayFail.capx
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests