Quote: "The site I have been using as a base so far is http://www.tek-tips.com/viewthread.cfm?qid=433215&page=2 but for some reason i get alot of errors. Any help would be great."
That message was probably made in 2005. It's best to stay here to get the latest methods on programming in Darkbasic Pro.
Quote: "Yes i know not the prettiest code and its not commented. Anyway iv been trying to make some code that lets me click on an image to take me deeper into the menu or start the game."
The easiest method for menus is using sprites and the SPRITE COLLISION() command. Every selected menu image is a hidden sprite and there is a small sprite at the mouse coordinates (also hidden). You check if the small sprite is colliding with any of the menu sprites and if it is you reveal the hidden menu sprite currently colliding with the small sprite. When not colliding with anything all the sprites are hidden to show just the background image (the menu items in a non-selected state).
set display mode 640, 480, 32
sync rate 0
sync on
global Loaded
` Load the background and each selected menu item
load image "MenuBack.png",1
` Set starting y coordinate for the selected menu items
y=154
for t=1 to 3
` Load the selected menu item
load image "Menu"+str$(t)+".png",t+1
` Create a sprite out of the image and center it
sprite t,screen width()/2-image width(t+1)/2,y,t+1
` Increase y for next selected menu item
inc y,78
next t
` Create a small sprite for the sprite collision check
box 0,0,2,2
get image 5,0,0,2,2,1
sprite 5,0,0,5
` Hide all sprites
hide all sprites
do
` Show the background menu
paste image 1,0,0
` Place the small sprite at the mouse coordinates
sprite 5,mousex(),mousey(),5
` Make Menu equal the sprite current colliding with the small sprite
Menu=sprite collision(5,0)
` Check if menu is more than zero (small sprite actually is colliding)
if Menu>0
` Show the sprite of the menu selection
show sprite Menu
else
` Hide all sprites (if no menu item is being selected)
hide all sprites
endif
` Check if the mouse button has been let go after it was clicked
if mouseclick()=0 and Clicked=1
` Check if a menu item is currently being selected
if Menu>0
` Hide all sprites
hide all sprites
` Remove the background image
cls
` Call the game function with the selected menu item
Game(Menu)
` Leave the do/loop
exit
endif
endif
` Check if the user is hitting a mouse button
if mouseclick()
` Turn on clicked switch
Clicked=1
else
` Turn off clicked switch
Clicked=0
endif
sync
loop
sync
wait key
end
function Game(gamestate)
select gamestate
` Start
case 1
if Loaded =0
Loadmap()
Loaded = 1
endif
print "the game"
endcase
` Instructions
case 2
print "how to play"
endcase
` Quit
case 3
print "Quitting"
sync
wait key
end
endcase
endselect
endfunction
function Loadmap()
make object cube 1, 5
sync
endfunction