Minilop Retroware

MPAGD SHMUPKIT

Evento Player, Shmupkit

2 de agosto de 2022

O evento Player é bastante simples. Há controlos para o movimento para a esquerda e para a direita, e para o impulso para cima com a tecla de cima, que está limitado a meio do ecrã, mas é claro que podes alterá-lo.

A tecla de disparo requer um antirressalto (largá-la) antes de se poder efectuar outro disparo. Podias alterar isto se quisesses disparo automático, mas terias de programar com cuidado para evitar demasiados sprites no ecrã.

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

Tudo sobre MPAGD SHMUPKIT