👌🎮 Platformer video game template 🎮👌
h
PowerCoder (703)

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

Functions:

  • 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.

You are viewing a single comment. View All
PowerCoder (703)

@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.