Rem Project: breakout Rem Created: 14/04/2005 22:57:49 Rem ***** Main Source File ***** set display mode 1024,768,32 sync on sync rate 100 autocam off color backdrop 0 hide light 0 set ambient light 20 make light 1 position light 1,-10,40,20 position camera 0,10,-20 point camera 0,0,0 gosub make_textures make object sphere 1,0.5,20,20 set object specular power 1,60 set object specular 1,rgb(200,200,200) x#=6 z#=6 xspeed#=0.1 zspeed#=0.1 gosub make_bricks gosub make_walls do gosub move_ball gosub move_bricks gosub collision_with_bricks gosub collision_with_walls text 0,0,str$(screen fps()) sync loop make_textures: cls for n=0 to 100 ink rgb(n+155,0,0),0 line 0,n,100,n next n get image 1,0,0,100,100 cls for n=0 to 100 ink rgb(0,n+155,0),0 line 0,n,100,n next n get image 2,0,0,100,100 cls for n=0 to 100 ink rgb(0,0,n+155),0 line 0,n,100,n next n get image 3,0,0,100,100 cls for n=0 to 100 ink rgb(n+155,0,n+155),0 line 0,n,100,n next n get image 4,0,0,100,100 cls for n=0 to 100 ink rgb(n+155,n+85,0),0 line 0,n,100,n next n get image 5,0,0,100,100 cls for n=0 to 100 ink rgb(0,n+155,n+155),0 line 0,n,100,n next n get image 6,0,0,100,100 return make_bricks: make object cube 10,1 hide object 10 brickseed=100 numberofbricks=25 x=-4 z=-4 for brick=brickseed to brickseed+numberofbricks-1 if brick-brickseed<>12 then make object sphere brick,1.6,20,20 else make object sphere brick,2,4,4 glue object to limb brick,10,0 `scale object brick,200,100,200 image=rnd(5)+1 if brick-brickseed<>12 then texture object brick,image else texture object brick,1 set object specular power brick,60 set object specular brick,rgb(200,200,200) position object brick,x,0,z inc x,2 if x>4 then x=-4:inc z,2 next brick return make_walls: make object plain 20,20,20 texture object 20,3 xrotate object 20,-90 ghost object on 20 return move_bricks: if upkey()=1 then move object 10,.1 if downkey()=1 then move object 10,-.1 if leftkey()=1 then turn object left 10,1 if rightkey()=1 then turn object right 10,1 return move_ball: inc x#,xspeed# inc z#,zspeed# position object 1,x#,0,z# return collision_with_bricks: for brick=brickseed to brickseed+numberofbricks if object exist(brick)=1 distleft#=intersect object (brick,object position x(1),object position y(1),object position z(1),object position x(1)+2,object position y(1),object position z(1)) if distleft#=0 then distleft#=1000 if distleft#<0.5 then xspeed#=xspeed#*-1:delete object brick:exit distright#=intersect object (brick,object position x(1),object position y(1),object position z(1),object position x(1)-2,object position y(1),object position z(1)) if distright#=0 then distright#=1000 if distright#<0.5 then xspeed#=xspeed#*-1:delete object brick:exit distinfront#=intersect object (brick,object position x(1),object position y(1),object position z(1),object position x(1),object position y(1),object position z(1)+2) if distinfront#=0 then distinfront#=1000 if distinfront#<0.5 then zspeed#=zspeed#*-1:delete object brick:exit distbehind#=intersect object (brick,object position x(1),object position y(1),object position z(1),object position x(1),object position y(1),object position z(1)-2) if distbehind#=0 then distbehind#=1000 if distbehind#<0.5 then zspeed#=zspeed#*-1:delete object brick:exit endif next brick return collision_with_walls: if x#>10 then x#=10:xspeed#=xspeed#*-1 if x#<-10 then x#=-10:xspeed#=xspeed#*-1 if z#>10 then z#=10:zspeed#=zspeed#*-1 if z#<-10 then z#=-10:zspeed#=zspeed#*-1 return