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 / Advantage scoring for a 2d tennis game

Author
Message
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 11th Mar 2004 21:19 Edited at: 11th Mar 2004 21:21
Hey! I just wondered if anyone knew how to code the advantage scoring for a tennis game. I've enclosed the source code for my game. I've got all the menu and computer AI working its just the advantage scoring left to do.

Any help would be 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
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 11th Mar 2004 23:47
if ball_x<1 then ai_score=ai_score(or p2_score)+1
if ball_x=>570 then player1_score=player1_score+1
text 0,0,str$(player_score1)
text 470,0,str$(ai_score(or player2_score))

CURRENT PROJECT: RETRO PAC-MAN
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 12th Mar 2004 20:38
Thats how ive done my normal scoring. I need it so that if both playerhave 40 then it goes to deuce. The player has to score twice in a row to win. If p1 scores then p2 then it goes back to deuce until someone wins(or vice versa).

I would apreciate anybodies help on this.

Cheers,

Michael

Intel Celron 2.6ghz, 256 MB Ram, 80gb HD,D DVD Rom, CD Rewriter,17" Flat pannel Monitior and DB Pro
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 12th Mar 2004 21:55
please help him coz hes on my team i've had a go at it but can't do it so please help.

comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 12th Mar 2004 22:35
I don't know if it works




Hope it helps

CURRENT PROJECT: RETRO PAC-MAN
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 12th Mar 2004 22:48
sorry no luck

Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 12th Mar 2004 23:38
ummm.. i'm not sure exactly what your asking but i think what you need to do (to have it to where you know when a player scored twice in a row)is have a variable that stores whether or not the each player was the last one to score then when a player scores you check if that player has scored last turn (or whatever)and if they have then you can do what ever you want to do (i don't know maybe some win animation?) and if they don't score there "turn" then you set the variable to 0 (variable=0)...

I'm probably wrong though...
and you've probably already tried this...
but this IS the newcomers corner after all i have to trie out the obvious stuff also...(and f course i could be wrong)...

You know, when i see an old lady slip and fall on the side walk, my first instinct is to luagh, but then i think, what if i where an ant? and she fell on me, it just doesn't seem so funny anymore.
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 13th Mar 2004 00:23 Edited at: 13th Mar 2004 00:32
This is in DBPro:

*edit*

source attatched:
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 13th Mar 2004 00:27
Quote: "This is in DBPro: "

and the point of that post is...?

You know, when i see an old lady slip and fall on the side walk, my first instinct is to luagh, but then i think, what if i where an ant? and she fell on me, it just doesn't seem so funny anymore.
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 13th Mar 2004 00:31
Quote: "Quote: "This is in DBPro: "
and the point of that post is...?"


click the source button
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 13th Mar 2004 00:44 Edited at: 13th Mar 2004 00:44
I think darkwing Duck is right you can use a variable tu store that.cuz you want if the players or the ai win when they score twice in a row.

do
if ballx=>570 then player_rows=player_rows+1
if player_rows=2 then text screen width()/2,screen height()/2,"P Wins"
if sprite collision(paddleai,ball)>0 then player_rows=0
if ballx<1 then ai_rows=ai_rows+1
if ai_rows=2 then text screen width()/2,screen height()/2,"Com Wins"
if sprite collision(playerpaddle,ball)>0 then ai_rows=0
loop


just substitute the playerpaddle,ball and paddleai by their sprite numbers

hope it helps

CURRENT PROJECT: RETRO PAC-MAN
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 13th Mar 2004 00:46
there is no "source button" (and yes i do know what a source button is )

You know, when i see an old lady slip and fall on the side walk, my first instinct is to luagh, but then i think, what if i where an ant? and she fell on me, it just doesn't seem so funny anymore.
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 13th Mar 2004 00:50
if one player hits 4 points and other player is below 3 then that player wins

else

if both players are >3 and difference is>1
true= player wins
false= deuce

try my source it does what you want.
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 13th Mar 2004 00:51
there is a source button on my 1st post
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 13th Mar 2004 13:38
Cheers! Thanks for all your help.

