Player Missile Event - Shmupkit
The player Missile is defined in Spite Type 1. It uses a simple 16x16 sprite image, and is launched when the player presses the fire key.
As standard, the missile will only travel half the height of the screen ,but you easily edit this, or use one of the available variables for defining it, which might be a neat way of rewarding the player with a power up.
When it reaches its maximum distance, or reaches the top of the screen, or hits an enemy, it triggers an explosion, by incrementing the frame - since the torpedo explosion is contained in frames 1-4
EVENT SPRITETYPE1 ;======= PLAYER TORPEDOS ============ ;============================================ ; ; VARIABLES ; ======================================================= ; DIRECTION - DIRECTION OF TRAVEL, 99 = TRIGGER EXPLOSION ; SETTINGA - availabe for use in your game ; SETTINGB - DISTANCE TRAVELLED COUNTER ; AIRBORNE - availabe for use in your game ; JUMPSPEED - availabe for use in your game ; ======================================================== IF DIRECTION 1 ; Torpedo travel up LET IMAGE = 1 ; make sure we are on image 1 REPEAT 6 ; torpedos move quick, so do this 6 times SPRITEUP ; move up ADD 2 TO SETTINGB ; increase the distance travelled by 2 IF SETTINGB > = 88 ; when distance travelled = 88 LET DIRECTION = 99 ; run the explode routine ENDIF IF Y <= 8 ; has the torpedo reached the top? LET DIRECTION = 99 ; yes, so explode it EXIT ; exit this event (as we are in a loop) ENDIF ENDREPEAT ENDIF ; EXPLODE THE TORPEDO ; =================== IF DIRECTION = 99 ; torpedo explosion requested ADD 1 TO FRAME ; increment the frame IF FRAME = 5 ; when we reach the last frame REMOVE ; remove the torpedo SUBTRACT 1 FROM S ; decrement the sprite counter ENDIF ENDIF