You can do it by moving in 3D, which actually is pretty simple.
First off, since all of the behaviors are in 2d, let me explain how to move with events. Which is also pretty simple.
Give your sprite an instance variable “vx” for x velocity. And add this event:
— sprite: set x to self.x + self.vx*dt
Pretty simple. You can do the same for y and z if you add a z variable too. You can change the vx, vy, vz variables to change the speed.
Now, to see the ball move in a 3D way we need some way to show the z. One idea is to have two objects: the ball and a shadow. The shadow would move in 2d and the ball would be z pixels above.
So if shadow has all our varaiables we can do this:
— shadow: set x to self.x + self.vx*dt
— shadow: set y to self.y + self.vy*dt
— shadow: set z to self.z + self.vz*dt
— Ball: set position to (shadow.x, shadow.y+shadow.z)
That takes care of the 3D positioning and the linear motion. We can make the ball move in a parabola like a real ball by adding this action:
Shadow: add 300*dt to dz
300 is the gravity and can be adjusted as needed. Next we can do a slew of other simple things.
The launch? Set the v variables to point in the direction you want.
Start of layout
— shadow: set vx to 100*cos(30)
— shadow: set vy to 100*sin(30)
— shadow: set vz to -200
100 is the ground speed.
30 is the angle you want to hit the ball.
-200 is the vertical speed. This is what would change a ground ball vs lobbing in the air.
You could also look up spherical coordinates that can give you an xyz from two angles and a speed. I just don’t know them off the top of my head, it would be ideal though.
Has ball landed?
— set v variable to 0
Or if you want it to bounce
Set vz to -0.5*self.vz
You can also make the xy speeds slow with
Set vx to 0.5*self.vx
Same for vy
Wall bouncing can be done similarly.
Anyways just some ideas.