English Amiga Board


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

 
 
Thread Tools
Old 21 October 2020, 10:06   #1
Toki
Registered User
 
Toki's Avatar
 
Join Date: Feb 2016
Location: Birmingham
Age: 60
Posts: 107
Space Invaders Code

Hi

Does anyone have Space Invaders written in Blitz Basic (or amos) which I could use to study?

Thanks
Toki is offline  
Old 21 October 2020, 12:15   #2
pink^abyss
Registered User
 
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
Sorry, no, but this looks quite easy to follow:
https://codeheir.com/2019/03/17/how-...vaders-1978-7/

From my "Tiny Invaders" i have the advice not to use single blits for every invader but to group them in rows. When one invader is out then you simply clear it from the row. So you get a away with 5 blits for all invaders.
Also for collision detection you can simply check first in which row the player shot is and then simply go through all invaders in that row with an aabb check.
pink^abyss is offline  
Old 21 October 2020, 15:00   #3
Toki
Registered User
 
Toki's Avatar
 
Join Date: Feb 2016
Location: Birmingham
Age: 60
Posts: 107
Thanks, that is very useful.

I'm going to base it on Andy McAdam's YouTube tutorial on the Windows version of Blitz Basic [ Show youtube player ]

He includes code for a simple space invaders type game

It will be a challenge. So a version written specifically for the Amiga would be the ideal.

Your link will provide me with help. Thanks.
Toki is offline  
Old 26 October 2020, 11:24   #4
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
One thing I've noticed with Space Invaders is the ripple effect as they move which I guess is down to only one row being moved each frame/loop? Always thought that this was quite an important aspect of the game and when the whole set move as one - it just looks wrong.

May make it slightly more complicated to program but on the other hand it would make it run more quickly...
Havie is offline  
Old 27 October 2020, 09:05   #5
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Also I have two versions of Space Invaders that I have written on PC in Blitz Basic. One is based on an old C+VG cover and the other is a Pacman/invaders mashup. Both based on the same code.

You can download them here:

http://www.havsoft.co.uk/Shooters.htm

Happy to share my code if you want (if you like spaghetti).
Havie is offline  
Old 27 October 2020, 13:58   #6
AF2013
Registered User
 
Join Date: Apr 2013
Location: .
Posts: 250
Thumbs up

Quote:
Originally Posted by Havie View Post
Also I have two versions of Space Invaders that I have written on PC in Blitz Basic. One is based on an old C+VG cover and the other is a Pacman/invaders mashup. Both based on the same code.

You can download them here:

http://www.havsoft.co.uk/Shooters.htm

Happy to share my code if you want (if you like spaghetti).
Hello there,

It was interesting on how you made the shoot em up R Type Game as You used counter timer on different enemys waves was good to learn on how is made.

thanks for sharing as I guess more people will learn from it
AF2013 is offline  
Old 27 October 2020, 22:08   #7
Toki
Registered User
 
Toki's Avatar
 
Join Date: Feb 2016
Location: Birmingham
Age: 60
Posts: 107
Yes Havie

