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.

Dark GDK / Sprites and Mice

Author
Message
Yogz
19
Years of Service
User Offline
Joined: 11th Oct 2004
Location: England
Posted: 9th Jan 2008 22:44
What's the easiest way to check whether a mouse pointer is in contact with a sprite?

I know in theory I can compare the X,Y,Height,Width coordinates, etc. however I've made various attempts using C++/GDK to no avail.

Or should I dump sprites and use textured plains instead?

Thanks
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 9th Jan 2008 22:57
Quote: "I know in theory I can compare the X,Y,Height,Width coordinates, etc. however I've made various attempts using C++/GDK to no avail."


Show us your code, we can find the problem.
John Goewert
16
Years of Service
User Offline
Joined: 1st Jan 2008
Location: Cornfield, MO
Posted: 9th Jan 2008 22:58
Actually, it should be near exactly the same as the contact collision in the Dark Invaders example.



However, a lazy method I just thought of would be to create a 1x1 pixel sprite that is clear and then update it to the position of the mouse and just use dbSpriteHit() on that sprite.

The problem I can't find in the documentation is how to get the mouse's X,Y position. You can set it with dbPositionMouse() and find out how much it moved with dbMouseMoveX(), Y(), or ? Z()?.
John Goewert
16
Years of Service
User Offline
Joined: 1st Jan 2008
Location: Cornfield, MO
Posted: 9th Jan 2008 23:10
Ah, guessed it and Intellisense grabbed it.

dbMouseX(), dbMouseY()

The docs do have it, but in an untitled pages that are not linked to in "Input".
Yogz
19
Years of Service
User Offline
Joined: 11th Oct 2004
Location: England
Posted: 9th Jan 2008 23:17
I'm rusty lol, look at the joining date :p

I'll take the lazy 1x1 sprite option. Had already gone down this route by replacing mouse pointer but that idea is better.

Thanks
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th Jan 2008 17:47
Tip I learned the hard way!

Need a command? Check the Dark BASIC Help! Find it - know the name - then go into C++ editor and see if intellisense picks it up!

If not? Look in the DarkGDK.h and other header files for the commands... Still not there?

Then sometimes you have to make your own header entry - and HOPE its there while you compile and link! (Yes there are a few... I forget who - but someone on here gave me a couple - they are in my source code ... I think in jgc_common.h in my Ted Demo and the Frustrum Culling port I made. But you may find others!

Login to post a reply

Server time is: 2024-09-29 09:18:55
Your offset time is: 2024-09-29 09:18:55