• Bruce

Vertical Shmup - Part 3 - Setting up the Player Spaceship

Now that we have the play area set up, let's create the player spaceship and work on the code for controlling it.


MENU: EDITOR > SPRITES (beginners tutorial)


Here's mine, but feel free to get creative with yours!



I'm going to add a second frame for the spaceship, which will display if the player users the THRUST key to move up the screen. It'll just have a little jetflame coming out the rear end of the ship. The quickest way to do this is:

M copy the current frame

I insert a new frame

K paste the original frame


and then edit it:




OK, that will do for the graphics for now, next we'll write some code for controlling the Spaceship, the rules I want are:


1) Left and right keys to move the space ship left and right

2) A Thrust key, which, when pressed, will move the player halfway up the screen, but if released the player will drift back to the bottom. When thrust is pressed we also want to display Frame 001 to show the jetflame



First, let's define our keys, I prefer QAOP Space:


MENU: EDITOR > KEYBOARD CONTROLS (beginners tutorial)





MENU: EVENTS > PLAYER (beginners tutorial)


To start with we'll add some basic MPAGD script that will handle movement:




EVENT PLAYER


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

IF KEY UP				; Player presses up (thrust)
	LET FRAME = 1			; switch to the frame that shows jetflame
	IF Y > 80			; If player is below the 80 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 (no jetflame)
	SPRITEDOWN			; move player down
ENDIF

						; PLAYER MOVEMENT
						; ====================
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
						; BOUNDARY CHECK
						; ====================
IF Y >= BOTTOMEDGE		; has player gone beyond the bottom edge?
	LET Y = BOTTOMEDGE	; yes, keep them at the bottom edge
ENDIF

Right, that's enough for now, let's build the game and see how it's working...





Success!, the ship can move left and right, thrust up and drift back down again.





Next, we are going to create a basic weapon for the player that they can fire



NEXT: PART 4: THE PLAYER WEAPON

5 views0 comments

Recent Posts

See All

A couple of people have asked for some tutorials on creating a Vertical Shoot-em up with MPAGD, something along the lines of Imagine's classic, Arcadia. This sounded like a good challenge....but one I

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