17 December 2020, 23:54 | #1 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,894
|
Record Player Movement to play back later
So, for my Space Invaders, I want to let the game play itself whilst in attract mode.
I guess that the easiest way to do this is to record keys used in a few seconds of play and then save this list. Then reload with the game and if in attract mode to use this list of commands to control the player? My initial thought was to just dim demo(1000) and record left as 1, right as 2 and fire as 3. Each loop I store the key command in demo(number). Then in attract mode I just cycle through demo, read the number and use this to control the play as if the key has been pressed? My issue is that I have no idea how to save the array demo and reload it. I know it is to do with openfile and savefile (I use this for saving and loading high scores) but don't understand what to do! I was looking at the Tape command but I am unsure if this will work? Any help would be much appreciated as currently I just used random numbers and player looks a little bonkers in attract mode!!! Thanks. |
18 December 2020, 00:10 | #2 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,343
|
Yep, that's a reasonable way of approaching it alright. Just make sure you don't run past 1000 frames or you'll have a crash on your hands
The simplest way to store it, though not the most efficient, is probably to just print out the values to a file and then read them back in in a similar way. The result will be a big text file with one number on each line, so you can easily edit it by hand afterwards if needs be. Something like this should work to write the file: Code:
If WriteFile(0, "Path:to/DemoFile") FileOutput 0 For i = 0 to 1000 NPrint demo(i) Next i DefaultOutput CloseFile 0 Else NPrint "Error writing to file!" End If Code:
If ReadFile(0, "Path:to/DemoFile") FileInput 0 For i = 0 to 1000 If EOF(0) = False demo(i) = Edit(5) Else i = 1000 End If Next i DefaultInput CloseFile 0 Else NPrint "Error reading from file!" End If |
18 December 2020, 19:13 | #3 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,894
|
Thanks - will have a go.
|
19 December 2020, 02:28 | #4 |
Gets there in the end...
Join Date: Sep 2005
Location: Wales
Posts: 863
|
For a shorter file you could store pairs of numbers first one for control state (left, right or none) and second one for the number of frames for that state?
(Although then you'd need a second list for the frame time until fire is pressed then though too. But the file would still allow a long demo.) |
19 December 2020, 23:18 | #5 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,214
|
You could implement a simple AI to play the game, might be easier.
|
20 December 2020, 11:48 | #6 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,894
|
|
20 December 2020, 11:53 | #7 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,214
|
AI doesn't have to play well... You can move in a random direction for a random number of frames, then repeat. Fire at random intervals.
Frankly that's how I play it anyway! |
20 December 2020, 15:44 | #8 |
Registered User
Join Date: Nov 2020
Location: Fareham, UK
Posts: 2
|
Some years ago I wrote a python version of space invaders. The attract modes I implemented as two lists one for each of the two demo games. I recorded the game in Mame and then counted frames and made a note of the state of the missile base, aliens and bombs and converted that into my lists. They are attached, you may or may not find them useful - I don't know Blitz basic, so the attached may be of no use at all!
|
20 December 2020, 21:12 | #9 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,894
|
Thanks - I will have a look, sounds really helpful!
|
20 December 2020, 21:24 | #10 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,894
|
Looking at Grumpa's code and linking this to Coagulus' idea I think I can probably use data statements and a dim but not have to have too long a list.
If I use the idea of storing a frame when something happens then I only need to store the key points and not all the bits in,between. For instance, if the base moves 20 pixels right then I just set which frame it starts moving right and it can keep moving until I set another frame that fires or moves left. And Grumpa has provided all this info! Cheers to all. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem Trying to Play Player Manager 2 | j000e | support.WinUAE | 16 | 10 December 2008 07:02 |
Any swf (flash) player for Amiga that can play Flash5+? | Ironclaw | request.Apps | 4 | 22 September 2005 10:48 |
Sensible Soccer 2 Player Plug 'n' Play | killergorilla | Retrogaming General Discussion | 1 | 24 July 2005 23:14 |
Help Converting ADF to be able to play back on Amiga | Unregistered | support.Apps | 12 | 29 August 2004 04:27 |
Someone know a way to play Player Manager using the Kick Off 2 engine ? | Iena78 | Retrogaming General Discussion | 10 | 01 August 2002 09:03 |
|
|