|
-
Jun 25th, 2000, 10:49 PM
#1
Thread Starter
New Member
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
-
Jun 26th, 2000, 12:12 AM
#2
Frenzied Member
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
NXSupport - Your one-stop source for computer help
-
Jun 26th, 2000, 02:04 AM
#3
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 26th, 2000, 04:33 AM
#4
Frenzied Member
Rotating images is hard, check out planet source code.
-
Jun 26th, 2000, 04:58 AM
#5
transcendental analytic
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.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 26th, 2000, 12:48 PM
#6
Thread Starter
New Member
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
-
Jun 26th, 2000, 03:05 PM
#7
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|