Prevent a sprite (which follows the mouse) out of a circle?

Find quick help here to get you started with Hollywood
Post Reply
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Prevent a sprite (which follows the mouse) out of a circle?

Post by sinisrus »

Hello,

How to prevent a sprite (which follows the mouse) out of a circle?
I want a circular area bounded to a sprite
User avatar
Juan Carlos
Posts: 889
Joined: Mon Sep 06, 2010 1:02 pm

Re: Prevent a sprite (which follows the mouse) out of a circ

Post by Juan Carlos »

You have searched in the Hollywood examples
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: Prevent a sprite (which follows the mouse) out of a circ

Post by sinisrus »

Hello,

Yes I searched but did not find

do you have any idea?
User avatar
Juan Carlos
Posts: 889
Joined: Mon Sep 06, 2010 1:02 pm

Re: Prevent a sprite (which follows the mouse) out of a circ

Post by Juan Carlos »

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
User avatar
TheMartian
Posts: 109
Joined: Sun Feb 28, 2010 12:51 pm

Re: Prevent a sprite (which follows the mouse) out of a circ

Post by TheMartian »

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
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: Prevent a sprite (which follows the mouse) out of a circ

Post by sinisrus »

@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
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: Prevent a sprite (which follows the mouse) out of a circ

Post by jalih »

sinisrus wrote:@themartian
I would like to know how to have an object that rotates around a fixed axis which follow the mouse
Not sure, if I understood right...

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)
If you need to calculate point in a circle:

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
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: Prevent a sprite (which follows the mouse) out of a circ

Post by sinisrus »

@Jalih

Thank you :-)
Post Reply