• Please review our updated Terms and Rules here

Space Shooter in Applesoft BASIC?

Mister_Alex

Experienced Member
Joined
Sep 1, 2011
Messages
58
I'm able to make a rectangle 'shoot' bullets, so a space-shooter type game seeks like a decent project. Of course, there's no way lo-res Applesoft can be used to make something along the lines of Galaga, but it would be fun just to shoot at 'something'.

To keep track of enemies, I think I need to use arrays, but it is still a bit slow. Does anyone know of other techniques for doing such a thing in a language that isn't object-oriented?
 
Programming wise, I find it helps a lot if the screen matrix is readable. Either through PEEK or special commands. I have not dived into Applesoft though to tell you which kinds of PEEK, VPEEK, SCREEN(), POINT() etc commands are available. For a few moving objects, you could store coordinates in regular variables but it makes it more clumsy to iterate than how arrays are. While integer variables ending with a % usually take up less memory, they also tend to be slower in most Microsoft derived Basics than your regular floating point variables, but it could be worthwhile seeing if A%(1..50) has a worse performance hit than A(1..50) for situations where you read the value more often than you change it.

Another approach of course is to allocate a block of RAM at the end or outside of Basic workspace area, and store coordinates in a direct access way. It would mean you use PEEK all the time and need a method to ensure Basic doesn't corrupt this memory, but in certain situations you might find PEEK is faster than reading a variable value, in particular if you just need coordinates that lie well within the range 0-255.
 
Well, yeah... arrays are needed if you are going to keep track of a clump of enemies. But if you were to make a game where aliens would come at you sort of like the arcade game 1941, then you wouldn't need arrays.

As far as lo-res goes, keeping track of memory locations is tricky. The screen is actually three separate chunks of memory, not one continuous 1024 byte block. Even worse if you try for double lo-res, 'cause that's three separate chunks of video memory, plus another three separate chunks that you have to bank-switch. BUT, it does give you 80x40 res...

I can help you more with figuring this out, but it's 3am. Maybe tomorrow?
 
Why not just make a bunch of arrays for the baddies, and compare the distance from the bullet and player ship, to the saved locations of the bad guys?



~Paul
 
If I'm not mistaken, the SCRN function lets you sample pixels from the GR screen.



~Paul

http://www.calormen.com/Applesoft/reference.htm#key_10018

Yes. You can use the SCRN function to test pixels, .. like, test the pixel that's +1 unit in the direction that the bullet is firing, before it moves into that space, so it can see the color of the baddie itself. If you move the bullet before you test the screen, you may overwrite your enemy.

I did a bunch of AppleSoft BASIC as a kid.

I can help with this.







http://www.calormen.com/Applesoft/index.htm
/
In-Browser AppleSoft Basic emulator.. very fun to tinker with.
 
Last edited:
Back
Top