Record the player and create a clone who repeat action

For questions about using Classic.

Post » Sat May 14, 2011 10:43 pm

Hello,

I need to do a record/play function like these flash games :
http://www.nekogames.jp/shockwave/cursor10.swf
http://www.nekogames.jp/shockwave/cursor2.swf
In my case, it is for a platform game. I want record the player's action, restart the level and play the recorded action on many clones exactly like in theses flash.

Is this possible ? how can I do that ?

Thanks. :)
B
18
S
3
G
6
Posts: 9
Reputation: 3,508

Post » Sun May 15, 2011 1:21 am

You have to record any x and y position and store them(in an array or a file).
Create on the 2nd attempt the ghostplayer and load the x and y positions.

Your game has a few more "players"...I would use the "s-plugin" and make 6 arrays with it, for the 6 lives.

Here is a example made by toralord->
viewtopic.php?f=8&t=6291&hilit=s+plugin+time+warp
He used the s-plugin to rewind the players action.

Now you have to put the information, that is stored in the s-plugin, on the ghostplayer(the x and y positions for example).

It's not that easy...but it's possible.

If there is any easier way to do it, someone else will post it I think^^...
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Sun May 15, 2011 1:54 am

You know what would be a fantastic object? One that streamlines Toralord's example all into one object.

Another idea would be an audio-video recording object that begins recording based on an event like: On Enter key pressed or on collision between Sprite A and Sprite B >>> record layout

It could create an .avi that would save to it's own folder, and through event expressions we could call the file up from the folder. It would definitely need functions to have the file delete or save itself based on events, and allow the end user to save whatever recording he chooses... allow pauses, rewinds, and fast forwards...

I know I'm just wishing out loud, but man that would be great!
B
12
S
4
G
3
Posts: 426
Reputation: 2,458

Post » Sun May 15, 2011 4:30 am

You might want to ask Minor about this sort of thing. He's currently working on a game that does exactly this.

You can see a video of it here in this thread:
viewtopic.php?p=72265#p72265

But I imagine it's rather complex, so I don't know how willing he is to divulge his work.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun May 15, 2011 6:39 pm

It's pretty straightforward to record the players movement, it's basically a list of positions every frame. The first task is to choose a way to store all the positions, the Array or S plugins will do. Replying is just a matter of setting the player's position to the positions in the list one by one.

For example I used the Array plugin here:
http://dl.dropbox.com/u/5426011/example ... eDrops.cap
made in CC r1

The "ghost" sprite is in a container with the Array object so that each "ghost" will have it's own list of positions. I keep track of which "ghost" to record the player's position to by a variable with the ghost's UID (unique id). When recording the player's position is always put in the last element of the array, then the array's size is increased by one. When replaying another variable is used to indicate what index of the array to read from. After the ghost positions are set from the arrays a that index the index is increased by one. You can also reverse the replay by decreasing by one.

Another idea for using this with platform movement is recording and setting x/y velocity instead of position, that should help with having the replay's animations update.
B
79
S
24
G
54
Posts: 4,738
Reputation: 40,739

Post » Sun May 15, 2011 8:00 pm

Nice example R0J0!
I can learn much from that .cap.
Was it easy for you to make it? For me it would take a bit longer to make an example like this.
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Mon May 16, 2011 12:51 am

How would you record animation? or would it be automatic?
B
11
S
3
G
8
Posts: 473
Reputation: 4,569

Post » Mon May 16, 2011 8:30 am

[quote:1kc88t7a]Was it easy for you to make it?[/quote:1kc88t7a]
It wasn't too difficult.

[quote:1kc88t7a]How would you record animation? or would it be automatic?[/quote:1kc88t7a]
In toralord's time warp example he recorded the position, angle, velocity and animation frame of the player. It's the same case here just record those other value with the position.
B
79
S
24
G
54
Posts: 4,738
Reputation: 40,739

Post » Mon May 16, 2011 11:04 am

Very interesting, it is exactly what I need. I will attempt to do the same with animation. Thanks :D

Just a little question, In your Cap, you reset the position of the player at the re-start. Is it possible to reset the positions of all objets (Enemies, moving platforms,...) in the layout easily ? Or restart the entire layout without loose saved arrays ?

In an advanced level, my hero will be able to shoot projectiles. Is it possible to record/play the shot if I wan't my clones shoot also ?

thanks again.
B
18
S
3
G
6
Posts: 9
Reputation: 3,508

Post » Tue May 17, 2011 3:37 am

I updated the example a bit to include animations.
It now records position, angle, animation, animation frame and when the player shoots. I also changed it to just reset the layout instead of moving the player back to it's starting position. The ghost and array objects are now global so they aren't destroyed when resetting the layout.

http://dl.dropbox.com/u/5426011/examples5/infMario.cap

This has ended up being a very enjoyable example to work on. :)
B
79
S
24
G
54
Posts: 4,738
Reputation: 40,739

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests