How to make a simple platformer game :>
-
To copy all code easily, go to this project play.creaticode.com/projects/679240dfee3a4781a5afde57Today we are making a simple platformer game! Start by making the character sprite, you can make it a square, triangle, human, squirrel, alien, anything. Set your characters size to anything, for this, Iâm going with 85. Use this code to make it!
when green flag clicked set size to (100) %
Nice!
Now, lets add a simple gravity system. Weâre going to have to add the âLevelGroundâ sprite, lets do it!
After creating that sprite, you can use this code inside of âLevelGroundâ to make it go to the middle, make sure your characterâs sprite is at the bottom of the boundary box for creating sprites, its fine for it to be outwards
when green flag clicked go to center
Now, for the player, copy this script for basic gravity!
when green flag clicked set [Gravity v] to [0] forever change [Gravity v] by (-0.2) if <key [space v] pressed?> then set [Gravity v] to [6] wait until <<not <key [space v] pressed?>> and <touching (LevelGround v)?>> endif end end
Oh, no! Our players gravity is going down super fast! Letâs fix that!
First, add a variable called: âCooldownâ, make this simple line:
when green flag clicked set [Cooldown v] to [N]
Awesome! Now, lets edit our script that was for gravity.
when green flag clicked set [Gravity v] to [0] forever wait (1) [milliseconds v] change [Gravity v] by (-0.25621) if <<(Cooldown) = [N]> and <key [space v] pressed?>> then set [Cooldown v] to [Y] set [Gravity v] to [6] change y by (2) repeat until <<touching (LevelGround v)?> or <(Gravity) = [0]>> set [Cooldown v] to [N] change [Gravity v] by (-0.25621) set [Cooldown v] to [Y] end set [Cooldown v] to [N] endif if <touching (LevelGround v)?> then set [Gravity v] to [0] endif end end
Awesome! Now, we have to make movement.
Make these 2 when pressing a / d blocks!
when [a v] key pressed repeat until <not <key [a v] pressed?>> change x by (-4) end end
And
when [d v] key pressed repeat until <not <key [d v] pressed?>> change x by (4) end end
Awesome! Now, you can make your own custom levels, you should add a second sprite for the outline so that if you collide with it, you donât go upwards, hope this helps!
-
Thank you for contributing to the community.
I assume you got these pseudocode using the right-click menuâs âcopy pseudocodeâ option, right?
FYI, you can also use the âExport PNG Imageâ option above it, so that you get high quality block images. Of course, you can also use screen capture. Usually a block image is easier to read compared to the pseudocode for beginners.
-
@info-creaticode Alright, thank you!