PONG ball spawn angle

0 favourites
  • 13 posts
From the Asset Store
Enjoy the powerful simulation with accurate ball physics, build with realistic ball spinning animations
  • Hello!

    I'm working on a PONG remake and I want the ball to spawn/respawn from the center of the screen every time. However, sometimes it will spawn directly vertical (only 90 degrees) or very close to that in which case it takes a long time for the ball to reach the paddle on either side of the screen. If anyone could tell me how I can set the ball to spawn within two very large increments on a 360 degree circle. To put this in other words, I don't want the ball to be able to spawn in a 40 degree increment on the top of the circle, nor on the bottom of the circle. Hopefully this makes sense. If not, I'll gladly try and clarify if anyone has any questions. Massive thanks!

  • Hi, I did mine this way. I set up variables for random x and random y.

    When the goal was scored , I set a random angle for x and y between certain values. So when the ball spawned after scoring it set off again at that random angle.

    Hope this helps

    *tried uploading a pic for you, but doesn't seem to be working

  • Ah, I see what you're saying. Yes that makes sense and does help! If you could upload a picture, that would help tons. If not, I'll try some stuff out. Thanks!

  • Let say a ball has 360 digrees and your game its landscape.

    Then you dont want the angles of 80 to 100 for not allow the ball go down and 260 to 280.when the ball spawn set the angle "choose(round.random(280,80),round.random(100,260))"

  • Try on created set angle random(random(45,135),135,225)

    Just pick angles towards where you want it to go most.

    Hope it helps Im still learning too.

    Jay

  • If you have a problem with "choose(round.random(280,80),round.random(100,260))"

    Try

    "choose(round.random(280,360),round.random(0,80), round.random(100,260))"

  • Maybe with "choose(round.random(280,80),round.random(100,260))" you dont have the best result.

    Try

    "choose(round.random(280,360),round.random(0,80),round.random(100,260))"

  • random(random(A,A)), random(random (B,B)

    The first random picks a random set of angles.

    eg. "A,A" angle towards player 1 or "B,B" towards player 2.

    Then the second random will set the angle random between chosen numbers.

    savvito123 this will Work wont it? I tried it once before.

    Jay

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • random(random(A,A)), random(random (B,B)

    The first random picks a random set of angles.

    eg. "A,A" angle towards player 1 or "B,B" towards player 2.

    Then the second random will set the angle random between chosen numbers.

    savvito123 this will Work wont it? I tried it once before.

    Jay

    Do you mean to create 2 events?

    If player 1 lose then run random(random(A,A)) and if player 2 lose then run the other BB?

    Yes it work like that.

    But personal i prefer the choose , it limit the events and also i prefer the round.random so it not give an angle of 30,789765. I avoid decimals all the way.

    The choose give you the ability to add as many numbers you want.

  • drive.google.com/open

    ID: 5271

    Picture of event ^

    Hope that clears it up

    Jay

  • drive.google.com/open

    ID: 5271

    Picture of event ^

    Hope that clears it up

    Jay

    Its not make sense to me..

    random works like that "random(value1,value2)"

    You just set the value1 and value2 to random.

    Construct it calculate the random number -15,15 and the 165,195 and gives you a random number between the 2 calculated numbers.

    Its the same with random(-15,195) this will give you the same result.

    with choose

    "choose(value1,value2,value3 etc)" it choose one of this values even if this values are random like

    "choose(random(0,100),random(150,250),random(350,450))"

    It choose one of this 3 number , from 0 to 100 or from 150 to 250 or from 350 to 450.

  • player1 player2

    random(random(0,0),random(0,0))

    This will send the ball to a random player at a random angle.

    Just set the angles to player 1 and 2.

    Jay

  • Build a capx and send it.

    I dont think this is working.

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