Jump to content
  • Advertisement
Sign in to follow this  

Pong Question

This topic is 4724 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, well, I’ve got a working pong prototype, but there are a few things I’m having trouble with 1) when ever I play other versions of pong, the ball speeds up as the game goes on, and it also seems like it reacts differently depending on the part of the paddle it hits. the first part is easy enough, but the second, well, am I imagining things, and if not how would you best get that effect? 2)I can't figure out how to get rid of the mouse 3)I want to have some kind of message box pop up saying "player wins!" if I use the MessageBox() function it would show up over the game, you can only see it if you close the main window. here's a link to the code, with project and a compiled exe http://reilz.741.com/code/Pong.zip note on the code: it's divided into a game obj and a DDrawObj, there are 5 files: a header file for each class("game.h" also has some #defines) to play, just run it, it will run until you hit esc, resetting with each score, control the left paddle with up and down, right paddle with A and Z, I have a really crappy ai set up, to use it go into the header file an change NUM_PLAYERS to 1. any comments on the code outside of what I’m asking about(including bugs or glitches or methods which work better) are welcome.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Reilz
and it also seems like it reacts differently depending on the part of the paddle it hits. the first part is easy enough, but the second, well, am I imagining things, and if not how would you best get that effect?


You can calculate the distance from the center of the paddle to where the ball hits and use that as a skew factor when calculating the reflection angle. Closer to the edge of the paddle would result in more velocity in that direction.

Share this post


Link to post
Share on other sites
In windows this function should hide the cursor:
ShowCursor( FALSE );

Quote:

This function displays or hides the cursor.

int ShowCursor(
BOOL bShow
);

Parameters

bShow
[in] Boolean that specifies whether the internal display counter is to be incremented or decremented. If bShow is TRUE, the display count is incremented by one. If bShow is FALSE, the display count is decremented by one.

Return Values

The return value specifies the new display counter.

Remarks

This function sets an internal display counter that determines whether the cursor should be displayed. The cursor is displayed only if the display count is greater than or equal to 0. If a mouse is installed, the initial display count is 0. If no mouse is installed, the display count is -1.

Share this post


Link to post
Share on other sites
Well I haven't looked at your code yet, but I had the same Message Box problem. All you have to do is output text to the screen on a time based blit. Something like....

var t = 1000;

int ShowText() {
while(t>0) {
//Output text...
--t;
}
return;
}

Share this post


Link to post
Share on other sites
Quote:
Original post by kelcharge
Well I haven't looked at your code yet, but I had the same Message Box problem. All you have to do is output text to the screen on a time based blit. Something like....

var t = 1000;

int ShowText() {
while(t>0) {
//Output text...
--t;
}
return;
}


what do use to output text to a Direct draw surface, cout?

Share this post


Link to post
Share on other sites
No, you have to use a font engine. What DX are you using?

** edit **
Oh, you said direct draw...

Ok in that case you need to create a font engine from scratch. This is actually really easy to do. The normal way to do this is create a bitmap that contains the images of the characters in some range (be sure to put them in ascii order!) of a fixed width/height font. Then just load that in to an array and use some subtraction logic in your display function to change a character from a given string to the index into that array.

I'm sure there is a good tutorial around here on the subject.

Share this post


Link to post
Share on other sites
Quote:
Original post by CyberFox
No, you have to use a font engine. What DX are you using?


Direct draw 7, from the Dx 9.0 SDK,

Share this post


Link to post
Share on other sites
I forgot, there is another way. You can integrate directdraw and windows GDI, there is a magic function for this that I will see if I can track down.

otherwise for creating a font blitter here are some resources:
Table of ASCII characters, you usually go from ' ' to '~'
A font template creating program, just ran across this so I can't tell you how well it works.

Wow, no finds on tutorials telling how to integrate directdraw and gdi. You'll have to wait tell I get home for that.

** edit **
Yep, took to long to post. Could the above poster explain how you go about getting the GDI handle from direct draw?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!