thanks nojbox87 and Sven B.
now, another question.
this time it deals with them menu of another game im making (its summer, im trying to keep busy)
sync on
position mouse 320,270
start:
do
set text font "aril"
set text size 94
load bitmap "title.bmp"
center text 320,60,"Maze Craze"
buttonselected=0
if makebutton(145,355,"Game")>0 then buttonselected=1
if buttonselected=1 then goto game
if makebutton(320,355,"Credits")>0 then buttonselected=2
if buttonselected=2 then goto credits
if makebutton(475,355,"Exit")>0 then buttonselected=3
if buttonselected=3 then goto exit
if makebutton(-100,-100,"hidden")>0 then buttonselected=4
if buttonselected=4 then goto exit
sync
loop
rem Make button functions
function makebutton(x,y,desc$)
buttonpressed=0
ink rgb(255,255,255),0 : box x-26,y-7,x+26,y+7
ink rgb(128,128,128),0 : box x-25,y-6,x+25,y+6
ink rgb(255,255,255),0
myx=mousex() : myy=mousey()
if myx>x-26 and myx<x+26
if myy>y-7 and myy<y+7
buttonpressed=1
endif
endif
if buttonpressed=1 then ink rgb(64,64,64),1
set text size 14 : center text x,y-7,desc$
if mouseclick()=0 then buttonpressed=0
if buttonpressed=2 then ink rgb(64,64,64),1
set text size 14 : center text x,y-7,desc$
if mouseclick()=0 then buttonpressed=0
if buttonpressed=3 then ink rgb(64,64,64),1
set text size 14 : center text x,y-7,desc$
if mouseclick()=0 then buttonpressed=0
endfunction buttonpressed
game:
autocam off : sync rate 60
hide mouse : sync on
rem Make four walls
make object box 1,10,200,1000 : position object 1,-500,100,0 : color object 1,rgb(255,0,155)
make object box 2,10,200,1000 : position object 2, 500,100,0 : color object 2,rgb(255,0,155)
make object box 3,1000,200,10 : position object 3, 0,100,-500 : color object 3,rgb(255,0,155)
make object box 4,1000,200,10 : position object 4, 0,100, 500 : color object 4,rgb(255,0,155)
rem Make a floor and create texture for it
make object box 5,1000,10,1000 : position object 5,0,-5,0 : color object 5,rgb(0,255,0)
create bitmap 1,32,32 : cls rgb(0,155,0) : ink rgb(0,145,0),0 : box 4,4,12,12
get image 1,0,0,32,32 : delete bitmap 1 : texture object 5,1
scale object texture 5,200,200
rem Make a player object (and a non-rotated collision box for it)
make object sphere 11,10
position object 11,497,0,-497
color object 11,rgb(180,0,0)
make object collision box 11,-5,-5,-5,5,5,5,0
disable object zdepth 11
rem Make steps
make object box 13,10,200,100
position object 13,400,100,-445
make object collision box 13,-4,-200,-45,4,200,45,0
make object box 14,10,200,100
position object 14,445,100,-445
make object collision box 14,-4,-200,-45,4,200,45,0
make object box 15,10,200,100
position object 15,445,100,-300
rotate object 15,0,90,0
make object collision box 15,-4,-200,-45,4,200,45,0
rem Make the wall and floor objects into static objects (for auto-camera collision)
for t=1 to 5
make static object t
objx#=object position x(t)
objy#=object position y(t)
objz#=object position z(t)
objsx#=object size x(t)/2.0
objsy#=object size y(t)/2.0
objsz#=object size z(t)/2.0
make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#
delete object t
next t
rem Make sky black
color backdrop 0
rem Start off player gravity
playergrav#=2.0
rem Main loop
do
rem Store old positions
oldposx#=object position x(11)
oldposy#=object position y(11)
oldposz#=object position z(11)
rem Control player object
if upkey()=1 then move object 11,2
if leftkey()=1 then yrotate object 11,wrapvalue(object angle y(11)-3)
if rightkey()=1 then yrotate object 11,wrapvalue(object angle y(11)+3)
rem Get current object position
posx#=object position x(11)
posy#=object position y(11)
posz#=object position z(11)
rem Handle sliding collision for player object with other objects
position object 11,posx#,posy#,posz#
if object collision(11,0)>0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
playergrav#=0.0
endif
rem Set a size for the player object
s#=object size y(11)/2.0
rem Ensure camera stays out of static collision boxes
if get static collision hit(oldposx#-s#,oldposy#-s#,oldposz#-s#,oldposx#+s#,oldposy#+s#,oldposz#+s#,posx#-s#,posy#-s#,posz#-s#,posx#+s#,posy#+s#,posz#+s#)=1
dec posx#,get static collision x()
dec posy#,get static collision y()
dec posz#,get static collision z()
if get static collision y()<>0.0 then playergrav#=0.0
endif
rem Update with new object position
position object 11,posx#,posy#,posz#
rem Use camera tracker to follow player object
angle#=object angle y(11)
camdist#=5.0 : camhigh#=posy#+50.0 : camfade#=3.5
set camera to follow posx#,posy#,posz#,angle#,camdist#,camhigh#,camfade#,1
rem Tilt camera down a little
xrotate camera 90
rem Update screen
sync
rem End loop
loop
rem Restore object if ever leave this loop
enable object zdepth 11
credits:
cls
set text size 15
ink rgb(255,255,255),1
text 0,0,"CREDITS"
text 0,30,"========================================================================"
text 0,45,"Game created by Anthony Mincarelli"
text 0,65,"Code to create menu was found on the live code base at thegamecreators.com"
text 0,75,"========================================================================"
text 0,110,"Press any key to return."
suspend for key
cls 0
goto start
exit:
end
ignore the game, its not done yet.
if you tested the code, you saw that the menu was flashing. also, im wondering if there is any way to rotate a collision box. *shrugs* it would make it alot easier if you could.
CEO of Qualed Entertainment
Join the Qualed Code Group: email me at
[email protected]