TGC Codebase Backup



gravityball by Rasdini

15th Feb 2004 21:38
Summary

3-D breakout with movement in all 3 plains



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    cls
print "Use the arrow keys or joystick to move around."
print "Use the shift key or fire 1 on joystick to close in."
print "Use the Control key or fire 2 on joystick to move out."
print "Good. Luck."
print "press enter to begin"
input imp


sync on:hide mouse
beginning:
for x=1 to 60:if object exist(x)=1 then delete object x
next x
if light exist(1)=1 then delete light 1
if light exist(2)=1 then delete light 2
backdrop off
cls
Print "New Game":sleep 2000
backdrop on
cx=160:cy=150:cz=-750:px=200:py=0:pz=-375:balls=5
blue=rgb(0,0,255):green=rgb(0,255,0):red=rgb(255,0,0):white=rgb(255,255,255)
bx#=0:by#=0:bz#=0:dx#=0:dy#=0:dz#=0:dz1#=0
make object box 10,10,400,800
color object 10,blue
color backdrop rgb(0,0,0)
position object 10,0,0,0
make object box 11,400,10,800
color object 11,blue
position object 11,200,-200,0
make object box 12,10,400,800
color object 12,blue
position object 12,400,0,0
make object box 13,400,10,800
color object 13,blue
position object 13,200,200,0
make object box 14,400,400,10
color object 14,rgb(0,0,255)
position object 14,200,0,400
make object sphere 1,10
color object 1,green
make object box 2,80,80,4
color object 2,white

set ambient light 10
make light 1
set light range 1,1000
make light 2
set spot light 2,5,20
set light range 2,5000

gosub serve
ghost object on 2
gosub setblocks

mainloop:
if score=200 then balls=balls+1:score=score+20
if score=400 then balls=balls+1:score=score+20
if score=500 then balls=balls+1:score=score+20
if score=700 then balls=balls+1:score=score+20
if score=800 then balls=balls+1:score=score+20
if score=1000 then balls=balls+10:score=score+20
set point light 1,bx#,by#,bz#+12
point light 1,bx#,by#,bz+20
position light 2,px,py,pz+5
point light 2,px,py,pz+20
position camera px,py,pz-200
point camera px,py,pz
position object 1,int(bx#),int(by#),int(bz#)
position object 2,px,py,pz
t1=object collision(1,0)
if t1=10 or t1=12 then dx#=dx#*-1:bx#=bx#+dx#*2
if t1=11 or t1=13 then dy#=dy#*-1:by#=by#+dy#*2
if t1=14 or t1=2 then dz#=dz#*-1:bz#=bz#+dz#*2
if t1>19 then delete object t1:score=score+20:blk=blk-1:dz#=dz#*-1

bx#=bx#+dx#:by#=by#+dy#:bz#=bz#+dz#
if bz#<-385
   balls=balls-1
   if balls<1 then goto beginning
   gosub serve
endif
if blk=0 then gosub setblocks
if upkey()=1 or joystick up()=1
   if py<150 then py=py+1
   if dy#>0 and t1=2 then dy#=dy#+.25
   if dy#>.75 then dy=.75
   if dy#<0 and t1=2 then dy#=dy#-.25
   if dy#<-.75 then dy=-.75
endif
if downkey()=1 or joystick down()=1
   if py>-150 then py=py-1
   if dy#<0 and t1=2 then dy#=dy#-.25
   if dy#<-.75 then dy=-.75
   if dy#>0 and t1=2 then dy#=dy#+.25
   if dy#>.75 then dy#=.75
endif
if leftkey()=1 or joystick left()=1
   if px>50 then px=px-1
   if dx#<0 and t1=2 then dx#=dx#-.25
   if dx#<-.75 then dx#=-.75
   if dx#>0 and t1=2 then dx#=dx#+.25
   if dx#>.75 then dx#=.75
endif
if rightkey()=1 or joystick right()=1
   if px<350 then px=px+1
   if dx#>0 and t1=2 then dx#=dx#+.25
   if dx#>.75 then dx#=.75
   if dx#<0 and t1=2 then dx#=dx#-.25
   if dx#<-.75 then dx#=-.75
endif
if shiftkey()=1 or joystick fire a()=1
   if pz<150 then pz=pz+1
endif
if controlkey()=1 or joystick fire b()=1
   if pz>-375 then pz=pz-1
endif
set cursor 0,0
print "SCORE-->";Score;"     BALLS-->";balls;"   ";pz
set cursor (screen width()/2)-25,0:Print "3-D BREAKOUT     Written by: Richard Sardini"

sync
goto mainloop

serve:
   bx#=150+rnd(150):dx#=.25
   by#=120-rnd(300):dy#=.25:by#=by#*-1
   bz#=rnd(50)-50:dz#=-.25:bz#=bz#*-1
   p=rnd(2):if p=1 then dx#=dx#*-1
   p=rnd(2):if p=1 then dy#=dy#*-1
return

setblocks:
for x=20 to 57
if object exist(x)=1 then delete object x
next x
z=200:x1=25
for x=20 to 27
make object box x,50,400,4
color object x,rgb(rnd(255),rnd(255),rnd(255))
position object x,x1,0,z
x1=x1+50
next x
z=z+30:x1=25
for x=30 to 37
make object box x,50,400,4
color object x,rgb(rnd(255),rnd(255),rnd(255))
position object x,x1,0,z
x1=x1+50
next x
z=z+30:x1=25
for x=40 to 47
make object box x,50,400,4
color object x,rgb(rnd(255),rnd(255),rnd(255))
position object x,x1,0,z
x1=x1+50
next x
z=z+30:x1=25
for x=50 to 57
make object box x,50,400,4
color object x,rgb(rnd(255),rnd(255),rnd(255))
position object x,x1,0,z
x1=x1+50
next x
blk=32
return