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
rem set display mode
set display mode 640,480,32
hide mouse
rem turn manual sync on and set sync rate to 30
sync on
sync rate 100
rem load media for game
load image "media/bat1.bmp",1
load image "media/bat2.bmp",2
load image "media/ball.bmp",3
rem setup variables
p1pos# = 200
p2pos# = 200
ball_x = 320
ball_y = 240
ball_speed = 5
ballx_dir = 0
bally_dir = 0
p1win = 0
p2win = 0
p1score# = 0
p2score# = 0
reset = 0
deuce = 0
p1adv = 0
p2adv = 0
rem random number
random_direction_x = RND(1)
random_direction_y = RND(1)
ballx_dir = random_direction_x
bally_dir = random_direction_y
reset_variables:
p1pos# = 200
p2pos# = 200
ball_x = 320
ball_y = 240
ball_speed = 7
ballx_dir = 0
bally_dir = 0
p1win = 0
p2win = 0
p1score# = 0
p2score# = 0
reset = 0
set cursor 280,50:print p1points$
set cursor 320,50:print "-"
set cursor 350,50:print p2points$
rem main loop
do
cls
rem position bats
Sprite 1,40,p1pos#,1
Sprite 2,600,p2pos#,2
rem position ball
sprite 3,ball_x,ball_y,3
rem move bats
if upkey() = 1 and p1pos# > 20 then p1pos# = p1pos# - 10
if downkey() = 1 and p1pos# < 330 then p1pos# = p1pos# + 10
if keystate(72) = 1 and p2pos# > 20 then p2pos# = p2pos# -10
if keystate(80) = 1 and p2pos# < 330 then p2pos# = p2pos# + 10
rem ball directions
If ballx_dir = 0 then DEC ball_x, ball_speed
If ballx_dir = 1 then INC ball_x, ball_speed
If bally_dir = 0 then DEC ball_y, ball_speed
If bally_dir = 1 then INC ball_y, ball_speed
IF ball_y < 1 then bally_dir = 1
IF ball_y > 475 then bally_dir = 0
rem collision
for check_collision = 1 to 2
If sprite hit(check_collision, 3) = 1
if check_collision = 1 then ballx_dir = 1
if check_collision = 2 then ballx_dir = 0
endif
next check_collision
rem ball leaves screen
if ball_x < 35 then new_ball = 1 : p2score# = p2score# + 1
if ball_x > 605 then new_ball = 1 : p1score# = p1score# + 1
rem creates new ball
if new_ball = 1
SLEEP 1000
ball_x = 320
ball_y = 240
ballx_dir = RND(1)
bally_dir = RND(1)
new_ball = 0
endif
rem scoring
if p1score# = 4 then p1win = 1
if p2score# = 4 then p2win = 1
if p1score# = 0 then p1points$ = "Love"
if p1score# = 1 then p1points$ = "15"
if p1score# = 2 then p1points$ = "30"
if p1score# = 3 and p2score# < 3 then p1points$ = "40"
if p2score# =0 then p2points$ = "Love"
if p2score# =1 then p2points$ = "15"
if p2score# =2 then p2points$ = "30"
if p2score# =3 and p1score# < 3 then p2points$ = "40"
if p1score# = 3 and p2score# = 3
p1points$ = "Deuce"
p2points$ = "Deuce"
p1adv = 0
p2adv = 0
p1score# = 10
p2score# = 10
endif
if p1win = 1
ball_speed = 0 : delete sprite 3
set cursor 300,240 : print "Player 1 Wins!"
set cursor 285,260 : print "Press Space to Continue"
if spacekey() = 1 then reset = 1
endif
if p2win = 1
ball_speed = 0 : delete sprite 3
set cursor 300,240 : print "Player 2 Wins!"
set cursor 285,260 : print "Press Space to Continue"
if spacekey() = 1 then reset = 1
endif
if reset = 1 then gosub reset_variables
set cursor 280,50:print p1points$
set cursor 320,50:print "-"
set cursor 350,50:print p2points$
sync
loop
Intel Celron 2.6ghz, 256 MB Ram, 80gb HD,D DVD Rom, CD Rewriter,17" Flat pannel Monitior and DB Pro