TGC Codebase Backup



DBP Menu code by Seppuku Arts

8th Jul 2005 19:21
Summary

Just make a simple menu using text, you can apply the same knowledge to bitmaps



Description

This was made in Dark Basic Pro, it uses the function command, and text and values, it can be controlled using the Keyboard and joypad, rather than the mouse. If you want to use bitmaps, load the bitmaps before the command set and replace the text commands in the functions with paste image commands, and maybe adjust the numbers a bit depending on image size.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Project: RPG Engine
Rem Created: 07/04/2005 23:20:41

Rem ***** Main Source File *****
cls
`Menu test
hide mouse
`keyboard menu
cls

uphold# = 0
downhold# = 0
t# = 0
do
if t# = 0 then t1()
if t# = 1 then t2()
if t# = 2 then t3()

if upkey()=1 then inc uphold#,1
if downkey()=1 then inc downhold#,1
if joystick up()=1 then inc uphold#,1
if joystick down()=1 then inc downhold#,1
if uphold# = 20 then cls : dec t#, 1 : uphold# = 0
if downhold# =20 then cls : inc t#, 1 : downhold#= 0
if t = 0 and returnkey()=1 then t4()
if t = 1 and returnkey()=1 then t5()
if t = 2 and returnkey()=1 then t6()

if t# = 0 and joystick fire a()=1 then t4()
if t# = 1 and joystick fire a()=1 then t5()
if t# = 2 and joystick fire a()=1 then t6()
if t# > 2 then t# = 0
if t# < 0 then t# = 2
loop
`text1 function
function t1()
text 0,10,"New game"

endfunction

function t2()
text 0,20,"Load"

endfunction

function t3()
text 0,30,"Quit"

endfunction

function t4()
text 0,60,"This would go to a new game"
endfunction

function t5()
text 0,60,"This would go to a Load menu"
endfunction

function t6()
end
endfunction