views:

113

answers:

1

Is it possible to add a feature to record the game play within your game without eating up too much memory ?

I want to allow the user to save there game as some sort of video file if thats possible ?

// Edit - made things easier to be more relistic// The idea is that the user can use the app to change the textures within a pre-animated scene and when their done they can then export it to video.

Thanks

A: 

Is your game deterministic? If it is then you should be able to record user input. Then to play it back you just run the game and provide the recorded input instead of live input.

Depending on the type of game the hardest part will be making it deterministic. You will need to capture all seeds to random number generators and how many times you have gotten a number from the generator so that you get exactly the same results out. Since we are talking about a single core you don't have to worry too much about order of evaluation which is good, but make sure it is well defined.

Second it will be easiest if you use a MVC(model view controller) setup then all you need is a playback controller and a live user controller that records timestamped input if necessary. Note: depending on how you do it it may be easier to use a frame count rather than an actual time. When the player hits record, gather the entire state of the game, and start capturing player input.

To export video all you have to do is load the starting state playback a frame, capture the frame then iterate over the entire playback record. If you have things in your game that are time based you will have to fiddle with the clock so that time spent doing the video capture is removed. Alternatively you could record time based events with a frame count so that it happens at the right frame, but then you have to make sure the different processing order doesn't change the game.

A second option is to go event based, just record every event that happens in the game Then during playback just trigger those events during the frame they originally happened in. This requires capturing more data since you aren't using the game to simulate everything(you still need to do animations and such), but might improve render times as you aren't running the whole game.

stonemetal
The problem with that is that I would not be able to allow the user to save it as a seperate video file? (that they could play back on their computer for example)
Dave
I can't recall ever seeing a game that implemented game recording in a raw video format. It's just too expensive in terms of CPU encoding power, and storage space. Certainly far too expensive for an iphone in those regards. You'd want to record the actions and play them back in some sort of emulator.
DougW
I've seen ones that allow uploading to youtube if that makes a difference?
Dave
You aren't going to have much processing power for your game if you have to be able to run a full video capture app at the same time in real time. Having input capture and play back would allow you to have a separate export process that ran in less than real time.
stonemetal
I've changed the idea around to make it more realistc and updated the description. Would this now be possible ? If so, how would you recommend I go about implementing it?
Dave