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.

Newcomers DBPro Corner / Rotating directional mouse cursor question

Author
Message
Lost Dragon
14
Years of Service
User Offline
Joined: 22nd Aug 2010
Location:
Posted: 15th Jan 2011 06:13 Edited at: 15th Jan 2011 06:14
I saw some code here.

That thread is too old to post on now.

I was reminded of Ultima 6 and 7, where the mouse cursor would rotate around the character, changing directions depending on how it was oriented on screen.

I hacked this out of it.

But I wonder if there is a better way? I do not understand the math in the function (math is not my thing) and atan produces 3 sets of 0 values, two of which have to be taken care of by extra code (otherwise the sprite mouse cursor shows "north" even though it's west or east of the character).

I've already done the best I know to do.

Graphics are attached.

Attachments

Login to view attachments
luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 15th Jan 2011 13:22
What's the problem here?It isn't accurate enough or simply not fast enough?

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 15th Jan 2011 15:45
Use rotate sprite. Here is how I would do it:


I simply use the arrow that faces north and rotate it based upon the angle. Hope this helps.

LB

Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 15th Jan 2011 16:01
I was just going to suggest that, LBFN. This is definitely the best way - use a single sprite and rotate it based on the angle.
Lost Dragon
14
Years of Service
User Offline
Joined: 22nd Aug 2010
Location:
Posted: 15th Jan 2011 19:40
Luskos: It was okay, I just wondered if there was a better way. Specifically I didn't understand the math in the function so I thought I'd ask.

LBFN: I like that improvement. Manually drawing arrows in 8 directions was pain! I also like that changing the arrow from inward facing to outward facing is as easy as swapping n.png or s.png.

Thanks all!
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 15th Jan 2011 19:49
That function basically does the same thing as ATANFULL, just so you know.

Login to post a reply

Server time is: 2024-09-29 00:21:05
Your offset time is: 2024-09-29 00:21:05