top of page
Writer's pictureBruce

Enemy Missile Event

Enemy missiles travel down the screen quite quickly, when they are spawned by an Enemy we pass the enemies direction of travel to the missile and then make the missile veer either left or right accordingly, so if the enemy was going left when they fired the missile then the missile will also veer left.



EVENT SPRITETYPE3
;=======  ENEMY MISSILES   ============
;======================================
; VARIABLES
; =======================================================
; DIRECTION	-	DIRECTION OF ENEMY TRAVEL WHEN RELEASED
; SETTINGA	-	availabe for use in your game
; SETTINGB	-	availabe for use in your game
; AIRBORNE	-	availabe for use in your game	
; JUMPSPEED	-	availabe for use in your game
; ========================================================


SPRITEINK 71					; bright white
SPRITEDOWN					; go down fast (3 times
SPRITEDOWN
SPRITEDOWN
IF DIRECTION = 0				; was alien going down when fired?
ELSE							; if so, do nothing
	IF DIRECTION < 8			; was alien going right?
		SPRITERIGHT			; make missile veer right
	ELSE
		IF DIRECTION = 8		; was alien going straight up?
		ELSE					; do nothing
		SPRITELEFT			; alien was going left, veer missile left
		ENDIF
	ENDIF
ENDIF


IF COLLISION PLAYER			; has missile collided with player?
	IF X > M					; is missile to the right of player?
		SUBTRACT M FROM X	; subtract M to find out how far to the right
		IF RND <= 10			; its a hit!
			OTHER			; switch to the player
			LET DIRECTION = 99 	; trigger the player explosion
			ENDSPRITE			; switch back to this event
			LET DIRECTION = 99	; explode the missile
		ENDIF
		ADD M TO X
	ELSE						; not to the right
		IF X < M				; is missile to the left?	
			SUBTRACT X FROM M	; yes, how far to left?
			IF M <= 8		; its a hit!
				OTHER		;switch to the player
				LET DIRECTION = 99 ; trigger the player explosion
				ENDSPRITE		; switch back to this event
				LET DIRECTION = 99 ; explode the missile
			ENDIF
			ADD X TO M			; reset M
		ELSE					; must have been a direct hit
			OTHER				; switch to the player
			LET DIRECTION = 99	; trigger the player explosion
			ENDSPRITE			; switch back to this event
		ENDIF
	ENDIF   	  
ENDIF

IF DIRECTION = 99				; Explosion requested
	LET TYPE = 6				; switch to the explosion type
	LET IMAGE = 4				; and explosion image
	LET FRAME = 0				; and the first frame
	LET DIRECTION = 2		; and tell the explosion its an enemy missile
ENDIF

IF Y >= 188					; has missile reached bottom of the screen
	REMOVE					; remove it
	SUBTRACT 1 FROM S			; decrement the sprite counter
ENDIF
	


52 views0 comments

Recent Posts

See All

Variables Reference - Shmupkit

Here's a full list of the Global Variables used by Shmupkit, I've tried to leave as many as possible free for you own use in your games....

Lost Game Event - Shmupkit

A simple GAME OVER message, similar to the GET READY one in the Restart Screen Event: EVENT LOSTGAME AT 10 12 REPEAT 10 READ A CHR A...

Kill Player Event - Shmupkit

What happens when a player is killed?, we decrement their lives and update the lives counter on screen EVENT KILLPLAYER SUBTRACT 1 FROM...

Comments


Want to support my work?....Buy my games!

aboutME

Hello, I'm Bruce and I write games for old 8bit computers using Jonathan Cauldwell's excellent Multi-Platform Arcade Games Designer (MPAGD)

​

I've written a few successful* games for the Sinclair ZX Spectrum and MSX platforms that have been (largely) well received including Twenty Four Hour Parsley People scoring a 10 out of 10 on Planeta Sinclair.

​

In my blog I am sharing lots of the code that I wrote for my games, in a way that you can use in your own games.   I've commented it so that you'll learn some of the techniques I use to create interesting new mechanics and help your games stand out from the pack.

​

MPAGD includes lots of standard scripts, they're great to get you started, but if you're new (or just rusty) when it comes to writing code, hopefully my tutorials will help you get started and  turn your imagination into awesome 8 bit games!

​

​

All my code is free to use and do with as you please, but if you find them useful please feel free to buy me a coffee ...or better still - buy or download my games :)

​

*successful is a very relative term in 8bit computer games

​

bottom of page