Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / help with pong

Author
Message
Patrick987
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location:
Posted: 23rd Jun 2009 05:27
im just beginning with darkgdk and i read all the tutorials but i don't really get how to get the ball to move in a pong game or how to make the computer paddle follow the ball any help would be great
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd Jun 2009 06:12
Check out the challenge that was run a few weeks ago. A couple of good source code listings with comments that could help.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Patrick987
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location:
Posted: 24th Jun 2009 01:08
i figured out how to make the paddle follow the ball but i still don't get how to make the ball move on its own or bounce off the walls
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 24th Jun 2009 02:51
Mostly look at the dbRotateSprite function and dbMoveSprite function. That gets you started. On a personal level I prefer to keep track of the ball's data myself. I use floats to track the x and y position but use ints in the dbSprite (num, x, y, img) function to place it. If I have an angle and a speed I break them down into displacement values for the x and y movement and add these components to the current position to get the new postion.

xDisplacement = dbCos (angle) * speed;
yDisplacement = dbSin (angle) * speed;

Loop {
x += xDisplacement;
y += yDisplacement;

dbSprite (num, x, y, imgnum);
}

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Patrick987
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location:
Posted: 24th Jun 2009 02:59
ok ill give that a try thanks a lot

Login to post a reply

Server time is: 2024-10-01 05:53:17
Your offset time is: 2024-10-01 05:53:17