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 / Problems trying to make a Sprite Button

Author
Message
Sebastian
17
Years of Service
User Offline
Joined: 12th Aug 2007
Location: Jasper, TX
Posted: 16th Aug 2007 00:25
It's the n00b of DarkBASIC Classic again... Oki, for now I know how to make the bitmap loaded sprites (load bitmap "Bitmap.bmp"
and then make an image of them... I must be going at this the wrong way, but using this line of code:

[image routine]

sprite 1, 200, 10, 1

do
if 200=mousex() and 10=mousey()and mouseclick()=1 then print "Hello"
loop

end

"Do What Thou Wilt, For The Whole Be The Law... Love is the Law, Do What Thou Wilt... There Is No Law Further Then Do What Thou Wilt..."
- A. Crowley
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 16th Aug 2007 03:35 Edited at: 16th Aug 2007 03:36
Quote: "It's the n00b of DarkBASIC Classic again... Oki, for now I know how to make the bitmap loaded sprites (load bitmap "Bitmap.bmp""


Why not just use Load Image??

Quote: "if 200=mousex() and 10=mousey()and mouseclick()=1 then print "Hello""


Apart from being back to front, that line refers to just one single solitary pixel on the screen!

Please look at the beginners tutorials. They will answer 99% of all your questions.

Tutorial 16 here for a start:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

... and all the others if you get stuck on anything else!

TDK_Man

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 16th Aug 2007 15:40
Load the image
then detect an area: if mousex() is within the left side and right side of the sprite.
Alternatively just make another single pixel sprite to follow the mouse around and detect collisions.

Your signature has been erased by a mod because it was rubbish.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Aug 2007 18:19 Edited at: 17th Aug 2007 18:21
Quote: "then detect an area: if mousex() is within the left side and right side of the sprite."


If you've created a sprite for the button then detecting an area is pointless.

Using sprite collision (as described in the tutorial linked to above) means you don't have to know how many buttons there are - or where they are on the screen. They can even move about and it still works!

Just one line of code tells you which button has been clicked on without any If..Then lines testing the mouse position and regions.

TDK_Man

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 17th Aug 2007 18:22
oops sorry I got mixed up there, here's what I meant.

Load the image
You can either paste the image and then detect an area: if mousex() is within the left side and right side of the image.
Alternatively make a sprite with the image and make another single pixel sprite to follow the mouse around and detect collisions between the sprites.

Your signature has been erased by a mod because it was rubbish.

Login to post a reply

Server time is: 2025-05-30 13:41:26
Your offset time is: 2025-05-30 13:41:26