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.

Newcomers DBPro Corner / Basic Question

Author
Message
RisTar_sn
19
Years of Service
User Offline
Joined: 15th Jan 2005
Location:
Posted: 17th Mar 2006 20:57 Edited at: 17th Mar 2006 20:59
Okay here is my pong code



And my problems are ... for the first thing i can seems to get the colossion right between the ball and the bat , i thought i have something in my hands but its not working . and the seconed is how to create the seconed bat moves by the computer ?
Thanks Guys
Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 18th Mar 2006 16:40
hi mate

What I am doing for you is I will put your code right and then post it here and walk you through what I did but this will have to wait untilo tonight because I am going out in about 2 mins but I will be back to help you.

BM

Our aim is to keep the loo's clean, your aim can help.
H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 18th Mar 2006 18:20
@Big man, beat you to it :-P!

I went through your code, which, btw is very nice and organized, good job! I put in code for the stuff you had trouble with and tried to comment everything very well so you would understand. I also added a point counter. Here's what I got:



If you have any questions, just post them here. Hope that helped!

-H4ck1d

There are 10 types of people, those who understand binary and those that don't.
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 19th Mar 2006 00:49
Good job with the code H4ck1d, but I couldn't stand not being able to beet the computer. I used your code but made the ball data arrays so that there can be more than one ball. Here is what I made it look like.



I know the original pong only had one ball; o well.

Insanity is just a state of mind
RisTar_sn
19
Years of Service
User Offline
Joined: 15th Jan 2005
Location:
Posted: 19th Mar 2006 19:08
Actually H4ck1d ive already managed to create the hit of the ball in the padle myself after some thinking . But ive tried to run your code and it just not working . BTW im using DBP . Ive tried to copy paste of the computer moving but it didnt work so i have to figure it out myself , BTW here is the code so far . Thanks for the help H4ck1d and thanks to you to Daemon
RisTar_sn
19
Years of Service
User Offline
Joined: 15th Jan 2005
Location:
Posted: 19th Mar 2006 19:13
RisTar_sn
19
Years of Service
User Offline
Joined: 15th Jan 2005
Location:
Posted: 20th Mar 2006 12:03
ive managed to make the other paddle move but i just cant beet the computer ....
Cheack out the almost final code of my pong game , last problem ;; being able to win ;;

H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 20th Mar 2006 22:08
Luckily, that's the easy part. First, pick a score to win at. Say, 10. So, in the main loop, put an if statement:



Then, have a subroutine (or you could use a function, doesn't really matter) for the player winning and the computer winning.

If you want, you can ask if they want to play again. If they do, just reset the points and the ball speed, and return to the main loop. Otherwise, just end the program.

I tried not to give you all the code, I think you should try to figure it out. If you need any more help, though, just ask.

-H4ck1d

There are 10 types of people, those who understand binary and those that don't.
RisTar_sn
19
Years of Service
User Offline
Joined: 15th Jan 2005
Location:
Posted: 21st Mar 2006 09:02
No its not my problem thats easy . my problem is that i cant beet the computer , when im using my code the computer always hit the ball and never miss so being able to win was being able to score for the computer . what i thought is to give the computer paddle a random speed so the speed of the computer paddle will be RND(5)
and then the computer paddle can miss , what do you think H4ck1d ?
BTW thanks for all the help 1!
H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 21st Mar 2006 21:55
Oh, sorry, I read your post wrong...

Frequently, the way to make the computer not as good is for the AI to not respond until the ball/puck is on the computer's half of the game.

So basically, have it check where the ball is. If the ball is on its side of the board, then have it move towards the ball, otherwise it just sits where it is (or maybe return to the middle). Unless you make the paddle return to the middle when the ball is on the other side, you should probably leave the speed at around 5, a little faster than player since it is now a lot "dumber."

I think I got what you were after this time .

-H4ck1d

There are 10 types of people, those who understand binary and those that don't.
Sonic 91 Software
19
Years of Service
User Offline
Joined: 19th Mar 2005
Location: In a Cryptic Crossworld!
Posted: 22nd Mar 2006 10:56
Oh...


SOOOOO many pong games!!!!!!

Everywhere in the forums! I know pong was a defining moment in video game history and I'm a retro gamer and pong is simple to code for newbies but if I see another post containing pong.....






I have no idea how to finish this sentence...

I am a Christian and I know that God loves me. That is what makes my life so great!
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 22nd Mar 2006 14:09
Then please, dont.

roswell
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location: United States
Posted: 23rd Mar 2006 16:13
I can understand your frustration, Sonic. I, myself, am dying to move on to a better project than my own version of Pong, but there are still many things I can do to improve my Pong game. Please don't discourage anyone from posting their code, because I'm learning something new from every version of Pong people are submitting!

'Just one game,' they said, and started to play. That was yesterday.

Dual Athlon 2.0/1GB RAM/GeForce Ti4200-128/WinXP Pro
Sonic 91 Software
19
Years of Service
User Offline
Joined: 19th Mar 2005
Location: In a Cryptic Crossworld!
Posted: 24th Mar 2006 10:43
Fair enough, roswell. someone please call me hypocritical, as i am going to make a pong game. (just to see what the enjoyment is in making pong!)

I am a Christian and I know that God loves me. That is what makes my life so great!

Login to post a reply

Server time is: 2024-09-24 19:23:45
Your offset time is: 2024-09-24 19:23:45