Difference between revisions of "PyGame Platform"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Collectables)
Line 42: Line 42:
 
[[File:Plat player object.gif]]
 
[[File:Plat player object.gif]]
  
==Collectables==
+
===Collectables===
Load your map again in Tiled, this time within the objects layer create 3 new objects for the coins. I have created 3 new objects called Coin1 , Coin2 , and Coin 3. I have also set the type to Coin and the height & width of each object to 16 pixels:
+
Now within the objects layer create 3 new objects for the coins. I have created 3 new objects called Coin1 , Coin2 , and Coin 3. I have also set the type to Coin and the height & width of each object to 16 pixels:
  
 
[[File:Plat coin objects.gif]]
 
[[File:Plat coin objects.gif]]

Revision as of 08:37, 6 July 2018

This will show you how to create a platform game using a tiled map, and rectangular based collision detection.

Create Map

Tiled

You will firstly need to install the Tiled program from the website and link below. In college the Tiled executeables are on moodle, under project, technical skill, monogame, and tiled. I have also added links to other tutorials for using Tiled.

Tiled Website and Download

Tiled Map Editor

Tutorials for using Tiled

Offical Tiled Tutorials

Tiled Basics

Tiled Youtube Playlist Series

Written Version of Above Tutorials


New Tiled Map

You will need a new tiled map, the tile size in the screen shot is 128 pixels, in the end i actually changed this to 32 x 32 and resized the tiles accordingly:

Plat new map.gif

Add Tile Set

Now your map is created we need to add a tile set:

New tileset.gif

I would always recommend you make sure to choose embed and based on tileset image:

Draw Your Level

Now you have a tile set build a simple set of platforms. You should rename the layer to something like Tiles:

Plat simple map.gif

Add Player Object

Now you have a section of platforms, we can now set the position of the player. This will also be the object moved by the code and player input. So insert an object layer, and then use the rectangle tool to create the object. My final player was 60 pixels high and 40 pixels wide:

Plat player object.gif

Collectables

Now within the objects layer create 3 new objects for the coins. I have created 3 new objects called Coin1 , Coin2 , and Coin 3. I have also set the type to Coin and the height & width of each object to 16 pixels:

Plat coin objects.gif

Now, click on the Object layer and in the properties panel add a custom property (+ symbol in bottom left corner). Make an integer called Coin_Count:

Plat coin count.gif

Key & Door

Edit your tiled map by adding a key object into the objects layer, and also place a door object in your main layer which represents your door:

Plat key door.gif