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 / Main Menu Help

Author
Message
Belthazor
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Lafayette,Louisiana
Posted: 31st Jul 2005 21:49
I want to make a menu screen with a bitmap in the background.
but the words won't show b/c my bitmap is mostly white, can I change the color of my text or is there a better way.
also how can I make menu buttons that I can click on work.

Tryin hard...
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 31st Jul 2005 23:13 Edited at: 31st Jul 2005 23:20
The colour of text is changed using the Ink command.

You can use Ink ForegroundColourNum, BackgroundColourNum as in:

Ink 65535,0

but as most users don't know what numbers to use, you can use the RGB function to give you:

Ink RGB(RedVal,GreenVal,BlueVal),0

So, Ink RGB(255,0,0),0 will give you red text on a black background.

As using RGB is slower, if you want black text, you should use Ink 0,0.

You also have Set Text Transparent and Set Text Opaque. If you use Transparent, then the background colour is invisible.

[Edit] I came across my old menu system the other day, but it's for DBC only and you didn't say if you were using Pro or not. I've attached it if it's any use to you.

[2nd Edit] Oops didn't read your post correctly - wrong type of menu, so ignore my attachment!

TDK_Man

Attachments

Login to view attachments
Heckno
20
Years of Service
User Offline
Joined: 8th Sep 2004
Location: Palm Coast, FL
Posted: 31st Jul 2005 23:13
try the ink command just before your print commands also below is a way i use the mouse cords to create actions on sprites...

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 31st Jul 2005 23:28
With regards to clickable buttons, simply draw the buttons on your bitmap in a paint program.

When you do this, take note of the X and Y position of the top left and bottom right corner of each button.

In your program's menu screen loop you would have something like:

MX=MouseX(): MY=MouseY(): MC=MouseClick()

If MX>TLCX and MY>TLCY and MX<BRCX and MY<BRCY and MC=1
Gosub WhateverThisButtonDoes
Endif

... where TLCX is this button's Top Left Corner X value, TLCY is the Top Left Corner Y value, BRCX is the Bottom Right Corner X value and BRCY is the Bottom Right Corner Y value.

Repeat for each button (OK if you only have a few buttons).

TDK_Man
NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 31st Jul 2005 23:32 Edited at: 31st Jul 2005 23:35
Belthazor,

Use the ink command, along with the rgb command, placed before your text or print commands, to change the color of the text.

Example:


If you do not understand rgb values, just know this. That, r/g/b stands for red/green/blue. Either value can be up to 255. The value stands for how much of that color is being output. A mixture of values will give out different colors of the color wheel. There is a possibility of up to 16,581,375 colors.

About buttons, they are quite simple. To make a button that works, we must first compare the coordinates of the box with coordinates of the mouse. A box will have 4 coordinates(left side, top side, right side, bottom side).



In the example above, the box's coordinates are:

left side = 0
top side = 0
right side = 100
bottom side = 50

How would we check if the mouse is inside the box? We check if it is to the right of the left side of the box and to the left of the right side of the box. Also, if it below the top of the box and above the bottom of the box. If all of these conditions are true, then the mouse is within the box, as shown above.

Example:


Now, to make a functional button from here, is extremely simple. Use the same code above, with a little mouseclick() checking, to see if the mouse is clicked while inside the box.

Example:


Note, that this code may need to be set up differently to do what you need it to do. Let us say that the last example above is placed in a do loop. The code where it states "run needed code", will be executed each loop until the mouse is let off off. If a program refreshes 60 times in a second, then if the user hold the mouse button down within the button for one second, then the needed code will be executed 60 times within that second.

To counter this is simple, once you understand the method. Check the example below.

Example:


I have thrown in a variable named runcode, which its value is changed to 1 when the button is pressed. Therefore, the if mouseclick() = 1 and runcode = 0 will only be true the first time the button is pressed. So, the needed to be ran code will only be executed once, no matter how long the user holds down the mouse button.

Using this method, the button is technically disabled after its first use. To enable the button for later use, would take a simple line of code runcode = 0.


+NanoBrain+
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 13th Aug 2005 21:16
I am stuck, I have done what TDK said and I cant get it to work, the values are correct what I have put in but it does not go to the main game.



http://www.Bevansfunbox.com
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 13th Aug 2005 21:29
you don`t have the correct values in the button click code, for example the MX>3 must actualy read MX>50 since that is the position of the leftmost position of your buttons, the same for all the other corners that make up the selection area box, you need the position of the corners in the test eg

if MX>50 and MY>275 and MX<200 and MY<300 and MC=1

the second MX and MY should be the position of the right bottom corner of the button btw, at the moment you are checking for a very small button starting at pixel 3, 15 pixels wide and 17 pixels down and 3 deep, TDK mans code was just an example, those numbers need to altered to reflect the size and position of your buttons.

The Ringmaster
19
Years of Service
User Offline
Joined: 19th Mar 2005
Location: Cyberspace
Posted: 14th Aug 2005 09:36
Thanx, I was having trouble with buttons myself

The Ringmaster
19
Years of Service
User Offline
Joined: 19th Mar 2005
Location: Cyberspace
Posted: 14th Aug 2005 09:39
I have another code for "text only" buttons. These do not work for images though:



The Ringmaster
19
Years of Service
User Offline
Joined: 19th Mar 2005
Location: Cyberspace
Posted: 14th Aug 2005 09:53
Oops. Um, I have a bug in my menu system, uh, it goes like this:



The buttons specifics are:
height: 31pxls
width: 170pxls

it is positioned at 530,270 and my display mode code is this:



Any ideas?

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 14th Aug 2005 19:29 Edited at: 14th Aug 2005 19:40
I have an old utility I wrote (somewhere) which loads images and lets you define buttons on it.

When you've defined areas of the screen as buttons, it writes the dba code to disk for you to merge into your own code.

It's not brilliant, but it works lol!

If I can find it, I'll post it as a new 'Newcomers Snippet' on the Newcomers board...

The Ringmaster:

Your problem I think, is because you are using a Window. You are also using an illegal Set Display Mode value. (This should be 640,480 or 800,600 etc and should only be used if using full screen mode).

When using windows, don't you have Set Window Size?

If I remember correctly, in DBC MouseX() and MouseY() returns the values from the top left corner of the SCREEN - not the top left corner of the window. Not sure - it's a very long time since I did this...

Use Set Window Position to define the window's X and Y position on screen, then subtract those values from the MouseX and MouseY positions you get.

Actually, it might be add - not subtract lol. I can't remember so you'll have to experiment!

TDK_Man

Login to post a reply

Server time is: 2024-09-24 01:30:19
Your offset time is: 2024-09-24 01:30:19