Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    How to make a simple platformer game :>

    General Discussion
    2d-games howto howtomake helping
    2
    3
    197
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • NotJaldolfYT
      NotJaldolfYT last edited by

      To copy all code easily, go to this project 😜 play.creaticode.com/projects/679240dfee3a4781a5afde57

      Today 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!

      i have toddler humor

      info-creaticode 1 Reply Last reply Reply Quote 1
      • info-creaticode
        CreatiCode @NotJaldolfYT last edited by

        @jd131111

        Thank you for contributing to the community.

        I assume you got these pseudocode using the right-click menu’s “copy pseudocode” option, right?

        19a99a93-1554-4b40-89a1-4406fc9b88e1-image.png

        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.

        1 Reply Last reply Reply Quote 2
        • NotJaldolfYT
          NotJaldolfYT last edited by

          @info-creaticode Alright, thank you! 😄

          i have toddler humor

          1 Reply Last reply Reply Quote 1
          • First post
            Last post