Jump to content

  • Log In with Google      Sign In   
  • Create Account

Cruis.In

Member Since 02 Jan 2013
Offline Last Active Jul 05 2013 11:06 AM

Topics I've Started

help with firing arcs

02 January 2013 - 09:45 AM

hey guys I am fiddling with learning by making asteroids type space game and such. It is 2d.

 

In this I have the 'view' fixed on the playership at the centre of the screen.

 

I want to calculate constantly the arc seen in the image below which is directly ahead of the ship. This would be a frontal firing arc. http://imageshack.us/photo/my-images/593/arcx.png/

 

This is where I am stumped. Having gone through so many maths lessons the past few days on py theorem etc...

 

Your ship rotates based on an angle based on your left/right input via kieyboard. So I know what direction the ship is facing in terms of a bearing. That value is held in the variable 'angle'.

 

Of course I know where my ship XY is, and I know where enemy ships XY are. I've used atan2 and I have calculated the bearing or angle of the enemy ship from my ship. But this won't help to create a fixed firing 'arc' in front of my player ship.

 

Basically I need a formula or calculation to calculate that tangent as seen in the picture, no matter what direction I am facing or where I am. So the value of that 'area' in front of the ship always remains constant which means it is my frontal firing arc. Let's say a value of about 60 degrees. So quite a narrow firing arc.

 

I know how to check if a potential target is within said firing arc before being allowed to fire, but determining that arc in front my ship is giving me measles.


Can anyone shed some light?

 

thanks


PARTNERS