platformer game - tips

So you wanna make 2D platformer game? Here are tips for you:

1. You need to check collisions between objects. Treat each object as a rectangle and check coordinates to examine if there is overlap. If there is, perform pixel based detection (there can be transparent pixels).

2. You can use tile map for making game levels

3. Objects can have "platform" property. If platform == null, they are falling because of gravity. But if objects is falling you still need to examine if there's collision with a platform.

4. To make various bonuses/collectable items that player can collect - make inventory object where each property is value of some bonus or feature:

{energy: 100, gold: 10, spells: 20} // player properties

and make bonus object look like this:

{energy: 10, gold: 2} // bonus that adds 10 energy and 2 gold.

you can also make some negative bonuses (e.g. poisons, thorns)

{energy: -10, xp: 2} // it takes 10 points of energy, though it gives you 2 xp.

Read also about multisets/bags: https://en.wikipedia.org/wiki/Multiset

5. to make AI for NPC, you can use state machines or async/await (wrap some bigger actions like in promises) e.g.

await approachTo(enemy);

await punch(enemy);

6. you can have multilayered backgrounds with parallax efect, so layers far away would move slower  than closer ones

7. for more realism you could integrate physics engine (e.g. https://rapier.rs/ )

8. think about graphics style and technicalities. 

  • raster or vector graphics?
  • graphics authored in graphics editor, or graphics generated procedural in real time?
  • 2D or 3D? (remember that you can have also 3D graphics prerendered to 2D bitmaps, or you can have 2D gameplay on 3D rendered scene etc.)
  • realistic? pixel-art? low-poly? comic style?
  • you would use graphics made by someone else or do you plan to make graphics by yourself? If so, you'd need to learn some pixel art, maybe Blender etc.

Comments

Popular posts from this blog

JavaScript landscape, job market and what next