Minilop Retroware

MPAGD SHMUPKIT

Evento do míssil inimigo

2 de agosto de 2022

Os mísseis inimigos descem pelo ecrã bastante depressa. Quando são lançados por um inimigo, passamos ao míssil a direção de deslocação do inimigo e fazemos o míssil desviar-se para a esquerda ou para a direita em conformidade: se o inimigo ia para a esquerda quando disparou, o míssil também se desviará para a esquerda.

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
	

Tudo sobre MPAGD SHMUPKIT