New answers tagged

0

To expand on (one way you could do) the mathematics behind @Gummibeer's answer.. Keep in mind this physics calculation d = vt + 1/2at2 or distance = initialVelocity*time + 1/2 acceleration * time2 Say your turret is at [0,0] and the enemy is at [10,0] and.. Say your bullet starts at 0 velocity, and accelerates at 1 unit/sec/sec If we aim at ...


1

You need to create two different instances of the class. I suggest you not to check for input inside your class but in your game loop, so you can handle events for both instances. Pseudocode below: Pong::Paddle player1(texture1, bounds1); Pong::Paddle player2(texture2, bounds2); while(running){ if(keyDown == W) player1.setYDirection(-1); else ...


0

Taking some inspiration from Aj_'s answer, I was able to resolve the collision successfully with the following code: I found that I needed to test for both: wall.CollisionRectangle.Center.Y - player.FootRectangle.Center.Y) * rectRatio > wall.CollisionRectangle.Center.X - player.FootRectangle.Center.X and wall.CollisionRectangle.Center.Y - ...



Top 50 recent answers are included