• Bruce

Player Event - Shmupkit

The player event is quite straightforward. There are controls for left and right movement, thrust upward with the up key, this is restricted to half way up the screen but obviously you can change this.



The fire key requires denouncing (releasing) before another shot can be fired. You could change this if you wanted auto-fire but you'd need to code carefully to avoid to many on screen sprites.



EVENT PLAYER
;===========        PLAYER       ============
;============================================
;
; VARIABLES
; ===========================================
; DIRECTION	-	TRIGGER PLAYER EXPLOSION (99)
; SETTINGA	-	FIRE KEY DEBOUNCING
; SETTINGB	-	availabe for use in your game
; AIRBORNE	-	availabe for use in your game	
; JUMPSPEED	-	availabe for use in your game
; ===========================================


							; COLOURS
							; =======================
SPRITEINK 69					; Bright Cyan ink

							; PLAYER MOVEMENT
							; ====================
IF KEY UP					; Player presses up (thrust)
	LET FRAME = 1				; switch to the frame that shows jetflame
	IF Y > 92 				; If player is below the 92 y pixel line
		SPRITEUP				; move player up
		SPRITEUP				; and up again (faster movement)
	ENDIF
ELSE							; if player is not pressing thrust
	LET FRAME = 0				; switch to the regular spaceship
	SPRITEDOWN				; move player down
ENDIF

IF KEY LEFT					; has player pressed LEFT?
	IF CANGOLEFT				; can the player move left?	
		SPRITELEFT			; yes, move player left
		SPRITELEFT			; and again (moves faster)
	ENDIF 
ENDIF

IF KEY RIGHT					; has the player pressed RIGHT?			
	IF CANGORIGHT				; yes, can the player move right?				
		SPRITERIGHT			; yes, move player right
		SPRITERIGHT			; and again (moves faster)
	ENDIF									
ENDIF

							; FIRE PHOTON TORPEDOS
							; ====================
IF KEY FIRE					; if player presses fire key
	IF SETTINGA = 0			; if firekey is debounced
		IF S < 12			; and if less than 12 sprites on screen
			SPAWN 1 1		; spawn a bullet
			LET SETTINGA = 1	; bounce the fire key
			SPAWNED			; switch to the Photon Torpedo
			LET DIRECTION = 1	; set its direction to 1 (up)
			ENDSPRITE		; return to this sprite
		ENDIF
	ENDIF
ELSE							; fire key not pressed
	LET SETTINGA = 0			; debounce it
ENDIF				


							; BOUNDARY CHECK
							; ====================
IF Y >= BOTTOMEDGE			; has player gone beyond the bottom edge?
	LET Y = BOTTOMEDGE		; yes, keep them at the bottom edge
ENDIF

							; REQUEST PLAYER EXPLOSION
							; ====================
IF DIRECTION = 99				; player explosion requested
	LET TYPE = 6				; switch it to the explosion type
	LET IMAGE = 4				; and the explosion image
	LET FRAME = 0				; reset it to first frame
	LET DIRECTION = 1			; this is the player exploding
ENDIF

							; STORE PLAYER X Y FOR OTHER EVENTS
							; =================================
LET M = X					; store player X in M
LET N = Y					; store player Y in N


12 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 with my most recent game - 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