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.

DarkBASIC Discussion / Clickable spots?

Author
Message
Shaddak
23
Years of Service
User Offline
Joined: 8th Apr 2003
Location:
Posted: 9th Apr 2003 05:32
I'm new to this, so perhaps this question has already been asked. How do I create clickable spots/options? I'm making up a menu and I want to make it so the different options on it are clickable.
AsriCE
23
Years of Service
User Offline
Joined: 10th Jan 2003
Location: Brunei
Posted: 9th Apr 2003 13:41
The following function returns a one if the specified region(in pixels) is clicked.

Rem X1 should be less than X2
Rem Y1 should be less than Y2
Function RegionClicked(X1, Y1, X2, Y2)
Clicked=0
If (MouseX()>=X1) AND (MouseX()=<X2)
If (MouseY()>=Y1) AND (MouseY()=<Y2)
If MouseClick()=1 Then Clicked=1
EndIf
EndIf
EndFunction Clicked

Asri CE Crew

Anak Brunei!
Shaddak
23
Years of Service
User Offline
Joined: 8th Apr 2003
Location:
Posted: 10th Apr 2003 05:19
thanks

Shaddak
23
Years of Service
User Offline
Joined: 8th Apr 2003
Location:
Posted: 10th Apr 2003 05:52
Hey, that seems to work, but I ran into a small problem. Here's what I have:

The problem that I run into is that it tells me there is no such label (note the "goto StoryA" oart). That label clearly is there, however.

--
No of SETI units returned: 832
Processing time: 1 year, 65 days, 1 hr, 47 min, 50.2 sec; (Total hours: 10321.79728]; Rank: 192,993/4,412,417 [users who share this rank: 172, top 95.622 percent]
Engulfed by Darkness
23
Years of Service
User Offline
Joined: 31st Mar 2003
Location: Canada
Posted: 10th Apr 2003 06:47
You must end all your "if"s.


If it's yellow let it mellow. If it's brown flush it down.
Engulfed by Darkness
23
Years of Service
User Offline
Joined: 31st Mar 2003
Location: Canada
Posted: 10th Apr 2003 07:07
Ignor the first post.

This would work tho:

Functions are totally separated from the rest of your code. Say for example you set a variable clicked = 1. Then go to a function and print clicked. It would print a 0. Even know they have the same name the function is separate and will not reconize variables from the rest of your code. Same with Subs. It doesn't reconize Subs out side of the Function. So you could place the Sub inside the Function or return the value of a variable of the Function to the main code.
Ex.


Hope that helps

If it's yellow let it mellow. If it's brown flush it down.
Engulfed by Darkness
23
Years of Service
User Offline
Joined: 31st Mar 2003
Location: Canada
Posted: 10th Apr 2003 08:12
Opps i forgot that Subs will not work in Functions.

You will just have to return a variable.

If it's yellow let it mellow. If it's brown flush it down.
Shaddak
23
Years of Service
User Offline
Joined: 8th Apr 2003
Location:
Posted: 10th Apr 2003 09:20
Hmm, I'll try that.

--
No of SETI units returned: 832
Processing time: 1 year, 65 days, 1 hr, 47 min, 50.2 sec; (Total hours: 10321.79728]; Rank: 192,993/4,412,417 [users who share this rank: 172, top 95.622 percent]
Hamish McHaggis
23
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 10th Apr 2003 19:02
Hmm, the code is a bit muddled, but darkness was getting there shouldn't it be like this...



The variables should be specified when you are calling the function, not inside it. I also simplified the main loop to one line.

Why the hell'd you ask me for crying out loud!?!

Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM

Login to post a reply

Server time is: 2026-06-11 15:09:04
Your offset time is: 2026-06-11 15:09:04