Skip to main content
gamedev.net
🔒 Locked

Question on Object Selection

Started by cb007sax 0 replies 200+ views
Original Post
cb007sax
cb007sax
Okay, basically I am kind of at in a point in my 2d isometric engine where i am doing sprite selection (really far huh? ) As in, i can target other enemies and stuff and click on them, also click on things on the ground such as items. Now correct me if i''m wrong, but is this the best way to go about this. Just have an array pointing to all clickable objects on the screen, and then having a for loop go through each object and seeing if my mouse is on one of the objects... That seems the best way to do it... Also, can anyone tell me, or link me to a tutorial on how to get cursor direction from cursor position? I have 6 directions, Up, down, left, right, UpRight Diagonal, DownRight Diagonal, UpLeft Diagonal, and DownLeft Diagonal. From a cursor point on the screen in x,y format, is there an algorithm to find which direction it is facing? Thanks
MSW
MSW
quote:

Also, can anyone tell me, or link me to a tutorial on how to get cursor direction from cursor position? I have 6 directions, Up, down, left, right, UpRight Diagonal, DownRight Diagonal, UpLeft Diagonal, and DownLeft Diagonal. From a cursor point on the screen in x,y format, is there an algorithm to find which direction it is facing? Thanks



???

the Direction of one object is relitive to other objects...to get the "curser direction" from the position it has onscreen...you need some way to compare it''s posistion with another object or arbitrary location (screen center, player character, nearest door tile, etc..)...

once you have the curser test it''s location with another location, you can find the angle (0-359), then integer divide by 60 to give you a number between 0 and 5 to corisspond to the indicated direction...there are lots of other ways to do this as well...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.