Submit templates for here.

← Back to all posts
👌🎮 Platformer video game template 🎮👌
PowerCoder (740)

This template will give you the simple yet important starting point for a platformer game. It will include smooth physics, movement, and a collision detection function.

IMPORTANT things to know:

  • To add walls and other objects make sure that the element has "object" as its class
  • The player element HAS TO have player as its id

What you can do with this template:

Link to that demo project: click me

(Link to demo 3: click me)

Platformer attributes:

  • {"y":STARTING_POINT_X, "x":STARTING_POINT_Y} - this will be the spawn point coordinates


  • collision(element1, element2); - detects collision between two elements
  • remove_px(str) - removes the "px" part of a string

Methods of Platformer:

  • check_death - detects if a player is below the screen's view
  • respawn - teleports you back to the spawn point
  • touching_platform - detects if the player is touching a platform
  • check_key - does some action with what keys are being pressed
  • jump - makes the player jump
  • left - makes the player move left
  • right - makes the player move right

UPDATES since 5/19/2020:

  • If you have a div with the class lava it will automatically recognize that as lava. And, If the player touches the lava, the game will respawn the player.
  • The gravity is more realistic! The longer you stay in the air going down, the more acceleration you get.

Contact me:

If you're having any issues please feel free to contact me at [email protected] and I will try to respond within the next 5 hours.

DannyIsCoding (698)

Super cool. Probably I will use it in the future. I don't code JS, but I plan on learning it in the future. Thanks for sharing

lukechu10 (4)

The movement is a bit jittery and not very natural. Otherwise, good job!

PowerCoder (740)

@lukechu10 Thanks 😁! I noticed that you didn't upvote...



PowerCoder (740)

@Zuhdi28 If you want to try using it, I can help you. Also, thanks for upvoting!


@PowerCoder no i don't need help


@PowerCoder also you can visit my post
you'll enjoy it

PowerCoder (740)

@Zuhdi28 I upvoted it. Nice knight:

xolyon (346)

Very Nice, will sure use!
There is a glitch were if you go off the edge and then back to the middle again the cube gets impaled in with the platform and doesn't die (and can still move around) this would be a cool feature for a game but how do you fix it lol

PowerCoder (740)

@xolyon Yeah. My tester(my brother) figured that out. I was going to do it. (And I know how to.) But, I thought that it would confuse a lot of people. Plus, it makes there be more work for whoever is using my template. But, since you brought it up, I will start trying to fix that. And, I will try to find a more efficient way than what I had in mind before.

xolyon (346)

@PowerCoder I kinda like the glitch tho (i know how to fix it too just people using it won't) so maybe leave it to code somewhere also could you add scroll or scenes?


mobile support much