![]() |
Welcome To Swish-Designs.co.uk Have a Nice Friday
Platform Game Engine Tutorial Part 1 - SwishMax
Learn the basics on how to build working platform game engine
Controls Used:
![]()
First Of All
Welcome to Part 1 of the platform game engine tutorial, in this tutorial you will learn how to do a static platform game engine such as the likes of Bombjack, Donkey Kong etc where the screen stays static. you will start of by creating a character all the way to creating his / her world
i hope you enjoy this tutorial, now lets begin.
Step.1
Open swishmax and set the movie size to whatever size you want your game to be a good size is 500 x 500 but i have used 230 x 240 for the sake of this tutorial. you will need some resources if you havent already got them, these wil consist of a main character, enemies if you want them, game objects (Tiles) to make up the platforms and scenery and goodies (collectables) a good resourse site to find these at is Gaming World, here you will find everything from tile sheets, characters, bosses, enemies, collectables and backgrounds. Ok with the dimension of you game set you should now have a blank canvas to work on like fig.1 below.
Fig.1
Step.2
Insert your Backdrop into the the movie click on the thumbnail below to view a larger image
save it into your project folder and insert it into you project movie.
once inserted name it as background. if you name everything it keeps objects easily identifiable.
you should have something looking like fig.2 below.
Fig.2
Step.3
Now you will need a tile set for the platforms, when you find a tile set you like, it will have to be edited in you favourite image editing software such as photoshop or fireworks etc.to crop out the platforms you wish to use, save them as seperate images in you project folder. below is my platform already croped from the chip set.
sandstone platform croped from tile sheet (chip set)
place you platforms anywhere in the play area of the movie, this is called making the world
you are creating a virtual wordl for you character to navigate, when you have finished you might end up with something resembling fig.3 below.
Fig.3
Once you have placed all you platforms on the scene group them all together as a sprite and name the sprite platforms the layout in your outline panel should now look like fig.4 below, with the platforms sprite above the background image.
Fig.4
Step.4
Now to create the Main Character of the game, select a character sprite set and again each seperate movement must be croped out from the sprite sheet using your favourite image editing software, the background also needs to be transparent, see below for the character i have chose to use.
Fig.5
Fig.5 (character sprite sheet)
Step.5
If you have no idea what you are doing at this stage do not worry just download a character set below i have previously created to make things a little easier.
Download The Character.zip file
No wether you have made your own sprites or downloaded the ready made ones, you need to import all your images into you project movie, when you have all 12 images in the movie select them all and group them together as a sprite, name the sprite as character.
Step.6
Now we need to give the character sprite actions to call at at later time using swishcsript.
All the Left facing images group together as a sprite and name the sprite left and add the following actions, see fig.6 below.
Fig.6
Repeat this proccess for the right images and the up images for the down images use the up images. naming the sprites acordingly right, up and down.
once complete add the following settings to the character sprite, see fig.7
Fig.7
Add the following actionscript to the character sprite.
gravity = 0.2;
yspeed = 0;
xspeed = 1;
}
onEnterFrame() {
if (_root.character) {
if (Key.isDown(Key.LEFT)) {
left.nextFrameAndStop();
gotoAndStop(4);
_x -= xspeed;
}
if (Key.isDown(Key.RIGHT)) {
right.nextFrameAndStop();
gotoAndStop(3);
_x += xspeed;
}
}
}
onFrame (1) {
stop();
}
onFrame (2) {
stop();
}
onFrame (3) {
stop();
}
onFrame (4) {
stop();
}
You shoud now have a character with animation, and moves left and right when the arrow keys are pressed, see example below. Example:
Step.7
Ok now you have everything in place and your character has got some movement lets bring the gravity into play, and tell the character to stop when he hits a platform by adding the following code underneath the exsisting move right code.yspeed += gravity;
while (_root.world.hitTest(_x, _y+_height/2, true)) {
_y--;
yspeed = 0;
}
if (!_root.world.hitTest(_x, _y+_height/2+1, true)) {
_y += yspeed;
} else {
yspeed = 0;
}
You should now have something working like in the example below.
Example:
Step.8
Ok now for making you character jump, every platform game needs a jump control, this is simply done by creating a new sprite Character_Control and add the following code to it.
}
on (keyPress("<Space>")) {
character_controls.play();
}
onFrame (1) {
stop();
}
onFrame (2) {
_root.character._y = _root.character._y - 5;
}
onFrame (3) {
_root.character._y = _root.character._y - 9;
}
onFrame (4) {
_root.character._y = _root.character._y - 9;
}
onFrame (5) {
_root.character._y = _root.character._y - 9;
}
onFrame (6) {
_root.character._y = _root.character._y - 6;
}
onFrame (7) {
gotoAndPlay(1);
}
You should now have something looking like the example below.
Example:
thats most of the common controls covered in platform games next i will cover enemies, repositioning when a life is lost, health bars, scoring system, and recording a high score using php so watch out for part 2 of my plat form game engine tutorial, i hope this has helped you in some way. .


