here's my code, is there anything i can do to make it faster?
set display mode 800, 640, 32
sync on : sync rate 0 : hide mouse : backdrop off : disable escapekey
rem Type just for the menu
type type_Menu
iBack as integer
iItem as integer
iMove as integer
iDirection as integer
tPoint as type_coordinate
iBegin as integer
endtype
rem Declares a variable with the menu type
global tMenu as type_Menu
remstart
This is the main menu
remend
_Loadmenu:
tMenu.tPoint.X = 90
tMenu.tPoint.Y = 420
tMenu.iBegin = 420
tMenu.iMove = 0
tMenu.iItem = 1
rem set font style to "Impact"
set text font "impact"
rem loads background image for the menu
load image "bitmaps/menu_Back.bmp", 1
load image "bitmaps/menu_Back.bmp", 2
do
rem clear the screen every refresh
cls rgb(0,0,0)
ink rgb(255,255,255), rgb(255,255,255)
rem paste the background image
paste image 1, 0, tMenu.iBack
paste image 2, 0, (tMenu.iBack - 600)
rem Get a new value for iBack that increases 2 and when it reaches 480, it is reduced my 480.
tMenu.iBack = IncSetValue(tMenu.iBack, 5, 600, 600)
rem set the text color to red and change the font size to 70
ink rgb(255, 0, 0), 0 : set text size 90
rem Draw the Title "Galaga" centered
center text 400, 30, "Galaga"
rem Set to color to white for the selection box
ink rgb(255, 255, 255), 0
if tMenu.iMove = 0
tMenu.iMove = CheckMenuMove(tMenu.iItem)
tMenu.tPoint.X = 0
else
tMenu.tPoint.X = IncSetValue(tMenu.tPoint.X, 10, 0, 0)
tMenu.tPoint.Y = MoveMenu(tMenu.iItem, tMenu.iMove, tMenu.iBegin, tMenu.tPoint.X, tMenu.tPoint.Y)
if tMenu.tPoint.X = 90
tMenu.tPoint.X = 0
tMenu.iItem = NewMenuItem(tMenu.iItem, tMenu.iMove)
tMenu.iMove = 0
tMenu.iBegin = tMenu.tPoint.Y
endif
endif
box 200, tMenu.tPoint.Y, 600, (tMenu.tPoint.Y + 60)
rem set the text color to pure red and change font size to 40
ink rgb(255, 0,0), 0 : set text size 60
rem Draw the menu items
center text 400, 420, "Start"
center text 400, 490, "Options"
center text 400, 560, "Exit"
set text size 20
text 0, 0, str$(scancode())
text 750, 0, "fps: " + str$(screen fps())
rem Updates the screen
sync
loop
return
rem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~MENU FUNCTIONS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function MoveMenu( Item, Direction, Begin, X, Y )
Select Item
case 1
if Direction = 1
Y = Begin + int(sin(X) * 140)
else
Y = Begin + int(sin(X) * 70)
endif
endcase
case 2
if Direction = 1
Y = Begin - int(sin(X) * 70)
else
Y = Begin + int(sin(X) * 70)
endif
endcase
case 3
if Direction = 1
Y = Begin - int(sin(X) * 70)
else
Y = Begin - int(sin(X) * 140)
endif
endcase
endselect
rem text 0, 200, str$(y)
endfunction Y
function CheckMenuMove(Item)
local Press as integer
Press = 0
if keystate(200)=1
Press = 1
exitfunction Press
endif
if keystate(208)=1
Press = 2
exitfunction Press
endif
if keystate(57)=1
GoToMenu(Item)
endif
endfunction Press
function GoToMenu(Item)
Select Item
case 1
endcase
case 2
endcase
case 3
end
endcase
endselect
endfunction
function NewMenuItem( Item, Direction )
if Direction = 1
dec Item, 1
if Item = 0 then Item = 3
else
inc Item, 1
if Item = 4 then Item = 1
endif
endfunction Item
rem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://esotericbasic.dbspot.com