• Bruce

Enemy Spawner Event

This is the engine room of Shmupkit. The Spawner itself is a blank sprite, and it's event controls which enemies should be spawned, where, how many and sets up all the parameters that control the enemy which are passed to the enemy event.


It's basically a data table of values that are read from whenever the player progresses to a new level/attack wave.


The Spawner makes sure the right sprites, numbers of sprites and delays between sprites are spawned correctly, and ensures there aren't too many sprites on screen at once which could otherwise cause display issues.



EVENT SPRITETYPE7
; VARIABLES
; =======================================================
; DIRECTION	-	availabe for use in your game
; SETTINGA	-	STATUS:
;				0 = GET DATA FOR NEXT LEVEL
;				1 = SPAWN ALIENS
; SETTINGB	-	TIMER BETWEEN SPAWNS
; AIRBORNE	-	SPAWNER MOVEMENT (not implemented yet)	
; JUMPSPEED	-	# OF ENEMIES SPAWNER
; ========================================================


								; ALIEN SPAWNER
								; ============


IF SETTINGA = 0					; first time we run this
	LET JUMPSPEED = 0				; reset the enemies spawned counter
	LET SETTINGB = 0				; reset the timer
	RESTORE				; start from the beginning of the data table
	REPEAT L						; get the data for this level
	READ AIRBORNE					; get the spawner movement
	READ X						; get starting x position
	READ Y						; get starting y position
	READ J						; get the enemy sprite type
	READ K						; get the enemy image
	READ E						; how many enemies in this level?
	READ G						; delay between releasing each enemy
	READ P						; points for a kill
	READ C						; colour
	READ W						; weapon
	READ H						; fire weapon probability
	READ Q						; min height to release weapons
	READ I					; x distance for alien weapon triggering	
	ENDREPEAT				
	LET D = E					; how many kills to get bonus?
	LET F = E					; enemies remaining
	ADD 1 TO SETTINGA         		; prevent this running again	
ENDIF



IF SETTINGB = G					; has timer reached the delay point?
	IF JUMPSPEED < E				; are there still enemies left to spawn?
		IF S < 9					; are there 10 or less enemies already on screen?
			SPAWN J K			; spawn an enemy
			ADD 1 TO JUMPSPEED	; increment the number spawned
			SPAWNED				; switch to the enemy sprite
			LET DIRECTION = 0		; set its initial direction to 0
			ENDSPRITE			; return to the spawner		
		ENDIF
	ELSE					; all enemies in this level have been spawned
		IF F = 0
			ADD 1 TO L					; get ready for next level
				IF L = 13	; have we reached the end of the levels?
				LET L = 1	; yes, start again
		ENDIF
		LET SETTINGA = 0			; get data for next level
		ENDIF
	ENDIF
	LET SETTINGB = 0				; reset the timer
ENDIF

ADD 1 TO SETTINGB					; increment the timer



								; Alien Spawner Data Table
								;=========================
DATA 0 132 8 5 2 8 8 5 67 1 10 100 8
DATA 0 100 8 5 2 10 8 10 68 1 10 100 32
DATA 0 232 16 5 2 12 6 15 69 1 8 100 100
DATA 0 8 32 5 2 6 6 15 70 1 8 100 8
DATA 0 232 146 5 2 6 6 20 71 1 4 100 8
DATA 0 8 146 5 2 6 6 20 66 1 4 100 8
DATA 0 40 8 5 2 6 8 5 69 1 2 140 8
DATA 0 200 8 5 2 6 8 5 69 1 2 140 8
DATA 0 200 8 5 2 6 8 5 69 1 2 140 8
DATA 0 8 128 5 2 6 8 5 67 1 10 100 8
DATA 0 80 8 5 2 6 8 5 67 1 10 100 8
DATA 0 80 8 5 2 6 8 5 67 1 10 100 8



20 views0 comments

Recent Posts

See All

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. VARIABLES USED BY SHMUPKIT ========================== A -

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 DELAY 5 ENDREPEAT DELAY 100 DATA 'G' 'A' 'M' 'E' ' ' 'O' 'V' 'E

What happens when a player is killed?, we decrement their lives and update the lives counter on screen EVENT KILLPLAYER SUBTRACT 1 FROM LIVES ; reduce number of lives remaining AT 0 16 ; upda

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