Try my pong clone. [UPDATED 10/13/05, 8:37]

Started by
20 comments, last by dudedbz1 18 years, 6 months ago
If you want some free webspace go to 100webspace.com. You get 100mb of space, PHP, CGI and good support.
Advertisement
I keep getting a 404 :(.
Since you've been having troules with your hosting, I decided to let you use some of mine:

dudedbz1's Pong - Rob Loach Mirror

Very well done, I like your use of the message box to say the score. I didn't know that was easily possible using SDL. Any notes about your next project?
Rob Loach [Website] [Projects] [Contact]
Good work! The gameplay gets a little boring after a while, though... Have you considered making the whole game run faster? At the current speed, given that the speed of the paddles is the same as the y-axis speed of the ball is the same, it is really easy to stay under the ball all the time..
thanx for sharing
Great work! I can tell you're gonna do really well with this game development thing!

Couple suggestions for version 2.0:

- Ball rebound direction based on where on the paddle it hits (a la break out)
- Faster gamplay
- Ingame windows instead of regular message boxes

Looks really great though!
Matt Hughson
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
Not bad man!

Well you have your self some hosting now I guess. Keep up the good work.



Thanks. I am working on 2.0 as we speak. It'll be for up to 4 players. Here's a screenshot: .
Now there are two balls(<---- hahaha) to look out for, and one moves faster than the other. The AI is somewhat stupid, but not all the time. I took out the scoring system and FPS regulator because I didnt like how I implemented them. I'm not going to the FPS for a while, cuz for now it doesnt really matter(unless you run it on a monster machine ;)). I HAVE to learn SDL_ttf because I can use it nicely. I'm just working on a class to handle all of it cuz I dont like to do it manually. Then I can make a nice scoring system. I made a pause, but not a menu with it(just toggle pause on/off with p or pause). Later I can make a main menu, too. Since its for four players I should make some kind of box that goes in the corners so the paddles dont hit themselves. And they could act as goals, too. Check back here fo info.

P.S. Thanks for hosting my game, Rob.

Edit: The message box is as easy to put into SDL as in windows.
MessageBox(GetActiveWindow(), // or null           "My text.",           "My title.",           MB_OK);


Edit2: I made all my Images be accessible through a vector of pointers to the variables in main. I did this so I dont pass in like 8 arguments to each function.

//beforevoid DrawGame(P1_Paddle,              P2_Paddle,              ...              ...);//aftervoid DrawGame(vector<Image*>&);


Edit2: Heres main():
int main(int, char**){	if (FUNCTION_FAILED(Init()))        return 1;            Image P1_Paddle;    Image P2_Paddle;        Image P3_Paddle;    Image P4_Paddle;        Image Ball;    Image Ball2;        Image Bg;        Image Pause;        vector<Image*> AllGraphics;        AllGraphics.push_back(&P1_Paddle);    AllGraphics.push_back(&P2_Paddle);    AllGraphics.push_back(&P3_Paddle);    AllGraphics.push_back(&P4_Paddle);        AllGraphics.push_back(&Ball);    AllGraphics.push_back(&Ball2);        AllGraphics.push_back(&Bg);        AllGraphics.push_back(&Pause);        if (FUNCTION_FAILED(InitResources(AllGraphics)))        return 1;            while (UpdateGame(P1_Paddle,                       P2_Paddle,                       P3_Paddle,                      P4_Paddle,                      Ball,                       Ball2,                       Bg))        DrawGame(AllGraphics);        CleanUp();        return 0;}

Now I just need to update the Update() function to also use this:
vector<Image*>&


[Edited by - dudedbz1 on October 13, 2005 7:55:55 PM]
-----------------------------....::::DRAGON BALL Z::::....C<<"+"<<"+"; // Go C++ !!!-----------------------------
i suggest gameplay be alot faster, AI be less predictable. otherwise.... not bad
I will make the gameplay faster, once I do a scoring system. But how can I make the AI less predictable? I'm not good at AI programming. If anyone can help me, please do so.

Heres my current AI part for the bottom paddle:
if (AI)        {        	if (Ball.Gety() > ((BG.GetChar()->h / 4) * 3) && Ball.BallDown)                {                if (Ball.Getx() < (P1_Paddle.Getx() + (P1_Paddle.GetChar()->w / 2) - (Ball.GetChar()->w / 2)))                    P1_Paddle.Setx(P1_Paddle.Getx() - 4);                if (Ball.Getx() > (P1_Paddle.Getx() + (P1_Paddle.GetChar()->w / 2) - (Ball.GetChar()->w / 2)))                    P1_Paddle.Setx(P1_Paddle.Getx() + 4);            }            else            {                if (Ball2.Getx() < (P1_Paddle.Getx() + (P1_Paddle.GetChar()->w / 2) - (Ball2.GetChar()->w / 2)))                    P1_Paddle.Setx(P1_Paddle.Getx() - 4);                if (Ball2.Getx() > (P1_Paddle.Getx() + (P1_Paddle.GetChar()->w / 2) - (Ball2.GetChar()->w / 2)))                    P1_Paddle.Setx(P1_Paddle.Getx() + 4);            }        }        else        {            if (Keys[SDLK_LEFT])                P1_Paddle.Setx(P1_Paddle.Getx() - 4);                            if (Keys[SDLK_RIGHT])                P1_Paddle.Setx(P1_Paddle.Getx() + 4);        }

All the others are like this, except that for the hieght ones they will most likely be y-axis, not x-axis like in this case.
-----------------------------....::::DRAGON BALL Z::::....C<<"+"<<"+"; // Go C++ !!!-----------------------------
One thing I did for my first pong and chess AI's is I made it make a mistake a random percent of the time. Like in terms of pong it could miscalculate where it thinks the ball is going to go. I didnt read your code exactly but what I did was just put in a random number that subtracted or was added to the coords of where the ball was going to go so the opponents paddle is slightly off, just to give it a lil more randomness instead of being perfect. Im sure this is a horrible method but im just tryin to help!
DONT LET THEM DISCRIMINATE! BRING BACK THE BLACK!

This topic is closed to new replies.

Advertisement