Navigation

    CreatiCode Scratch Forum

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

    Tutorial: Gravity without 2D Physics

    General Discussion
    2
    3
    352
    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.
    • c.
      Cαƚƚყ Mod Helper last edited by c.

      removeable: yes I know that physics blocks exist but this is for users (like me) that don’t know how to use them.

      Does your gravity look like this?
      Screenrecording2024-09-0420.04.32-ezgif.com-video-to-gif-converter.gif

      Don’t you wish it could look like this without the use of 2D Physics blocks?
      Screenrecording2024-09-0420.56.38-ezgif.com-video-to-gif-converter.gif
      Well, I can show you how! First, you need to select a sprite!
      I’ll choose a white squircle.

      Then you need a Level sprite! I will just use a square. Alright, let’s get to coding! First we need a

      when green flag clicked
      

      block!
      Now we need a forever loop! It should look something like this:
      Screenshot 2024-09-04 20.13.47.png

      We should make a Gravity variable, and don’t forget to start off with Gravity being 0!
      Here’s what I did:
      Screenshot 2024-09-04 20.20.03.png

      Now don’t forget to add collision!
      Screenshot 2024-09-04 20.24.33.png

      This didn’t quite work. Let’s fix that!
      Screenshot 2024-09-04 20.45.54.png
      Perfect! Now we need a key to press to start it! I’ll use Space Bar.
      Screenshot 2024-09-04 20.48.05.png
      Uh oh! The player can jump indefinitely! Let’s fix that!
      Screenshot 2024-09-04 20.53.03.png

      Good job! You just made basic, but customizable Gravity!
      It’s a bit buggy, but it works! If you know how to fix some issues, please contact me by making a new topic with the title; “RE: Tutorial: Gravity without 2D Physics”, and you may tag me as well.

      I hope you found this tutorial useful, and I might make some more!

      Official Forums Moderator

      jeffreyrb03-gmail 1 Reply Last reply Reply Quote 3
      • jeffreyrb03-gmail
        JaecadeJnight Mod Helper @c. last edited by

        @106809nes oh cool, this is what you normally do in Scratch. Basically just gotta check forever if the player is not touching the ground. If not, you have to change y by a negative value like -0.5 until they are touching the ground. Good tutorial tho

        #LLJW
        <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

        c. 1 Reply Last reply Reply Quote 3
        • c.
          Cαƚƚყ Mod Helper @jeffreyrb03-gmail last edited by c.

          @jeffreyrb03-gmail
          Thanks! I do this a lot for quick and simple projects, but for big games like mine, I make usable, completely customizable, non-buggy gravity.

          Official Forums Moderator

          1 Reply Last reply Reply Quote 2
          • Referenced by  c. c. 
          • Referenced by  c. c. 
          • Referenced by  c. c. 
          • Referenced by  c. c. 
          • Locked by  c. c. 
          • First post
            Last post