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 >
Text File  |  1997-06-30  |  2KB  |  60 lines

  1. <PICLOAD>SPACE_3.DAJ
  2.  
  3.  
  4.                          SPACE INVADERS TUTORIAL PT 1C 
  5.                              --------------------- 
  6.                                 BY CHRIS SWINSON 
  7.  
  8.  
  9. If the alien was displayed as position 0,0 and the size of the  alien was 16x16 
  10. then  the size of the detection would range from  0,0 to 16,16.  You need  some 
  11. form of check to see if the lazer  shot has entered that area or not.
  12.  
  13.  
  14. <PICSHOWD>000,000,208,052,032 
  15.  
  16.  
  17.    
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. In  number  terms the alien is between 0-15 on the X axis and 0-15   on  the  Y 
  29. axis. So if the bullets X position is between 0-15 then  thats is check 1 done. 
  30. Check 2 is to see is the Y position is  between 0-15. So if the bullet was at X 
  31. position  of  10  and  the  Y  position of 10 then this  would  be  seen  as  a 
  32. collision.  If  the Y  position of the bullet is 10 then that is check 2  done. 
  33. And is  within the area of the alien.  So if the X position of the bullet   was 
  34. 20 but the Y position was 10 then check 1 ( The X axis ) Is  false .  It is out 
  35. of the 0-15 area.  Check 2 ( The Y axis ) Is  true.  But as both checks or  not 
  36. true then no collision is  detected.
  37.  
  38. In IF THEN ELSE terms it would look like...
  39.  
  40. If X_alien=0 and If X_bullet<=15 and X_bullet=>0 and Y_bullet<=15  
  41.   then Collision detected 
  42.  
  43.  
  44. X_bullet<=15  : Checks if the bullet is in the X range of the  
  45.               : alien.
  46.               : This means if the bullet is equal to or smaller  
  47.               : than 15 on the X axis .   
  48.   
  49. X_bullet>=0   : Make sure Bullet is in the X range.
  50.  
  51. Y_bullet<=15  : Make sure bullet is in the Y range of the alien.
  52.  
  53. Though  if the alien were to move the Command If line would be  larger as  more 
  54. checks would have to be done. Ie X_alien 1 would  change so more checks on that 
  55. would be needed.
  56.  
  57. So you may see that the line would be very long.  And as there is  more than  1 
  58. alien the program would be massive. And massive  programs need lot of CPU time.
  59.  
  60.