Hello,
How to prevent a sprite (which follows the mouse) out of a circle?
I want a circular area bounded to a sprite
Prevent a sprite (which follows the mouse) out of a circle?
- Juan Carlos
- Posts: 891
- Joined: Mon Sep 06, 2010 1:02 pm
Re: Prevent a sprite (which follows the mouse) out of a circ
You have searched in the Hollywood examples
Re: Prevent a sprite (which follows the mouse) out of a circ
Hello,
Yes I searched but did not find
do you have any idea?
Yes I searched but did not find
do you have any idea?
- Juan Carlos
- Posts: 891
- Joined: Mon Sep 06, 2010 1:02 pm
Re: Prevent a sprite (which follows the mouse) out of a circ
No because I know the problem because I though made a sniper game with the mouse pointer and the gun point of view but web have no so good examples and I think that in this forum we are ten members with problems to make routines and convert from other language is imposible Hollywood has diferent sintaxis of java or C
- TheMartian
- Posts: 109
- Joined: Sun Feb 28, 2010 12:51 pm
Re: Prevent a sprite (which follows the mouse) out of a circ
Hi
Just a thought... May be you can sort of reverse the problem and create a bigger circular sprite as a sort of zone. If they collide - you are inside the zone and all is well. I guess it should work though I haven't tried. It has the advantage that the 'zone' sprite can be moved around easily if that is required
regards
Jesper
Just a thought... May be you can sort of reverse the problem and create a bigger circular sprite as a sort of zone. If they collide - you are inside the zone and all is well. I guess it should work though I haven't tried. It has the advantage that the 'zone' sprite can be moved around easily if that is required
regards
Jesper
Re: Prevent a sprite (which follows the mouse) out of a circ
@themartian
yes it works but it is not perfect
I would like to know how to have an object that rotates around a fixed axis which follow the mouse
yes it works but it is not perfect
I would like to know how to have an object that rotates around a fixed axis which follow the mouse
Re: Prevent a sprite (which follows the mouse) out of a circ
Not sure, if I understood right...sinisrus wrote:@themartian
I would like to know how to have an object that rotates around a fixed axis which follow the mouse
If you need to calculate the angle in a circle (useful, if you want to rotate object towards mouse pointer):
Code: Select all
x1, y1 ; Center point of the circle
x2, y2 ; Mouse pointer coords
; Calculate angle in radians. Remember to convert to degrees, if needed.
angle = Atan2(y2 - y1, x2 - x1)
Code: Select all
angle ; angle in radians
r ; radius
x1, y1 ; Center point of a circle
x1, y2 ; Point in a circle
; Calculate point in a circle
x2 = x1 + Cos(angle) * r
y2 = y1 - Sin(angle) * r
Re: Prevent a sprite (which follows the mouse) out of a circ
@Jalih
Thank you
Thank you