Tips On Making A Platform Game by Tommy Haaks

Started by kevin, October 27, 2008, 08:10:39 PM

Previous topic - Next topic

kevin





...Tips On Making A Platform Game In PlayBASIC...

 Tips and tricks for building a platform game by Tommy Haaks

 Visit www.PlayBasic.com


1. How to get started?


 Okay, so you want to join the Heroes Quest competition of Underware Design and have no idea how to get going? Never did a platformer game before? Then read on - you'll find some things to twist your brain around here.




2. The basics


What does a simple platformer need?

 A main character that the user can control. In most games the main character can walk or run left and right and jump up. In some games he can pass platforms while jumping up, in others he collides with the platforms and his up jump is stopped and you'll need to use the gaps between platforms for jumping.  Enemies are strolling along the platforms or some can fly around the whole level. In some games enemies can also jump and trace you, in other games enemies can just fall down to lower platforms.




3. The maps


That's the toughest part for many platformer coders: How do I create a map?  Luckily PlayBasic offers many options:

3.1 Use a mapping tool

 You can use one of the existing mapping tools (PlayMapper, PlayMapper Mini, Mappy) to design your maps. There are libraries to load them in and display them. The advantage is that you can easily design your maps. The biggest disadvantage is that you can't offer an ingame level editor.


3.2 Use text files for maps

Another option is to use simple text files to design your maps.  Files containing lines like these could be read easily and used to create maps using the PB map commands:


W          K               K     W
W   K    GGGGG           M       W
W    M           M      GGGGGG   W
W  GGGGGG   GGGGGGG              W
WE                           S   W
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW


 W could be a wall, G some ground tile, K a key to collect and M a monster. S could be the start position of your main character and E the exit to reach after all keys are collected.

 Read this file line by line and scan it character by character to create your map. Each character specifies a map tile or some animated sprite.  Advantage is that you can use any text editor to create your maps. An ingame editor can also easily be integrated as it just needs to write simple text files for  the levels which is pretty simple and covered in a lot of PB examples.


3.3 Just use sprites

Instead of using the map commands you could simply use sprites instead of maps. Basically maps are just helper structures to simplify your life. But some people find the map stuff too complicated and prefer to create separate sprites for the map tiles. Instead of using "CheckMapImpact" to test against map collisions you could put all sprites into the same sprite collision class and use plain sprite collision checks (PB command "SpriteHit") between player/monster and map sprites.





4. Common map commands


- Use CreateMapGfx to connect a map with an image containing the tile graphics,
- Use CheckMapImpact to check if a given rectangle collides with a tile on a given layer of the map. Keep in mind that all layers/levels of a map share the same tile size and that the CheckMapImpact only tests against the whole tile size - no matter what graphic image is shown on that tile!
- Use NewMap and NewLevel if you want to create your maps dynamically, use LoadLevel from the SLib named maps to load PlayMapper maps, the PlayMapperClassic slib etc
- Use DrawMap to draw the layers of your map.




5. Player / main character and monsters


  You can't put those into the map as they are active objects which move. Place some marker tile on a special info layer that is not drawn or always use the same coordinates to place them onto your map. Or check for a free position (remember the CheckMapImpact and SpriteHit command).

5.1 Moving objects and check collisions

For all moving objects (main character, monsters, elevators) and special objects (exit, teleporter, collectibles, bonus objects) you'll need "CheckMapImpact" to test for free positions on your map. You'll need "SpriteHit" to check for object/object collisions (main character "hits" collectable, reaches the exit or stands on an elevator).




6. Suggested PlayBasic examples to look at


  *PB\Projects\Examples\Maps\MapBasics
  *PB\Projects\Games\2D_&_3D_Platformer\2D_Version





7. Other hints


- Use the forum to ask questions
- Look at the examples and try to understand them. Modify them to get more experience
- Use the forum
- Create small example projects to solve certain issues in your game
- Use the forum (got that now?)





8. Enjoy


 Don't forget: you code your games for fun. If it gets too complicated, take a break. Free your mind for some time. Rethink. Try again. Still stuck? Ask someone for help. Contribute stuff to the community for feedback and to help other game coders.

Cheers,
Tommy