Hi
I was wondering how I could get my image to follow my mouse.
Like have the front of the image always looking at the mouse on the screen.
Just a quick question thanks ahead of time.
Rotating image to follow mouse.
Re: Rotating image to follow mouse.
You mean that you want a fixed image to rotate to always be "pointing" at the mouse?
Now posting IN STEREO (where available)
Re: Rotating image to follow mouse.
Sort of... I have a image that moves with W,A,S,D, and I want the... err front so to say to always look at the mouse.
If you dont know what i mean, Im making a top down shooter, and I need to be able to aim haha.
If you dont know what i mean, Im making a top down shooter, and I need to be able to aim haha.
Re: Rotating image to follow mouse.
I guess you mean like a top down shooter huh?
I was gonna throw my functions your way and let you figure it out, But im feeling kind today so i made you a demo instead
Have fun
-Forgot to mention: Controls are Arrow keys to move character and mouse click for flamethrower and i apologise for using a jpg, as i stole the image from Google images
I was gonna throw my functions your way and let you figure it out, But im feeling kind today so i made you a demo instead
Have fun
-Forgot to mention: Controls are Arrow keys to move character and mouse click for flamethrower and i apologise for using a jpg, as i stole the image from Google images
- Attachments
-
- topdown.love
- (16.12 KiB) Downloaded 403 times
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Rotating image to follow mouse.
@mikembley: Nice example, though there are some things that could be done better (game-wise, but you're not making a game anyway).
Re: Rotating image to follow mouse.
Haha that is a pretty nifty example, and yes thats exactly what I want to do . But mind telling me how to look at the script haha
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Rotating image to follow mouse.
A .love is a renamed zip, so you can just open it with your zip program, or you can rename it and then open it.
Re: Rotating image to follow mouse.
Ah yes. Thanks haha. Now I just need to find were the code is that rotates the img.
EDIT:
would this be it
EDIT:
would this be it
Code: Select all
player.direction = point_direction( player.x, player.y, love.mouse.getX(), love.mouse.getY() )
Re: Rotating image to follow mouse.
That indeed would be it. point_direction is a function that returns the angle between two points
Re: Rotating image to follow mouse.
So would I use this same method to make the guy shoot? haha. Like I want a actual bullet that travels in a fixed direction, not your flamethrower example
Who is online
Users browsing this forum: No registered users and 3 guests