English Amiga Board


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

 
 
Thread Tools
Old 18 November 2020, 16:57   #41
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,113
I did use sprites originally as you're right, pixel perfect collision easy but this doesn't work with my fake overlay so turned them into bobs.

At the moment I just use a basic rectangular collision box but as your shot is only 1 pixel wide, it seems to do the trick? No clever optimization, I just run through the list of 55 invaders and check for an overlap - if so, exit loop. Figured that 55 times round a loop shouldn't take too much time from a frame?

Probably can be done in a more clever way but if it works...

Will only revisit this if speed becomes an issue.
Havie is offline  
Old 19 November 2020, 11:11   #42
rothers
Registered User

 
Join Date: Apr 2018
Location: UK
Posts: 142
You've got me wondering what the shortest possible code for Space Invaders would be now. I think I could use the video ram routine to get it damned small.
rothers is offline  
Old 19 November 2020, 12:35   #43
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,113
Quote:
Originally Posted by rothers View Post
You've got me wondering what the shortest possible code for Space Invaders would be now. I think I could use the video ram routine to get it damned small.
You need to explain this more to us thickies - video ram routine?
Havie is offline  
Old 20 November 2020, 10:43   #44
rothers
Registered User

 
Join Date: Apr 2018
Location: UK
Posts: 142
So I think they only thing in the game you need to monitor is what the bullets are touching in video ram.

You'd be able to get away with doing this maybe every other frame.

As soon as the bullets are !=0 you can work out what's happened with a very simple set of checks.

Eg:

In all cases the bullet !=0 removes the bullet with a inverse paste of it.

There is no need to check the enemy bullets until they are below the top of the bases.

If they are above the player when !=0 (hit base).

If they are below the top of the player they have to have hit the player so player dies.

If they hit each other (the player bullets & enemy) the enemy bullet will destroy the player bullet, nice side effect?

If the player bullet is below the invaders (it hit a base or enemy bullet).

If the player bullet is above the invaders it hit the UFO, destroy UFO.

If it's within the invaders field you will be able to rough calculate what it hit, remove invader.

That's it.
rothers is offline  
Old 23 November 2020, 00:00   #45
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,113
Some helpful comments - thank you. Hadn't thought about Blitting inverse - doh, so simple!

Quick update:

All three different alien shot types are now in the game and work as in the arcade. Shot one fires at player and shots 2 and 3 follow a pattern from a 16 number table.

Player blows up if hit by alien shot.

Most bugs eradicated as I've gone along so movement is all good, correct invader dies when shot, bullets come from correct height depending on which invader is firing (I calculate which column of invaders is shooting and then work out the lowest invader still alive to fire the shot).

All being well, I sort out the lives and a bug with player blowing up. May be even add the invader sounds and upload a new version.

Then I need to work on the invader firing routine so it follows the arcade algorithm. Add the UFO and front end, add second player and high score then I'm done. Sounds simple...
Havie is offline  
Old 24 November 2020, 00:37   #46
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,113
Here is the latest version. Player blowing up bug sorted, added some basic sounds (needs work) and even had a go a the invader shooting algorithm (needs a bit more work). Lives now work and you even get a basic GAME OVER message. So game is playable now.

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

Need to add UFO and sort out some graphic corruption, invaders shooting and some dodgy collision detection next.
Havie is offline  
Old 24 November 2020, 15:47   #47
rothers
Registered User

 
Join Date: Apr 2018
Location: UK
Posts: 142
If you use the video ram based approach your collision detection will be pixel perfect and I'm pretty sure that's how the arcade machine works too.
rothers is offline  
Old 24 November 2020, 20:51   #48
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,113
Quote:
Originally Posted by rothers View Post
If you use the video ram based approach your collision detection will be pixel perfect and I'm pretty sure that's how the arcade machine works too.
Sorry - you need to give me a bit more detail. Are you talking about copying the screen where your shot is and erasing the shot and then check to see if this leaves some pixels and then calculating what has been hit?

At the moment I am using the point command as the shot is only 1 pixel wide. I am only checking the point above your shot but probably need to check more than this - just trying to reduce the number of checks as this will slow down my game...
Havie is offline  
Old 06 December 2020, 19:23   #49
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,113
All graphics done - just need to do numbers 0-9 for the scores.

UFO now working - doesn't explode or give score yet but next thing to do!

Nearly there...
Havie is offline  
Old 07 December 2020, 10:43   #50
rothers
Registered User

 
Join Date: Apr 2018
Location: UK
Posts: 142
Quote:
Originally Posted by Havie View Post
Sorry - you need to give me a bit more detail. Are you talking about copying the screen where your shot is and erasing the shot and then check to see if this leaves some pixels and then calculating what has been hit?

At the moment I am using the point command as the shot is only 1 pixel wide. I am only checking the point above your shot but probably need to check more than this - just trying to reduce the number of checks as this will slow down my game...

All that matters is what those bullets (enemy and player bullets) touch, yeah?

So just look just before pasting to see if there is !0 at the tip of the bullet location.

eg: assuming the bases are at 150px down

pix=GetPixel(bulletx,bullety); //look in video ram to see what colour the pixel is at the tip of the bullet before drawing it

if (pix!=0) {
if (bullety>150) { .... } //must have touched a base
if (bullety<151) {......} //must have touched an enemy
};

That's it, that will also be how the arcade does it because it's super fast and minimal.

Last edited by rothers; 07 December 2020 at 10:50.
rothers is offline  
Old 13 December 2020, 23:41   #51
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,113
Thanks - this is helpful although I have my own code working but might come back to yours if I feel it's not accurate enough.
Havie is offline  
Old 24 December 2020, 21:54   #52
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,113
Latest version which is now a proper and playable game is up in the Game Factory:

https://eab.abime.net/showthread.php...48#post1448248
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
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 09:16.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.10728 seconds with 12 queries