Learn to Code via Tutorials on Repl.it!

← Back to all posts
Simple platformer base
GameDev46 (211)

This is a very easy to use platformer base, entirely made by me!!

So all you need to do to use it is look at the top of the script.js file for the arrays, numbers in these brackets [], and look at the easy o understand names of them

Platforms array

The array called platforms is, you guessed it, the positions and sizes of the platforms! The platforms are equal to 4 numbers in the array, the 1st number is the x position, the 2nd is the y position, the 3rd is the length and the 4th is the height, so when deleting platforms delete all 4 numbers otherwise it will become very weird.

bounce array

This array controls where the bounce pads are and is layed out in the same way as the platforms array. 1st is the x, then the y, then the length and finally the height.

enemies array

The enemies array is done differently than the platforms and bounce array as each enemy is only 3 values! The first is the one you change depending on the platform size that the enemy is on, the higher the number the smaller the amount of platform the enemy covers and the smaller the number the more of the platform the enemy covers!! I suggest fiddling about with this value until it stops just where you want it to! The 2nd value is the x position and the 3rd is the y.

backing array

This array renders the dark blue buildings in the background, this array only needs one value for each building, the distance from the roof it will spawn, the higher the number the closer to the bottom of the game it's roof will be, but the lower the value the closer to the top of the game it's roof will be.

coins array

This draws the coins on the map which you have to collect! It only needs to input values the 1st is the x and the 2nd is the y!! It gets a bit more complicated now as for the win screen to show properly you will need to change a small value in the code!!
So when you are happy with your coin placing go to the timer.js file and head down to line 21 and you should say an if statement

if (coins == 23) {

in the if statement on line 21 replace 23 or whatever number is at the position of 23 with the amount of coins in your game and tada everything is working and the win screen will show when you finish by collecting all the coins

Simple right??

ALL OTHER ARRAYS AND CODE DON'T NEED TO BE EDITED

Comments
hotnewtop
EpicGamer007 (1736)

Wow! This is really fun! Though I think this should go in the templates section because this seems more like a template than a tutorial but great job!