Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Parabolic Canon Ball Movement
Qt 6.11 is out! See what's new in the release blog

Parabolic Canon Ball Movement

Scheduled Pinned Locked Moved Solved Game Development
7 Posts 3 Posters 2.6k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MongKong
    wrote on last edited by
    #1

    So far i made it so when im looking right and i press space i shoot a canonball which moves like a parabola, tho i dont know how to make it so when im turned left and i press space that it moves the same way, just to the left....
    this is the code:
    0_1552069536052_a974f8d9-89e4-4ff8-b4e6-835cca820ea2-image.png

    and this is the parabolic function im using:

    0_1552069864205_b04daff4-fbb7-4c13-b9ba-df4c2bad654d-image.png

    And with my variables:

    0_1552069796399_2b120432-d866-47b5-a547-81cc4ccd85e7-image.png

    I added *0.5 because i didn't canon ball to land too far away from the ship

    Here is the video on how the canon ball moves using this function :
    https://streamable.com/4xpnx

    If any1 could figure out a function which i could use for when my ship is turned left i'd really appreciate it... I tried adding and subtracting stuff from this function but nothing worked out as it should've.... So please if anyone knows any solution to it please help me out :(

    JonBJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Its not so nice with pictures for code as you cant cut and paste. or even scroll to see all of it.
      Anyway,
      the x()+moveByX seems to control the direction so
      MoveByX += 0.1
      could be
      MoveByX += - 0.1 ( when direction == 3 )
      to decrease the x ?

      the parabolic seems only to be used for the y decay.

      M 1 Reply Last reply
      3
      • M MongKong

        So far i made it so when im looking right and i press space i shoot a canonball which moves like a parabola, tho i dont know how to make it so when im turned left and i press space that it moves the same way, just to the left....
        this is the code:
        0_1552069536052_a974f8d9-89e4-4ff8-b4e6-835cca820ea2-image.png

        and this is the parabolic function im using:

        0_1552069864205_b04daff4-fbb7-4c13-b9ba-df4c2bad654d-image.png

        And with my variables:

        0_1552069796399_2b120432-d866-47b5-a547-81cc4ccd85e7-image.png

        I added *0.5 because i didn't canon ball to land too far away from the ship

        Here is the video on how the canon ball moves using this function :
        https://streamable.com/4xpnx

        If any1 could figure out a function which i could use for when my ship is turned left i'd really appreciate it... I tried adding and subtracting stuff from this function but nothing worked out as it should've.... So please if anyone knows any solution to it please help me out :(

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @MongKong
        Image

        g / 2 vO2 cos2(theta)
        

        Excuse me, may I ask: is g gravity? is v velocity?? what is the big O??? :)

        M 1 Reply Last reply
        0
        • mrjjM mrjj

          Hi
          Its not so nice with pictures for code as you cant cut and paste. or even scroll to see all of it.
          Anyway,
          the x()+moveByX seems to control the direction so
          MoveByX += 0.1
          could be
          MoveByX += - 0.1 ( when direction == 3 )
          to decrease the x ?

          the parabolic seems only to be used for the y decay.

          M Offline
          M Offline
          MongKong
          wrote on last edited by
          #4

          @mrjj
          i tried and it doesn't work :/ y is getting lower and lower

          1 Reply Last reply
          0
          • JonBJ JonB

            @MongKong
            Image

            g / 2 vO2 cos2(theta)
            

            Excuse me, may I ask: is g gravity? is v velocity?? what is the big O??? :)

            M Offline
            M Offline
            MongKong
            wrote on last edited by
            #5

            @JonB

            ye g is gravity while v0 is initial speed

            1 Reply Last reply
            1
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @MongKong said in Parabolic Canon Ball Movement:

              tried and it doesn't work :

              try to output x values with QDebug and see why.

              M 1 Reply Last reply
              3
              • mrjjM mrjj

                @MongKong said in Parabolic Canon Ball Movement:

                tried and it doesn't work :

                try to output x values with QDebug and see why.

                M Offline
                M Offline
                MongKong
                wrote on last edited by
                #7

                @mrjj
                yep i did so and i figured it out just minutes ago, i had to add another variable for X cords and now it's working perfectly thank you all!

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved