How do I make ball movement like One Tap Tennis?

0 favourites
  • 11 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hello everyone,

    I would like to make the ball movement like One Tap Tennis game.

    Please show me how to start with this ball behavior.

    Thanks

  • Looks like it might be a good experiment for the new z feature.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah, I think so.

    Hello Kyatric , I saw that you have made a similar game like this:

    kyatric.com/games/boule-et-bill-le-tournoi-de-ping-pong

    Could you please share your tutorial?

    Many Thanks.

  • This was made as contract work, I cannot share the sources for it and I have no time at this point to write a complete tutorial on the subject.

  • u basically need a parabola movement, check this forum post there are some example files there also, and from that u need to change the perspective of things, and do a bit of fake-3d sort of thing.

    qarp or lerp should do it.

  • Thank you,

    I will try it.

    Kyatric I understood. Thank you btw!

  • Here are some notes on how I’d go about it, and most of the math worked out. Hopefully I’ve provided sufficient explanations.

    The 3D physics of the ball is probably the easiest. We already have xy and we can do z with a instance variable. Just add three other instance variables to keep track of velocities: vx,vy,vz. Also we can use a variable g for gravity.

    Then the motion can be done with:

    g=300

    Add g*dt to vz

    Set x to x+vx*dt

    Set y to y+vy*dt

    Set z to z+vz*dt

    The result is parabolic motion on the z axis. You can make it bounce off the ground with:

    Z>0

    — set z to -abs(z)

    You can control where the ball will land by setting the initial velocities.

    t = distance(x,y, goalx, goaly)/speed

    Vx = (goalx-x) /t

    Vy = (goaly-y) /t

    Vy = -g*t

    To see the z motion we need to rotate everything around in 3D somehow. You can do that on the same objects, but it’s probably simpler to just position new objects from the old ones. It turns out a 3D rotation is basically the same as a 2d one.

    Rotate on the YZ plane:

    a = the amount to rotate

    y, z = the point to rotate

    cy, cz = the center of rotation

    NewY = (y-cy)*cos(a)-(z-cz)*sin(a)+cy

    NewZ = (y-cy)*sin(a)+(z-cz)*cos(a)+cz

    We can then add perspective fairly easily. It’s basically just dividing x and y by z.

    Perspective:

    X,y,z = the position

    Cx, cy = the center of perspective

    Fov = field of vision. 300 is a decent default.

    Eye = camera distance from scene.

    NewX = (x-cx)*fov/(z+eye) +cx

    NewY = (y-cy)*fov/(z+eye) +cy

    Scale = 1*fov/(z+eye)

    Perspective is wonky when behind or too close. Increase eye till everything is in front.

  • I got around some wifi, so here is a working example:

    dropbox.com/s/0cygc1w5noarffs/3dball.capx

    Something to play with at least.

  • That's wonderful, R0J0hound

    Thank you so much!

  • I got around some wifi, so here is a working example:

    https://www.dropbox.com/s/0cygc1w5noarffs/3dball.capx?dl=1

    Something to play with at least.

    R0J0hound It is impressive. Why do not you try to make the camera engine for the scene with objects?

    I tried to do something like that, but I’m not sure about the optimization.

    c2community.ru/imagehosting/images/2018/May/18/rec14.gif

  • That looks cool and all but it’s not something I’ve wanted to do.

    The only optimization i do is simplifying and organizing events to be straightforward and easy to use as possible. Speed rarely is a concern to me. I’d rather things work right than have it work fast.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)