home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
No Fragments Archive 10: Diskmags
/
nf_archive_10.iso
/
MAGS
/
ST_PLUS
/
STP18.MSA
/
STP_INVAD_1C.STP
< prev
next >
Wrap
Text File
|
1997-06-30
|
2KB
|
60 lines
<PICLOAD>SPACE_3.DAJ
SPACE INVADERS TUTORIAL PT 1C
---------------------
BY CHRIS SWINSON
If the alien was displayed as position 0,0 and the size of the alien was 16x16
then the size of the detection would range from 0,0 to 16,16. You need some
form of check to see if the lazer shot has entered that area or not.
<PICSHOWD>000,000,208,052,032
In number terms the alien is between 0-15 on the X axis and 0-15 on the Y
axis. So if the bullets X position is between 0-15 then thats is check 1 done.
Check 2 is to see is the Y position is between 0-15. So if the bullet was at X
position of 10 and the Y position of 10 then this would be seen as a
collision. If the Y position of the bullet is 10 then that is check 2 done.
And is within the area of the alien. So if the X position of the bullet was
20 but the Y position was 10 then check 1 ( The X axis ) Is false . It is out
of the 0-15 area. Check 2 ( The Y axis ) Is true. But as both checks or not
true then no collision is detected.
In IF THEN ELSE terms it would look like...
If X_alien=0 and If X_bullet<=15 and X_bullet=>0 and Y_bullet<=15
then Collision detected
X_bullet<=15 : Checks if the bullet is in the X range of the
: alien.
: This means if the bullet is equal to or smaller
: than 15 on the X axis .
X_bullet>=0 : Make sure Bullet is in the X range.
Y_bullet<=15 : Make sure bullet is in the Y range of the alien.
Though if the alien were to move the Command If line would be larger as more
checks would have to be done. Ie X_alien 1 would change so more checks on that
would be needed.
So you may see that the line would be very long. And as there is more than 1
alien the program would be massive. And massive programs need lot of CPU time.