This one is a complete remake of the last.
New view, Win and Lose screen, and the ball reflects.
Uncompressed:
_beginning:
global player1score#
global player2score#
hide mouse
sync on
sync rate 40
make object box 1,1,1,3
color object 1,rgb(255,0,0)
make object box 2,1,1,3
color object 2,rgb(0,255,0)
make object sphere 3,1
color object 3,rgb(0,0,50)
make object box 4,10,0.1,10
position object 4,0,-0.55,0
balla#=90
do
if ballx#>6
player2score#=player2score#+1
ballx#=0
ballz#=0
balla#=270
player1pos#=Player1pos#-player1pos#
player2pos#=player2pos#-player2pos#
endif
if ballx#<-6
player1score#=player1score#+1
ballx#=0
ballz#=0
balla#=90
player1pos#=Player1pos#-player1pos#
player2pos#=player2pos#-player2pos#
endif
set cursor 270,20
print "Your Score:"
set cursor 320, 50
print "-"
set cursor 270,80
print "Enemy's score:"
set cursor 390,80
print player2score#
set cursor 370,20
print player1score#
ballx#=newxvalue(ballx#,balla#,0.3)
ballz#=newzvalue(ballz#,balla#,0.3)
if ballx#>4 and ballx#<4.5
balla# = balla# + rnd(20) - 10
endif
If rightkey()=1 and player1pos#<3.5
player1pos#=player1pos#+0.4
endif
If leftkey()=1 and player1pos#>-3.5
player1pos#=player1pos#-0.4
endif
if rightkey()=1 and ballx#>4 and ballx#<4.5
balla#=balla#+8
endif
if leftkey()=1 and ballx#>4 and ballx#<4.5
balla#=balla#-8
endif
if ballz# > player2pos#
player2pos# = player2pos# + 0.03
endif
if ballz# < player2pos#
player2pos# = player2pos# - 0.03
endif
if ballx#>4 and ballx#<4.5 and ABS(player1pos#-ballz#)<1.5
balla#=360-balla#
endif
if ballx#<-4 and ballx#>-4.5 and ABS(player2pos#-ballz#)<1.5
balla#=360-balla#
endif
if ballz#>4 or ballz#<-4
balla#=180-balla#
endif
balla#=wrapvalue(balla#)
position object 1,5,0,player1pos#
position object 2,-5,0,player2pos#
position object 3,ballx#,0,ballz#
yrotate object 3,balla#
position camera 10,10,0
point camera 0,0,0
checkwin()
sync
loop
`***********************
`**Check Win Function***
`***********************
function checkwin()
if player1score# = 20 and player1score# > player2score#
showwin()
endif
if player2score# = 20 and player2score# > player1score#
showlose()
endif
endfunction
`***********************
`*****Win Function******
`***********************
function showwin()
delete object 1
delete object 2
delete object 3
delete object 4
sync
set text size 20
print "Congratulations! You win!"
print ""
print "Final score: "+str$(player1score#)+" to "+str$(player2score#)
print "Press any key to continue..."
sync
wait key
player1score# = 0
player2score# = 0
goto _beginning
endfunction
`***********************
`****Lose Function******
`***********************
function showlose()
delete object 1
delete object 2
delete object 3
delete object 4
sync
set text size 20
print "Game over! You lose!"
print ""
print "Final score: "+str$(player2score#)+" to "+str$(player1score#)
print "Press any key to continue..."
sync
wait key
player1score# = 0
player2score# = 0
goto _beginning
endfunction
Compressed:
_beginning:
global player1score# : global player2score# : hide mouse : sync on : sync rate 40
make object box 1,1,1,3 : color object 1,rgb(255,0,0) : make object box 2,1,1,3 : color object 2,rgb(0,255,0) : make object sphere 3,1 : color object 3,rgb(0,0,50) : make object box 4,10,0.1,10 : position object 4,0,-0.55,0
balla#=90
do : if ballx#>6 : player2score#=player2score#+1 : ballx#=0 : ballz#=0 : balla#=270 : player1pos#=Player1pos#-player1pos# : player2pos#=player2pos#-player2pos# : endif :if ballx#<-6 : player1score#=player1score#+1 : ballx#=0 : ballz#=0 : balla#=90 : player1pos#=Player1pos#-player1pos# : player2pos#=player2pos#-player2pos# : endif
set cursor 270,20:print "Your Score:":set cursor 320, 50:print "-":set cursor 270,80:print "Enemy's score:":set cursor 390,80:print player2score#:set cursor 370,20:print player1score#:ballx#=newxvalue(ballx#,balla#,0.3):ballz#=newzvalue(ballz#,balla#,0.3):if ballx#>4 and ballx#<4.5 :balla# = balla# + 10:endif
If rightkey()=1 and player1pos#<3.5 :player1pos#=player1pos#+0.4:endif:If leftkey()=1 and player1pos#>-3.5 :player1pos#=player1pos#-0.4:endif:if rightkey()=1 and ballx#>4 and ballx#<4.5 :balla#=balla#+8:endif:if leftkey()=1 and ballx#>4 and ballx#<4.5 :balla#=balla#-8:endif:if ballz# > player2pos#:player2pos# = player2pos# + 0.03:endif:if ballz# < player2pos#:player2pos# = player2pos# - 0.03:endif
if ballx#>4 and ballx#<4.5 and ABS(player1pos#-ballz#)<1.5:balla#=360-balla#:endif:if ballx#<-4 and ballx#>-4.5 and ABS(player2pos#-ballz#)<1.5:balla#=360-balla#:endif:if ballz#>4 or ballz#<-4:balla#=180-balla#:endif
balla#=wrapvalue(balla#):position object 1,5,0,player1pos#:position object 2,-5,0,player2pos#:position object 3,ballx#,0,ballz#:yrotate object 3,balla#:position camera 10,10,0:point camera 0,0,0:checkwin():sync:loop
function checkwin():if player1score# = 20 and player1score# > player2score#:showwin():endif:if player2score# = 20 and player2score# > player1score#:showlose():endif:endfunction
function showwin():delete object 1:delete object 2:delete object 3:delete object 4:sync:set text size 20:print "Congratulations! You win!":print "":print "Final score: "+str$(player1score#)+" to "+str$(player2score#):print "Press any key to continue...":sync:wait key:player1score# = 0:player2score# = 0:goto _beginning:endfunction
function showlose():delete object 1:delete object 2:delete object 3:delete object 4:sync:set text size 20:print "Game over! You lose!":print "":print "Final score: "+str$(player2score#)+" to "+str$(player1score#):print "Press any key to continue...":sync:wait key:player1score# = 0:player2score# = 0:goto _beginning:endfunction
(Yea, i used goto, sue me o.o)