Please share your code or the space Invader games. I've been playing around with BB on my Amiga, but also BB on the PC. I'm hoping the PC version will help instruct me on the amiga version. I've had a look at your code for a few of your games. I love the Doctor Who game, I shall be playing more of that. Your Flappy Bird game on the Amiga could be a godsend for me working out how to write games in BB for the amiga. It's perfect for learning because it's not too hard. I've struggled to find BB games on the amiga at this kind of level. Thanks very much.
Toki is offline  
Old 27 October 2020, 23:39   #8
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
Quote:
Originally Posted by pink^abyss View Post
From my "Tiny Invaders" i have the advice not to use single blits for every invader but to group them in rows. When one invader is out then you simply clear it from the row. So you get a away with 5 blits for all invaders.
Also for collision detection you can simply check first in which row the player shot is and then simply go through all invaders in that row with an aabb check.
You can get away with zero blits for the aliens (unless there's a hit) by drawing the aliens on the back playfield and just moving the playfield about relative to the front playfield. The only blit which needs doing then is to remove an alien when it (or add an explosion, etc)
E-Penguin is offline  
Old 28 October 2020, 00:12   #9
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Thanks - I'll have a root around and sort out my code for you to have a look at!

Might have a play around with Invaders and report back my findings!

I have one game to finish and upload -Dragonfire and was asked to make Flappy Bird have a wider screen - which is proving to be trickier than I thought as everything is coded for the width I have set the screen. On top of this, my son has challenged me to do something on the PC (he is using unity and doing 3D - no idea on this) so I am wading my way through an AppGameKit primer at the moment (loved Blitz on the PC but more modern languages have a lot more built in). And now you've thrown in Invaders...

At the same time, one game I'd like to have a crack at is Road Runner as this was never converted to the Amiga...so much to do and so little time!!!

Flappy Bird thread here which shows how my thinking has changed over time:

http://eab.abime.net/showthread.php?...ghlight=flappy
Havie is offline  
Old 28 October 2020, 00:14   #10
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Quote:
Originally Posted by E-Penguin View Post
You can get away with zero blits for the aliens (unless there's a hit) by drawing the aliens on the back playfield and just moving the playfield about relative to the front playfield. The only blit which needs doing then is to remove an alien when it (or add an explosion, etc)
Would never had thought of this - what a good idea and possible simpler than drawing only one or two columns each time!
Havie is offline  
Old 28 October 2020, 01:38   #11
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 862
Quote:
Originally Posted by Havie View Post
Would never had thought of this - what a good idea and possible simpler than drawing only one or two columns each time!
You could get creative with the DisplayScroll command and move rows (horizontally) independently too...
Coagulus is offline  
Old 28 October 2020, 07:16   #12
Toki
Registered User
 
Toki's Avatar
 
Join Date: Feb 2016
Location: Birmingham
Age: 60
Posts: 107
Thanks Havie for the suggestions. The thread for your old version of Flappy Bird was interesting, all the different suggestions.
I shall have a study of the code. So much easier to learn something with a completed version.
Toki is offline  
Old 28 October 2020, 07:23   #13
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Ok - had a think and a look at the game running on YouTube to refresh the old memory!

Invaders move in rows not columns and move from the bottom up which creates the ripple effect in their movement as well as allowing you to shoot Invaders higher up the column.

Also, let's assume that we are going for an arcade perfect port so as I see it there a a few ways to get this working. First off, you only need 2 colours so 1 bitplane would be enough - this would speed up any graphic processes (you could use 2 bitplanes for 4 colours if your wanted or change the palette as you move down the screen to create the overlay effect). Options suggested so far:

1) Blit each invader each frame - slowest
2) Blit rows of invaders in one go
3) Draw all the invaders on screen and use Displayscroll to move rows left and right
4) Set up a screen 3 screen widths, draw all the invaders onto the screen and use hardware scrolling to give the impression the invaders are moving left and right.

1), 2) and 3) would allow the ripple effect and 4) wouldn't.

We also have to remember that the invaders move down so you for 4) you'd need to hardware scroll the up as well which make the area taken up (and memory used even greater). Whereas in 1) and 2) you just Blit them moving down and in 3) move a row at a time using Displayscroll.

You also need to think about the animation of the invaders. Obviously in 1) and 2) you just Blit the different animation as they move. In 3) and 4) this becomes more difficult to do but you could have two screens with the different animations on and double buffer between them to create effect but all the invaders would animate simultaneously (or with four colours you could create two animation frames with palette switching).

Also, if you want to jazz the game up then you'd need to up the bitplanes and this will slow down your Blits. But if you went Dualplayfield then you could have 8 colours for the invaders and have an 8 colour background without any trouble.

Shields would be just drawn to screen at the beginning of each level and slowly eroded by the invaders fire or your shots. In double buffered mode they would need to be on each screen and eroded identically.

All missiles and you shot would be sprites so if you used any form of scrolling, they wouldn't be affected. Your base could either be another bob or a sprite depending on how many missiles on screen at once? Looking at the actual arcade game, it doesn't seem to fire more than 3 missiles at once so you'd probably make your base a sprite and this would make pixel perfect collision detection really simple.

Anyway, my random thoughts and I'm sure others who are better programmers would have better suggestions...
Havie is offline  
Old 28 October 2020, 07:25   #14
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Quote:
Originally Posted by AF2013 View Post
Hello there,

It was interesting on how you made the shoot em up R Type Game as You used counter timer on different enemys waves was good to learn on how is made.

thanks for sharing as I guess more people will learn from it
Yep - didn't know how else to do it! Just have a counter going up 1 per loop and trigger waves at set times. I'd be interested in different methods.
Havie is offline  
Old 28 October 2020, 07:50   #15
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Ok - have uploaded Santa Invaders/Christmas Invaders to the zone with the source code so should compile and run (hopefully).

