The Daily Click ::. Forums ::. Klik Coding Help ::. Help with Shell Arc
 

Post Reply  Post Oekaki 
 

Posted By Message

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
26th March, 2008 at 18:28:03 -

I am making a game in which you control a tank which fires shells. problem is i dont want the shells to gos straight all the time as that would never actually happen. i want to add a small arc into their flight paths so that it looks slightly more realistic. the cannon itself has 180 degree shooting from left over the top to right.

One other side note: i am controlling the targt area for the shells with the mouse but i want to limit the mouse to being able to go a certain distance towards and away from the tank. make sense???

 
n/a

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
26th March, 2008 at 18:45:05 -

http://create-games.com/forum_post.asp?id=216169&show=all#post_216186

As for limiting mouse movement, distance between 2 objects
A(x1,y1) B(x2,y2)

Distance = square root((X1 - X2)˛ + (Y1-Y2)˛)

and if you want to limit it to "R" pixels,
compare when this distance is > than your required length, and if it is use these on the cursor

X position = XPos of tank + (R * cos(A))
Y position = Ypos of tank - (R * sin(A)) (or could be +, not sure)
where A is the current angle between the objects.

This (provided MMF/whatever is decent with angles) should make it so it follows a circular path around the object as you move the mouse (you'll obviously have to create a work around so that it stays on the same radial line as the actual mouse cursor i.e the mouse cursor, crosshair object, and centre of the limited circle are all on the same invisible line)

 
My signature is never too big!!!

SoldjahBoy



Registered
  25/10/2006
Points
  100
27th March, 2008 at 03:57:35 -

Wow some of you guys know the formula for everything...I was always crap at mathematics, but I love to make graphics and have lots of great ideas... but I always get stuck on the maths. I bet it's the opposite for you guys... love the maths, but probably can't draw too well? I'd trade with you any day!

 
What's wrong with pillow shading? O.o

wizkidweb



Registered
  11/12/2007
Points
  143
31st March, 2008 at 18:28:28 -

You could also use the Move by Bézier object.

 
When you do things right, people won't be sure you've done anything at all.
- God (Futurama)
   

Post Reply



 



Advertisement

Worth A Click