I've decided to define all my variables at the beginning of my program.
So the stupidist question I can ask right now is.... How do you define a boolean variable.
Edit: Nevermind that. Here's the most recent code. The detection of hits still doesn't appear to work.
rem hide the mouse and set sync
hide mouse:sync rate 40
hide light 0
set ambient light 10
make light 1
position light 1,20,10,10
sync on
autocam off
position camera 0,10,-10:point camera 0,0,0
`Boolean Variables
dim boolean (alreadymade)
dim boolean (breakoutlvl)
dim boolean (player1hit)
dim boolean (player2hit)
dim boolean (powerupactive)
dim boolean (bosslvl)
`Float Variables
dim float (ball2a#)
dim float (ball2x#)
dim float (ball2y#)
dim float (ball2z#)
dim float (balla#)
dim float (ballx#)
dim float (ballz#)
dim float (bossspeed#)
dim float (player1pos#)
dim float (player2movespeed#)
dim float (player2pos#)
`Integer Variables
dim int (player1score)
dim int (player2score)
dim int (powerup1)
dim int (powerx)
level#=1
player2movespeed#=.5
powerx=0
`um, randomize... the timer.... i thnk...
randomize timer()
rem MAKE THE PADDLES, BALL AND FLOOR
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,30,30:color object 3,rgb(0,0,50)
set object specular 3,rgb(200,50,50)
make object box 4,15,0.1,10:position object 4,0,-0.55,0
make object box 5,15,4,2: position object 5,0,0,6
make object box 6,15,2,2: position object 6,0,0,-6
rem SET THE BALL ANGLE
balla#=rnd(45)+45
goto menu1
menu1:
cls
show mouse
`if this button is pressed, go to the main game loop!
if button3(320,240,"Start Game!") > 0
goto mainloop
endif
`if this button is pressed, exit the program!
if button3(320,280,"Exit") >0
end
endif
sync
goto menu1
rem START THE MAIN LOOP
`tag for main loop
mainloop:
do
`set collision for the ball
set object collision on 3
set object collision to spheres 3
gosub movement
gosub scoring
gosub bouncing
gosub positioning
`check to see if boss lvl
for x=1 to 4
if level#=5*x
bosslvl=1
endif
next x
`check to see if breakout lvl
for x=1 to 10
if level#=2*x
gosub breakout
endif
next x
rem MAKE SURE balla# IS LESS THAN 360 AND MORE THAN 0
balla#=wrapvalue(balla#)
if breakoutlvl=1 and powerup1=1
scale object 1, 100, 100, 200
text 0,0, "Long Paddle"
make object box 9999, powerx, 1, 1
powerx=powerx-1
delete object 9999
powerupactive=1
if powerx=0
powerup1=0
powerx=100
endif
endif
if breakoutlvl=1 and powerup1=3
if object exist(9998)=0
make object sphere 9998,1,30,30
set object specular 9998, rgb(rnd(255),rnd(255), rnd(255))
endif
gosub extraballproperties
text 0,0, "Extra Ball"
make object box 9999, powerx,1,1
powerx=powerx-1
delete object 9999
powerupactive=1
if powerx=0
powerup1=0
powerx=100
endif
endif
sync
loop
levelup:
boss_speed#=player2movespeed#*1.5
level#=level#+1
inc player2movespeed#, .2
for x=1 to 6
color object x, rgb(rnd(255), rnd(255), rnd(255))
next x
ink 0,rgb(rnd(255), rnd(255), rnd(255))
player1score=0
player2score=0
return
movement:
rem PLAYER 1 PADDLE MOVEMENT
IF upkey()=1 and player1pos#<3.5 then player1pos#=player1pos#+0.5
IF downkey()=1 and player1pos#>-3.5 then player1pos#=player1pos#-0.5
if upkey()=1 and ballx#>4 and ballx#<4.5 then balla#=balla#+8
if downkey()=1 and ballx#>4 and ballx#<4.5 then balla#=balla#-8
rem ai to find ball
if bosslvl=0
if player2pos#>object position z(3)+3 and object position z(2)>-3.5
player2pos#=player2pos#-player2movespeed#
position object 2,-5,0,player2pos#
endif
if player2pos#<object position z(3)-3 and object position z(2)<3.5
player2pos#=player2pos#+player2movespeed#
position object 2,-5,0,player2pos#
endif
endif
if bosslvl=1
if player2pos#>object position z(3)+3 and object position z(2)>-2.25
player2pos#=player2pos#-player2movespeed#
position object 2,-5,0,player2pos#
endif
if player2pos#<object position z(3)-3 and object position z(2)<2.25
player2pos#=player2pos#+player2movespeed#
position object 2, -5, 0, player2pos#
endif
endif
rem BALL MOVEMENT
ballx#=newxvalue(ballx#,balla#,0.3):ballz#=newzvalue(ballz#,balla#,0.3)
return
scoring:
rem SCORING
if ballx#>9 then player2score=player2score+1:ballx#=0:ballz#=0:balla#=rnd(90)+45
if ballx#<-9 then player1score=player1score+1:ballx#=0:ballz#=0:balla#=-rnd(90)-45
set cursor 300,50:print player2score
set cursor 320,50:print "-"
set cursor 340,50:print player1score
if player1score>=10 and player1score-2>=player2score
gosub levelup
endif
return
bouncing:
rem BOUNCING
if ballx#>6.5 and ballx#<7 and ABS(player1pos#-ballz#)<1.5
balla#=360-balla#
player1hit=1: player2hit=0
endif
if bosslvl=0
if ballx#<-6.5 and ballx#>-7 and ABS(player2pos#-ballz#)<1.5 then balla#=360-balla#
player2movespeed#=.5+((.2)*(level#-1))
player2hit=1: player1hit=0
endif
if bosslvl=1
if ballx#<-6.5 and ballx#>-7 and abs(player2pos#-ballz#)<2.25 then balla#=360-balla#
scale object 2,100,100,150
player2hit=1: player1hit=0
endif
if ballz#>4 or ballz#<-4 then balla#=180-balla#
return
positioning:
rem POSITION OBJECTS
position object 1,7.5,0,player1pos#:position object 2,-7.5,0,player2pos#
position object 3,ballx#,0,ballz#:yrotate object 3,balla#
return
breakout:
for boxnum=7 to level#+12
if object exist(boxnum)=0 and alreadymade=0
`make block
make object box boxnum,1,1,1.5
position object boxnum,rnd(6)-3,0,rnd(7)-3.5
`set collision for block
set object collision on boxnum
set object collision to boxes boxnum
alreadymade=1
endif
if object exist(boxnum)=1
if object collision(3,boxnum)=1 and player1hit=1
player1score=player1score+1
delete object boxnum
if powerupactive=0
powerup1=rnd(5)
endif
balla#=360-balla#
endif
endif
if object exist(boxnum)=1
if object collision(3,boxnum)=1 and player2hit=1
player2score=player2score+1
delete object boxnum
balla#=360-balla#
endif
endif
next boxnum
breakoutlvl=1
return
extraballproperties:
if object exist(9998)=1
position object 9998, ball2x#, ball2y#, ball2z#
ball2x#=newxvalue(ball2x#,ball2a#, .3)
ball2z#=newxvalue(ball2z#,ball2a#, .3)
if bosslvl=1
if ball2x#<-6.5 and ball2x#>-7 and abs(player2pos#-ball2z#)<2.25
ball2a#=360-ball2a#
player2hit=1
endif
endif
if bosslvl=0
if ball2x#<-6.5 and ball2x#>-7 and abs(player2pos#-ball2z#)<1.5
ball2a#=360-ball2a#
player2hit=1
endif
endif
if ball2x#>6.5 and ball2x<7 and abs(player1pos-ball2z#)<1.5
ball2a#=360-ball2a#
player1hit=1
endif
if ball2z#>4 or ball2z#<-4 then ball2a#=180-ball2a#
endif
`makes button 1 (in big grey box)
function button1(x,y,xsize,ysize,content$)
colortheme = rgb(200,200,200)
pressed = 0
if mousex() > x and mousex() < x + xsize
if mousey() > y and mousey() < y + ysize
if mouseclick() > 0 then pressed = mouseclick()
endif
endif
if pressed = 1
ink rgb(rgbr(colortheme)/2,rgbg(colortheme)/2,rgbb(colortheme)/2),0
box x,y,x+xsize-1,y+ysize-1
ink rgb(255,255,255),0
box x+1,y+1,x+xsize,y+ysize
else
ink rgb(rgbr(colortheme)/2,rgbg(colortheme)/2,rgbb(colortheme)/2),0
box x+1,y+1,x+xsize,y+ysize
ink rgb(255,255,255),0
box x,y,x+xsize-1,y+ysize-1
endif
ink colortheme,0
box x+1,y+1,x+xsize-1,y+ysize-1
ink 0,0
center text x+(xsize/2),y + (ysize/2) - (text height(content$)/2),content$
endfunction pressed
` to make a button like button 2 (changes color when moused over)
function button2(x,y,content$)
colortheme = rgb(255,0,0)
pressed = 0
tx = text width(content$) / 2
ty = text height(content$) / 2
if mousex() > x - tx and mousex() < x + tx
if mousey() > y - ty and mousey() < y + ty
pressed = 1
endif
endif
if pressed = 1 then ink colortheme,0 else ink rgb(255,255,255),0
center text x,y - ty, content$
if pressed > 0
pressed = mouseclick()
endif
endfunction pressed
`makes a button like button 3 (dissapears when moused over)
function button3(x,y,content$)
colortheme = rgb(255,255,0)
if rgbr(colortheme) > 0
if redval = 0 then redi = 1
if redval = rgbr(colortheme) then redi = -1
inc redval,redi
endif
if rgbg(colortheme) > 0
if greenval = 0 then greeni = 1
if greenval = rgbg(colortheme) then greeni = -1
inc greenval,greeni
endif
if rgbb(colortheme) > 0
if blueval = 0 then bluei = 1
if blueval = rgbb(colortheme) then bluei = -1
inc blueval,bluei
endif
pressed = 0
tx = text width(content$) / 2
ty = text height(content$) / 2
if mousex() > x - tx and mousex() < x + tx
if mousey() > y - ty and mousey() < y + ty
pressed = 1
endif
endif
if pressed = 1 then ink rgb(redval,greenval,blueval),0 else ink rgb(255,255,255),0
center text x,y - ty,content$
if pressed > 0
pressed = mouseclick()
endif
endfunction pressed
"I will work harder... if you ask me enough times."