http://eab.abime.net/zone/Santa%20Invaders.zip

One thing I did a while back was make all my games run in a window as they were coded to run full screen at 640x480 (they were written a while back) so they wouldn't work properly or at all on modern graphics cars!
Havie is offline  
Old 28 October 2020, 21:57   #16
Toki
Registered User
 
Toki's Avatar
 
Join Date: Feb 2016
Location: Birmingham
Age: 60
Posts: 107
Xmas has come early! Thanks Havie. It compiled fine. An addictive game! Thanks for your considerations above. It really helps my learning seeing all your different considerations. I shall be studying the Santa code and the Flappy Bird one. I'm not sure if learning BB on the PC and the Amiga at the same time is advisable, but so far it seems to help.
Toki is offline  
Old 28 October 2020, 22:14   #17
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
I have had a bit of a play on Amiga Blitz and put together a quick demo - has 55 invaders and you can move your base left and right (joystick or z and x keys).

Basically I use just one screen and set up all the invaders. Then I move and animate one invader per frame. This creates the ripple effect and seems to work fine on an A500 (under Winuae).

The screen is currently 4 colours as I I just do a plain Blit each time and each invader as a black box around them so when they move they wipe out what it is left behind (same for you player base). With only four colours I only have 3 to work with (colour 0 is transparent) so I have one for the background (black), 1 for the invaders (white) and one for the shields and base (green). If I want another one for the spaceship (red) then either I need to go to 8 colours or use teh Copper to change the palette on the fly (if I did this down the screen the your shots would change colour as they go up the screen which would simulate the coloured overlays).

Also, at the bottom where there are multiple colours I could have a split screen which was a set of different colours.

This will mean that (when programmed) the invaders will automatically speed up as initially it takes 55 frames to move them all. If 30 are destroyed then it will only take 25 frames to move them all so in 50 frames they will move twice as fast. With one invader it will move 55 times the initial speed. Your base speed will remain constant.

Test demo in the zone:

http://eab.abime.net/zone/test.

Also found this page which helped my thinking:

https://www.computerarcheology.com/A...SpaceInvaders/

I hope this helps!
Havie is offline  
Old 28 October 2020, 22:15   #18
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Quote:
Originally Posted by Toki View Post
Xmas has come early! Thanks Havie. It compiled fine. An addictive game! Thanks for your considerations above. It really helps my learning seeing all your different considerations. I shall be studying the Santa code and the Flappy Bird one. I'm not sure if learning BB on the PC and the Amiga at the same time is advisable, but so far it seems to help.
If you haven't tried Pacman v Ghost Invaders - I think this is a better game as it has power ups too!
Havie is offline  
Old 28 October 2020, 23:56   #19
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,893
Update:

After saying I wouldn't use Types I have recoded the invader's variables using a dimmed Type as this allows me easily to reduce the list in order to speed up the invaders. Also, when a collision between the player shot and an invader is detected then it is easy enough to kill the type! As the shot will be a sprite I can use PColl during the loop and then kill the Type if there is a collision (after showing the explosion).

Obviously if the shot hits a base I need to destroy a part of the base but as the bases are a different colour then this should be fine?

So tomorrow, I'll sort out the sprites and get the player shooting and killing the invaders. And I can add the score in too.

Then, if there is time, I'll program the three different types of shot and you'll have a functioning game.
Havie is offline  
Old 29 October 2020, 13:09   #20
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
Quote:
Originally Posted by Havie View Post
3) Draw all the invaders on screen and use Displayscroll to move rows left and right

We also have to remember that the invaders move down so you for 4) you'd need to hardware scroll the up as well which make the area taken up (and memory used even greater). Whereas in 1) and 2) you just Blit them moving down and in 3) move a row at a time using Displayscroll.
I think DisplayScroll only does horizontal - you'd still need to move the playfield up and down to manage the vertical.
E-Penguin 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
A500 Space Invaders MB revision rossb support.Hardware 20 22 October 2019 20:45
SPACE INVADERS samples? volvo_0ne request.Modules 5 28 February 2018 22:16
Pit Fighter / Super Space Invaders! stainy HOL data problems 4 23 May 2008 08:45
[Found: Mr Wobbly Leg Versus The Invaders From Space] Space-Invaders game? Dindel Looking for a game name ? 5 06 March 2008 10:05
Super Space Invaders (WHDLOAD) Retro1234 request.Old Rare Games 3 30 October 2006 20:12

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 06:17.

Top

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