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 / Sprite collision. Does it work for making buttons?

Author
Message
Sunflash
19
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 17th Feb 2006 03:50
Hey all,
I've been working on a menu system, but am looking at improving my code. I have some buttons loaded in the program as sprites, and currently to test if the mouse is over the button, I have to say something like:

If MouseX() >900 And MouseX() <1023 And MouseY() >180 And MouseY() <205

I've tried useing the Sprite Collision() command to test if the cursor sprite is bumping into the button sprite, but theres a problem, the button ha LOTS of black in it, so if the cursor is anywhere over that black, the program says it's not there. So, I added a RGB value of 0,0,10 to the black in the button so it would register as partly black. That didn't work, so I added more blue to the image, and that STILL didn't work I ended up haveing to make it look obviously a little blue, but it was STILL becoming transparent in DBC. Is there any way around this?
Thanks,
-Sunflash

When FPSC develops enough, lets make a Redwall game!

DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 17th Feb 2006 05:51
o yah this isnt goin to help but Redwall rocks!

Check out my site!(unfinished)
http://www.freewebs.com/dbnewbie/
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 17th Feb 2006 09:56
don`t use black?, seriously, you could have some white sprites the same size and position as the buttons but hidden, before the sync occures, unhide them and check for collision, then just before the sync rehide them so you only see the screen you intended, they might even flag collisions while they are hid, not sure on that since I use Pro, Pro users have the problem that we would like pixel perfect collision (whats causing your problem) but have box collision instead(what you would like for your buttons), so it`s kinda ironic , the other way is just to use the x/y positions as you where doing.



Windows: 32 bit extension/graphical shell for a 16bit patch to an 8bit OS originally coded for a 4bit CPU, written by a 2bit company that can't stand 1bit of competition, now available in 64bits.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 17th Feb 2006 09:58
I don't know what you are doing but transparency works on black 0,0,0 to about 5,5,5 if you have a 16 bit colour range, and about 0,0,0 on a 32 bit colour range. 16 bit is a bit messed up because DB Classic changes the pallette a bit for 16 bit. If you have 8 bit colours it may be badly effected as to allow blue to be transparent. Maybe you are grabbing the images from the bitmap, try just loading the images without grabbing them.

Sunflash
19
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 17th Feb 2006 11:08
Quote: "I don't know what you are doing but transparency works on black 0,0,0 to about 5,5,5 if you have a 16 bit colour range, and about 0,0,0 on a 32 bit colour range. 16 bit is a bit messed up because DB Classic changes the pallette a bit for 16 bit. If you have 8 bit colours it may be badly effected as to allow blue to be transparent. Maybe you are grabbing the images from the bitmap, try just loading the images without grabbing them."


I'm useing 32 bit color.

Quote: "they might even flag collisions while they are hid"


Yup, it does. And it would work dandy too, but my problem is that the collision =0 if the cursor is over the transparent part of a sprite, so when you go over the buttom... or whats SUPPOSED to be the button, the computer thinks there hasn't been a collision.

When FPSC develops enough, lets make a Redwall game!

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 17th Feb 2006 13:52 Edited at: 17th Feb 2006 13:55
Quote: "Yup, it does. And it would work dandy too, but my problem is that the collision =0 if the cursor is over the transparent part of a sprite, so when you go over the buttom... or whats SUPPOSED to be the button, the computer thinks there hasn't been a collision."


To get rid of black in buttons just load the images into a art package, and raise the brightness very slightly. make sure you keep areas black that need to be transparent. I use the magic wand.

Sunflash
19
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 17th Feb 2006 23:38
Yup, this is what I have tried to do, but for some reason it still registers as transperant. I've made it obvously blue and it made it transparent!

When FPSC develops enough, lets make a Redwall game!

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Feb 2006 14:09
Maybe you are using JPG. Use BMP. JPG does not make accurate colours.

new programmer
19
Years of Service
User Offline
Joined: 20th Dec 2005
Location: right behind you.
Posted: 19th Feb 2006 05:22
Quote: " o yah this isnt goin to help but Redwall rocks! "


thats right
Sunflash
19
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 19th Feb 2006 08:10
Quote: "Maybe you are using JPG."


Nope, I'm useing .BMP

When FPSC develops enough, lets make a Redwall game!

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Feb 2006 12:58
Well instead of going blue, go 3,3,3. It works in all the games that I have made.

Login to post a reply

Server time is: 2025-05-23 15:17:36
Your offset time is: 2025-05-23 15:17:36