English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 17 December 2020, 23:54   #1
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
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.
Havie is offline  
Old 18 December 2020, 00:10   #2
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
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
And then to read it:
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
Daedalus is offline  
Old 18 December 2020, 19:13   #3
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Thanks - will have a go.
Havie is offline  
Old 19 December 2020, 02:28   #4
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 862
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.)
Coagulus is offline  
Old 19 December 2020, 23:18   #5
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
You could implement a simple AI to play the game, might be easier.
E-Penguin is offline  
Old 20 December 2020, 11:48   #6
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Quote:
Originally Posted by E-Penguin View Post
You could implement a simple AI to play the game, might be easier.
Not sure creating AI to play is easier than just recording me playing!

Easiest option is just a load of data statements to fill the dim as I already have it working randomly!
Havie is offline  
Old 20 December 2020, 11:53   #7
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
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!
E-Penguin is offline  
Old 20 December 2020, 15:44   #8
Grumpa
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!
Attached Thumbnails
Click image for larger version

Name:	SI Attract Mode 1.gif
Views:	50
Size:	268.3 KB
ID:	70012  
Attached Files
File Type: txt SPACE INVADERS ATTRACT MODES.txt (5.5 KB, 75 views)
Grumpa is offline  
Old 20 December 2020, 21:12   #9
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Thanks - I will have a look, sounds really helpful!
Havie is offline  
Old 20 December 2020, 21:24   #10
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
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.
Havie is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:59.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09913 seconds with 16 queries