I've just been making like a 5 mintue RPG to truly test my new DBPro skills (which arn't that good yet. I'm having problems still with a few things like collision and particles and such). Anyways, I started making the menu, using #include and seperate files containing functions. I did however make the variables consistent by using cOp (the only variable so far, and then one the menu uses) in the parameters.
Here's the main file:
Rem ***** Main Source File *****
`includes
#include "menufunctions.dba"
`Init for performance.
sync off : backdrop off : hide mouse
if check display mode(1024,768,32)=1 then set display mode 1024,768,32
`Loading Screen
load bitmap "media\gfx\screens\loading.bmp",1
copy bitmap 1,0,0,640,480,0,0,0,screen width(),screen height()
sync : delete bitmap 1
`Title screen
cOp=1
setupmenu(cOp)
menuloop(cOp)
and here is the menufunctions.dba file (prepare to read one long function
)(Note: Besides the first two functions, the others just make cubes, then wait key then exit. Once I get the menu done, they'll do what they're supposed to, but for now thats all they do.):
Rem ***** Main Source File *****
function setupmenu(cOp)
cOp = 1
load bitmap "media\gfx\screens\mains.bmp",1
copy bitmap 1,0,0,640,480,0,0,0,screen width(),screen height()
sync
endfunction
function menuloop(cOp)
do
delete bitmap 1
`get user keys
if cOp = 1
if upkey()=1 then cOp=3
if downkey()=1 then cOp=2
if leftkey()=1 then cOp=4
if rightkey()=1 then cOp=5
endif
if cOp=2
if upkey()=1 then cOp=1
if downkey()=1 then cOp=3
if leftkey()=1 then cOp=4
if rightkey()=1 then cOp=5
endif
if cOp=3
if upkey()=1 then cOp=2
if downkey()=1 then cOp=1
if leftkey()=1 then cOp=4
if rightkey()=1 then cOp=5
endif
if cOp=4
if upkey()=1 then cOp=5
if downkey()=1 then cOp=5
if leftkey()=1 then cOp=3
if rightkey()=1 then cOp=1
endif
if cOp=5
if upkey()=1 then cOp=4
if downkey()=1 then cOp=4
if leftkey()=1 then cOp=1
if rightkey()=1 then cOp=3
endif
`Change picture acordingly
delete bitmap 1
`Start Game
if cOp=1
load bitmap "media\gfx\screens\mains.bmp",1
copy bitmap 1,0,0,640,480,0,0,0,screen width(),screen height()
sync
endif
`Load Game
if cOp=2
load bitmap "media\gfx\screens\mainl.bmp",1
copy bitmap 1,0,0,640,480,0,0,0,screen width(),screen height()
sync
endif
`Options
if cOp=3
load bitmap "media\gfx\screens\maino.bmp",1
copy bitmap 1,0,0,640,480,0,0,0,screen width(),screen height()
sync
endif
`Help
if cOp=4
load bitmap "media\gfx\screens\mainh.bmp",1
copy bitmap 1,0,0,640,480,0,0,0,screen width(),screen height()
sync
endif
`Exit
if cOp=5
load bitmap "media\gfx\screens\maine.bmp",1
copy bitmap 1,0,0,640,480,0,0,0,screen width(),screen height()
sync
endif
`Select an option
if returnkey()=1
`Start Game
if cOp=1 then Startgame()
`Load Game
if cOp=2 then Loadgame()
`Options
if cOp=3 then Options()
`Help
if cOp=4 then Help()
`Exit
if cOp=5
delete bitmap 1 : sync : cls
text 1,1,"Are you sure?"
input input$
if input$="Yes" then end
if input$="yes" then end
if input$="y" then end
if input$="Y" then end
if input$="No" then setupmenu(cOp)
if input$="no" then setupmenu(cOp)
if input$="N" then setupmenu(cOp)
if input$="n" then setupmenu(cOp)
endif
endif
loop
endfunction
function Startgame()
cls
backdrop on
make object cube 1,100
wait key
end
endfunction
function Loadgame()
cls
backdrop on
make object cube 1,100
wait key
end
endfunction
function Options()
cls
backdrop on
make object cube 1,100
wait key
end
endfunction
function Help()
cls
backdrop on
make object cube 1,100
wait key
end
endfunction
When I run the exe, it gives me the error "Cannot load bitmap at line 66". Well, in the main file, there aren't 66 lines, and in menufunctions.dba, line 66 is a comment, and line 67 is "if cOp=1" just incase. Also, I know all the files are in the correct locations, media\gfx\screens\something.bmp
Any help would be appreciated. Thanks, Nick.
The only way to prevent all lag in a game is not to make the game.