Skip to main content
gamedev.net
🔒 Locked

GDI Help

Started by Icemage Jan 6, 2001 at 3:46 PM 4 replies 600+ views
Original Post
Icemage
Icemage
I''m Making a pong game and i cant figure out how to make the ball reverse its velocity when it hits the paddle im using GDI and here''s what i have been trying... ///////////////////////////////////////////////////////////////// if (ball_y > PADDLE_HEIGHT && ball_y < WINDOW_HEIGHT && ball_y == paddle_y && ball_x == paddle_x) { ball_xv = -ball_vx; } ///////////////////////////////////////////////////////////////// Ok i know i need to explain some of my variables... ball_y = the ball y axis ball_x = take a wild guess paddle_y = the height of the paddle (its on the bottom of the screen) paddle_x = the axis the paddle moves on ball_xv= the velocity of the ball going on the x axis ball_yv= the velocity of the ball going on the y axis Does anyone know how to help me??? IceMage
Felisandria is Hot, So is Jewelaye
SHilbert
SHilbert
Umm... could you give us a description of where things are on the screen? It doesn''t make sense to be flipping the x velocity of the ball if it hits a paddle on the bottom of the screen.

Visit my site!
Icemage
Icemage
opps i meant to put...


if (ball_y > PADDLE_HEIGHT && ball_y < WINDOW_HEIGHT &&
ball_y == paddle_y && ball_x == paddle_x)
{
ball_yv = -ball_yx;
{

Dark im learning to inprove all my skills not just dx
Felisandria is Hot, So is Jewelaye
SHilbert
SHilbert
That code looks like it will work only if the ball is in the exact center of the paddle. Try checking if the ball is within a range, rather than if it''s just on one pixel.

Visit my site!
Icemage
Icemage
Now how would i put a range on it?
Felisandria is Hot, So is Jewelaye

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.