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.

2D All the way! / Sprite collision with mouse cursor

Author
Message
Shopro
21
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Japan
Posted: 15th Dec 2002 13:26
Hello

Can someone give me some advice on the best way to achieve this? For example, in an AoE or AoM type game, when you click on a unit it gets selected. I've figured how to do this by using a sprite as the cursor, but I hoped there is a better way.

Any advice will be appreciated
Thank you

-Shopro
xtom
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 15th Dec 2002 20:59
You can use mousex() and mousey() and compare them to sprite positions. Using a sprite is just as good as though.
Kangaroo2
21
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 16th Dec 2002 00:54
probably the easiest way to keep the default windows cursor but detect a hit anywhere on the sprite not just its x & y positions is to place a dark 1x1 sprite at the mouse coord, and check for collisions with that. It'll position itself at the point of the mouse and if its Dark enough (but not quite true black otherwise its invisible) you won't see it.

* If the apocalypse comes, email me *
Shopro
21
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Japan
Posted: 16th Dec 2002 18:40
Thanks for the replies.
I thought DBP would have a specific command for this, but oh well

-Shopro

indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 21st Dec 2002 07:15
the collision with an intended mouse sprite could be effective as u will want to change the state of the mouse indicator cursor to show the user different results.

u could use a distance functon also in this regard.

Login to post a reply

Server time is: 2024-03-29 10:06:02
Your offset time is: 2024-03-29 10:06:02