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 / Pong game scoring Problem

Author
Message
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 5th Mar 2004 22:46
I just wondered how you get it to return to the start after it has displayed player 1 wins or player 2 wins. I have enclosed my source code below so you can see.



Thanks for your help,

Michael


Intel Celron 2.6ghz, 256 MB Ram, 80gb HD,D DVD Rom, CD Rewriter,17" Flat pannel Monitior and DB Pro
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 5th Mar 2004 23:07
GOTO is considerd bad practice, just put the whole code in an endless loop and make the main game loop end when either p2win or p1win equal 1, eg.......

do
game start code

repeat
main loop
until (p2win=1) or (p1win=1)

loop

that should work fine, your original code should work though so I am not sure what the issue is, what happens at the end of a game?, wait key might fall through if the player still has a key depressed when the game ends BTW, you might to just stick a wait command in there to pause the game (more "bad" practice ) for a couple of seconds before the restart, cheers.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
BearCDPOLD
20
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 5th Mar 2004 23:14
The reason why your program kept telling us that playerX kept winning was because you needed to set the values p1score#, p2score#, p1win, and p2win to 0. Just a couple other things that might help:
Put a CLS at the start of your loop so we can see the score board thing more clearly. And if you can in the future, avoid using GOTO, instead use GOSUB, in the entire history of the basic language GOTO was always an iffy command. GOSUB does basically the same thing, just cleaner with more options.
BTW, I only posted the section of the code that handled scoring. I like the way you handled the ball physics


Crazy Donut Productions
Current Project: KillZone
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 7th Mar 2004 10:59 Edited at: 7th Mar 2004 11:00
Thanks for your help. I've got the scoring to work now and ive swapped it to tennis scoring. (Love,15,30,40) I just wonderd when both players get to 40 how doyou do the advantage scoring. The rules in tennis are if both players get 40 then its a deuce. It then goes to advantage scoring. When 1 player scores they get an advantage. They need to score again to win. If the other player scores first then it goes back to deuce until someone wins. If anyone has any sugestions on how to code this they wouldbe greatly apreciated.

Cheers,

Michael



Intel Celron 2.6ghz, 256 MB Ram, 80gb HD,D DVD Rom, CD Rewriter,17" Flat pannel Monitior and DB Pro

Login to post a reply

Server time is: 2024-09-22 00:37:00
Your offset time is: 2024-09-22 00:37:00