Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Need Help With Buttons for menu

Author
Message
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 7th Aug 2005 15:22
I have created a simple Menu for a game called Block Breaker.
I have 4 pictures in the background and i would like to make them buttons. Do i need to make them seperate images or can i just create a box around each text and define that an onclick?

Attachments

Login to view attachments
Heckno
20
Years of Service
User Offline
Joined: 8th Sep 2004
Location: Palm Coast, FL
Posted: 7th Aug 2005 19:08
depends on what effect your going for...

one way to do it is to make each a separate sprite and attach a very small or invisible sprite on the end of the cursor. Then use sprite collision with mouse click to activate the button....

Or you could determine the x/y coordinates of each button and write the code to only activate within the x/y bound box of each respective button...

so you can do it either way, separate images or not...
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 7th Aug 2005 19:19
I have decided to make seperate images that will act as buttons. I have the X,Y coordinates of each box and not sure how to write the command for it. Also I do not know how to make it so when you click on the button it actually runs the game, such as if i was to click on "New Game" how do i link it and do i have to write another seperate script or do i write it under the one i have created the menu on.

Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 7th Aug 2005 19:19
I have decided to make seperate images that will act as buttons. I have the X,Y coordinates of each box and not sure how to write the command for it. Also I do not know how to make it so when you click on the button it actually runs the game, such as if i was to click on "New Game" how do i link it and do i have to write another seperate script or do i write it under the one i have created the menu on.

Cookyzue
20
Years of Service
User Offline
Joined: 12th Oct 2003
Location: Who Cares?!
Posted: 7th Aug 2005 22:06 Edited at: 7th Aug 2005 22:06
this would be for checking i fthe mouse is in the box and is being clicked.


then after that you could just use a goto command, so its like this:



MCK Games
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 7th Aug 2005 22:27
Do I just write Maingame: and then write all the stuff for it under it? That would then mean I have the Do-Loop for menu and then after the Do-Loop for the game. Will that not confuse things? Surly I have to unload all the menu commands or something along the lines of that.

Cookyzue
20
Years of Service
User Offline
Joined: 12th Oct 2003
Location: Who Cares?!
Posted: 8th Aug 2005 00:34
like this



MCK Games
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 8th Aug 2005 00:36
I have sort of got it now. I have done a menu, the buttons are not great because i cant figure how to do the coorordinates but i can click on the button in a small place and then it goes to the main game. Thanks for the help

Heckno
20
Years of Service
User Offline
Joined: 8th Sep 2004
Location: Palm Coast, FL
Posted: 8th Aug 2005 05:53
you can always manually map it out by posting the x/y cords to the screen with print commands...

you could try something like below:

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Aug 2005 06:45
Don't use Goto!!! There are better ways to do it.

Also, only have one main Do..Loop in your program otherwise you are making it difficult for yourself.

Put code you may want to use over and over again in a procedure or a function. Each time you want to use it, you just use Gosub or if it's a function, call it.

Your program should never exit the main Do..Loop unless you want the program to end.

Your program structure should look something like this...

Gosub VariablesSetup
Gosub ScreenSetup

Rem Main Program Loop...
Do
MX=MouseX(): MY=MouseY(): MC=MouseClick()
Gosub KeyBoardInput
Gosub MainMenu: Rem Prog loops there until game starts
Gosub PlayerMove
Gosub AI
Gosub DrawObjects
Sync
If EndGame = 1 Then Exit
Loop
Gosub CleanUp
End

That's only a rough guide and you can split your game up into smaller chunks in the procedures making it easier to track down problems.

TDK_Man

Login to post a reply

Server time is: 2024-09-24 01:26:38
Your offset time is: 2024-09-24 01:26:38