Difference between revisions of "PyGame Platform"
(→Collectables) |
|||
Line 42: | Line 42: | ||
[[File:Plat player object.gif]] | [[File:Plat player object.gif]] | ||
− | ==Collectables== | + | ===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: | |
[[File:Plat coin objects.gif]] | [[File:Plat coin objects.gif]] |
Revision as of 07:37, 6 July 2018
This will show you how to create a platform game using a tiled map, and rectangular based collision detection.
Contents
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
Tutorials for using Tiled
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:
Add Tile Set
Now your map is created we need to add a tile set:
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:
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:
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:
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:
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: