-
Hail VB'ers
I need som help. I writing a game. And i need the player to Face the direction that the mousecursor is in. Its just a 2D tile based game. Really simple. Could someone email me the code that enables me to do this. I know its not simple, but i know that others of you would of had the same problem, and i'm asking if you could help me out.
Sending your reply to my Email address is preferable. But i don't really mind. JUST HELP ME!!
Thanks.
--------------
Rowie
-
I have a basic Idea, I'm just not sure of the exact code!!!
you could make it that the program finds where the person (or object) in the game is. Then it could fiqure out that if the x coordinates of the mouse are from one range to another the person (object) looks one way
-
well, this might help:
Code:
'| <- mouse pointer here
' |
' |
' |
' |
player -> X---------|
1: Find the offset of the pointer from the player
x = Abs(pointer.x - player.x)
y = Abs(pointer.y - player.y)
2: You will now have an x-offset, and a y-offset
then to find the angle: ArcTan(y / x)
3: Rotate the image of the player through that angle.
(I don't know how to do this, but it is fairly easy with DX and I'm sure there's a tutorial on rotating bitmaps.
-
Rotating images is hard, check out planet source code.
-
I would recommend not to use rotating image procedures since they drain a lot of performance, instead rotate them manually with paintshop or photoshop,and load them into an array or imagelist or put them in a res file.
-
Hail,
Thanks for your replies. I've already got the basic idea. But it would be easier if someone had the code already.
Once again - thanks!
---------------
Rowie
-
I think if you use mine, but round the angle to the nearest pi/6 radians or something like that, then load the image from an imagelist, it should speed it up quite a bit.