gosub is global.
Rem Project: Pong
Rem Created: 4/29/2008 2:48:11 PM
Rem ***** Main Source File *****
GoSub _Setup
GoSub _Graphics
xspeed = 1.5
yspeed = 1.5
xborder = 725
yborder = 520
Do
gosub _Paddle1
gosub _Ball
Loop
End
_Graphics:
Load Image "Paddle10.jpg",1
Sprite 1,99,275,1
Set Sprite Priority 1,4
Load Image "Paddle20.jpg",2
Sprite 2,701,275,2
Set Sprite Priority 2,3
Load Image "Ball0.bmp",3
Sprite 3,395,280,3
Set Sprite Priority 3,2
Load Image "Background0.bmp",4
Sprite 4,0,0,4
Set Sprite Priority 4,1
Return
_Setup:
Set Display mode 800,600,16
set text font "arial",0
set text size 16
cls
print "I"
print "I"
get image 11,0,0,16,32,1
save Image "Paddle10.jpg",11
get image 12,0,0,16,32,1
save Image "Paddle20.jpg",12
cls
print "@"
get image 13,0,0,16,16,1
save Image "Ball0.bmp",13
cls
print "#"
get image 14,0,0,16,16,1
save Image "Background0.bmp",14
Return
_Paddle1:
Rem Paddle1
If Upkey()=1 Then Move Sprite 1,2
If Downkey()=1 Then Move Sprite 1,-2
If Sprite Y(1)<60 Then Move Sprite 1,-3
If Sprite Y(1)>480 Then Move Sprite 1,3
return
Rem Paddle2
_Ball:
Rem Ball
` sprx = Sprite x(3)
` spry = Sprite y(3)
Inc sprx, xspeed
Inc spry, yspeed
If sprx <= 60 Then xspeed = abs(xspeed)
If spry <= 58 Then yspeed = abs(yspeed)
If sprx >= xborder Then xspeed = -abs(xspeed)
If spry >= yborder Then yspeed = -abs(yspeed)
If Sprite Collision (3,1) Then xspeed = abs(xspeed)
If Sprite Collision (3,2) Then xspeed = -abs(xspeed)
Sprite 3,sprx,spry,3
return