@ Flashing blade. That's just the sort of code ive been looking for. Do you know how i could implement that into my game. Ive tried to do it but i can't seem to get it to work. 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
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 13th Mar 2004 14:11
1st - score varible shoud be int not float(drop the #)

2nd - arrays would be so much better than p1core p2score etc. Arrays and Types are well worth learning.

3rd - whats this line for:
p1score# = 10
p2score# = 10

4th - If player score>3 AND difference between scores=2 then "Player Wins". If both players scores are>=3 AND both players score same then "DEUCE". If both players are>=3 AND difference between scores=1 then "ADV".

5th - Did I mention Arrays and Types are well worth learning?

6th - If you still get stuck then I'll try to be more specific.

7th - Good luck with your project.

8th - Arrays and Types are your friends.
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 13th Mar 2004 15:01
Cheers I'll try that!

Intel Celron 2.6ghz, 256 MB Ram, 80gb HD,D DVD Rom, CD Rewriter,17" Flat pannel Monitior and DB Pro
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 13th Mar 2004 15:50
Thanks for all your help flashing blade. I've got the advantage scoring working now.

THANKYOU!!!!



Intel Celron 2.6ghz, 256 MB Ram, 80gb HD,D DVD Rom, CD Rewriter,17" Flat pannel Monitior and DB Pro
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 14th Mar 2004 17:33
I've now used a text to speech translator on the computer to do the 15 love and wteva bits. However if it was 15 30 and then it went to 30 30 it would say the score from before (so it would say 15 30) I've tried subtracting 1 from each of the player numbers but then it just messes it up. I want it so that when a player scores it gives you the correct score not the 1 from the go before. This is the code that i am using at the moment.

if p1score = 1 and p2score = 0 then play sound 150
if p1score = 2 and p2score = 0 then play sound 300
if p1score = 3 and p2score = 0 then play sound 400
if p1score = 1 and p2score = 1 then play sound 1515
if p1score = 2 and p2score = 1 then play sound 3015
if p1score = 3 and p2score = 1 then play sound 4015
if p1score = 2 and p2score = 2 then play sound 3030
if p1score = 2 and p2score = 3 then play sound 3040
if p1score = 3 and p2score = 1 then play sound 4015
if p1score = 3 and p2score = 2 then play sound 4030
if p1score = 3 and p2score = 3 then play sound 4040
if p1score = 0 and p2score = 1 then play sound 015
if p1score = 0 and p2score = 2 then play sound 030
if p1score = 0 and p2score = 3 then play sound 040
if p1score = 1 and p2score = 2 then play sound 1530
if p1score = 1 and p2score = 3 then play sound 1540

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
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 14th Mar 2004 19:07
could you post your entire source?
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 14th Mar 2004 19:10 Edited at: 14th Mar 2004 19:11
Yeah sure. Here it is.



The sound numbers may seem random but they stand for things. So if it says 15 15 then the sound number is 1515.

Cheers,

Michael

Ps the sound commentry is only in single player.

Intel Celron 2.6ghz, 256 MB Ram, 80gb HD,D DVD Rom, CD Rewriter,17" Flat pannel Monitior and DB Pro
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 14th Mar 2004 19:47
I think the problem is you updating scores every loop and not just after someone has scored. So at 15-30 then sound 1530 is played every loop from the begining and all you hear is the very begining and not all of it(do you hear a buzzing/grating sound?), then when score is 30-30 then you play sound 3030 evry loop so you only get the first milisecond or so of it - but now sound 1530 is "released" and can finish playing.

Only check scoring if someone has scored - put all your score routine inside the new-ball if-endif

but do this bit every loop:
set cursor 275,50:print p1points$
set cursor 320,50:print "-"
set cursor 355,50:print p2points$
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 14th Mar 2004 20:10
I'll try that. But i don't hear a grating sound i hear the proper sound just the one that should have played the last new ball.

Intel Celron 2.6ghz, 256 MB Ram, 80gb HD,D DVD Rom, CD Rewriter,17" Flat pannel Monitior and DB Pro
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 14th Mar 2004 20:17
FLASHING BLADE YOUR A GENIUS! You've solved both my problems.

I can't thankyou enough,

Cheers,

Michael

Yes I can. I'll putyour name in the credits. Cheers!

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-11-26 07:29:20
Your offset time is: 2024-11-26 07:29:20