Hey there, for first - sorry for my english, I'm from Belarus. For second - I have an idea of a canabalt-like side-scroll game but with some shooter elements in it, so, it will be about a cowboy... aaaaaand that's all for now. How can it be realized, that arms of cowboy turns with mouse cursor (pistols in both hands kinda looking at the mouse cursor in any time)
Turning arms with mouse cursor
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 5
- Joined: Sat Sep 22, 2012 9:51 pm
- Location: Belarus, Minsk
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Turning arms with mouse cursor
Welcome!
How do you want the arms to turn? Completely or just left/right? If you want the first, you can use trigonometry to calculate the angle between your cowboy and the cursor. If the latter, you just have to check which x-coordinate is larger: the cursor's or the cowboy's.
Good luck, and keep asking questions if something's not clear.
How do you want the arms to turn? Completely or just left/right? If you want the first, you can use trigonometry to calculate the angle between your cowboy and the cursor. If the latter, you just have to check which x-coordinate is larger: the cursor's or the cowboy's.
Good luck, and keep asking questions if something's not clear.
Help us help you: attach a .love.
-
- Prole
- Posts: 5
- Joined: Sat Sep 22, 2012 9:51 pm
- Location: Belarus, Minsk
Re: Turning arms with mouse cursor
Thank you!
The axis of rotation in the forearm, hands, ideally, should describe the sector of the circle. Picture realated.
The axis of rotation in the forearm, hands, ideally, should describe the sector of the circle. Picture realated.
Re: Turning arms with mouse cursor
Then it's the first of Robin's solutions, with a "cap" to the angle (math.min and math.max, or a simple "if angle >= x then...")
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
-
- Prole
- Posts: 5
- Joined: Sat Sep 22, 2012 9:51 pm
- Location: Belarus, Minsk
Re: Turning arms with mouse cursor
Yeah, thanx, but...umghh, stupid question - how to make arms rotatable, should I use animation lib for it?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Turning arms with mouse cursor
I think -- but I might be wrong -- that what would be easiest would be to make all images of the cowboy without arms and then draw the arms separately.
You could use an animation library, but you don't have to, necessarily.
You could use an animation library, but you don't have to, necessarily.
Help us help you: attach a .love.
-
- Prole
- Posts: 5
- Joined: Sat Sep 22, 2012 9:51 pm
- Location: Belarus, Minsk
Re: Turning arms with mouse cursor
Yep, I thought about this variant too, but I don't know yet, how to make cowboy jump not separately with his hands in this case.
Re: Turning arms with mouse cursor
You'll just want to move the cowboy and his arms at the same time. The simplest way would be to move the cowboy and his arms at the same velocity -- so if the cowboy moves 5 horizontally and 5 vertically, so would his arms and they'd be together. But there are other ways to accomplish this depending on the effect you want. For example, you could keep the cowboy in the center of the screen and move all of the world around him instead of him -- then you don't have to worry about moving them together.
With Love2d, you've got complete control.
With Love2d, you've got complete control.
-
- Prole
- Posts: 5
- Joined: Sat Sep 22, 2012 9:51 pm
- Location: Belarus, Minsk
Re: Turning arms with mouse cursor
Thanx, I think now I have direction to work in.
Re: Turning arms with mouse cursor
You inspired me to make something for my son who is going through a cowboy phase. A little broken now, but you can see it here.
Who is online
Users browsing this forum: No registered users and 2 guests