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.

Author
Message
Amax125
17
Years of Service
User Offline
Joined: 16th Nov 2008
Location:
Posted: 16th Nov 2008 20:49
Hey Im new to the forums.
I know a little about DB, but I am still a noob.

Anyway, I am making an RTS. Here is the code for it:


I want to select the character with the left mouse button and move him to a different location when I click the right mouse button. To do that, though, I would have to find the coordinates of the mouse in a 3D space. Is that too hard to do with a randomized matrix? Should I be using a shape instead for the landscape?
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 16th Nov 2008 22:44 Edited at: 16th Nov 2008 22:50
Well Phaelax has a post in the code snippets on RTS. Maybe that could help you. It has a DBP and DBC 1.13 section. Here are some excerpts...





"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
Amax125
17
Years of Service
User Offline
Joined: 16th Nov 2008
Location:
Posted: 18th Nov 2008 01:51 Edited at: 2nd Dec 2008 03:42
Hmmm. I tried that, but it fails still...

See for yourself.
Amax125
17
Years of Service
User Offline
Joined: 16th Nov 2008
Location:
Posted: 23rd Dec 2008 23:45
Ok, so I decided to make this thing 2d instead. Now, I just have a problem with selection.



Basically, it is supposed to change a sprite when clicked on with the left mouse button into a sprite with the same image, only faded.
When a faded sprite is clicked on, it should turn back into the non-faded version of itself.

However, in my Mouse_Selection method, the variable SpriteHit never seems to be above 0. Is there anything I am doing that is very wrong here?
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 2nd Jan 2009 04:06
SPRITE HIT only returns when the sprite is colliding with another. If you want to figure when the player clicks the sprite, you need to use a combination of MOUSEX(), MOUSEY(), and MOUSECLICK().

Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 2nd Jan 2009 06:55
yes that should solve your problem. but also what i'v read is that sprite hit returns a 1 for a hit but then resets to 0 so a better use would be sprite collision for most other things.
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 2nd Jan 2009 19:07 Edited at: 2nd Jan 2009 23:51
@Amax125
You might want to try a CheckArea Function. This method will check if the XY position of the sprite or image you're trying to select is within a certain range.



This should allow you to select multiple sprites if you want to click and drag a box.

Here's a quick example of this method.



[edit]

You can use this with 3d as well, get the object's position using
Amax125
17
Years of Service
User Offline
Joined: 16th Nov 2008
Location:
Posted: 18th Jan 2009 16:57
Cool! Thanks for the help.
I got selection down now and have created a box whenever the user clickes and drags now.
I just didn't realize the difference between sprite hit and sprite collision before.

Login to post a reply

Server time is: 2026-07-05 01:47:39
Your offset time is: 2026-07-05 01:47:39