Ok so it's time for my first noob questions I guess..
I've been working through the nerdy nights tutorials and I feel pretty good about where I am. But now I want to improve what I have.
I'm wanting to improve on the basic object collision in the pong game.
The basic logic was pretty easy to figure out based on the tutorial:
BUT it's not exactly accurate since the ball can get behind the paddle and technically all those rules are true and a bounce happens. I've searched the forums and read a lot of posts on object collision and I think I have a good idea of what needs to happen. I need to create a collision bounding box instead of using the single x,y coordinates for each object. Maybe just a suggestion (provide link) of which of the previous posts in the forum I should really look at for inspiration would help me. I tried looking at other example code people had posted but most of the links are broken now..
The other thing I'm having trouble understanding is moving objects off screen. How do games like double dragon keep the enemies from wrapping around to the other side when they are knocked off screen? And more specifically related to the pong game how can you register a score every time no matter how fast the ball is moving?
If I check the balls x position to see if it's past one of the paddles there's an 8pixel gap that it would need to be in for that to register a score. So what if the ball gets moving really fast 16pixels/frame? now it's too fast and will skip over this area wrapping around to the other side of the screen and only registers a score sometimes. So how do I make this bulletproof so it will always register a score?
Thanks guys this forum is amazing.
I've been working through the nerdy nights tutorials and I feel pretty good about where I am. But now I want to improve what I have.
I'm wanting to improve on the basic object collision in the pong game.
The basic logic was pretty easy to figure out based on the tutorial:
Code:
if ball x < paddle1x
if ball y > paddle y top
if ball y < paddle y bottom
bounce, ball now moving right
if ball y > paddle y top
if ball y < paddle y bottom
bounce, ball now moving right
BUT it's not exactly accurate since the ball can get behind the paddle and technically all those rules are true and a bounce happens. I've searched the forums and read a lot of posts on object collision and I think I have a good idea of what needs to happen. I need to create a collision bounding box instead of using the single x,y coordinates for each object. Maybe just a suggestion (provide link) of which of the previous posts in the forum I should really look at for inspiration would help me. I tried looking at other example code people had posted but most of the links are broken now..
The other thing I'm having trouble understanding is moving objects off screen. How do games like double dragon keep the enemies from wrapping around to the other side when they are knocked off screen? And more specifically related to the pong game how can you register a score every time no matter how fast the ball is moving?
If I check the balls x position to see if it's past one of the paddles there's an 8pixel gap that it would need to be in for that to register a score. So what if the ball gets moving really fast 16pixels/frame? now it's too fast and will skip over this area wrapping around to the other side of the screen and only registers a score sometimes. So how do I make this bulletproof so it will always register a score?
Thanks guys this forum is amazing.