## sorry

Posted by
December 18th, 2010 10:15 am

I had a bunch of problems with the maths of my game that I really cant solve at the moment, so I am quitting.

### 9 Responses to “sorry”

Share the problem, maybe we can help

• alfie275 says:

Basically it was a problem with:
A)Rotating the ship relative to its current rotation
B)Making the ship go forwards relative to its rotation

And I’ve spent like all my time on this problem, I dont think I could get any gameplay intime.

It’s simple trigonometry.

in pseudocode:

int ship_angle
int ship_speed
int ship_x
int ship_y
if key_left then ship_angle–
if key_right then ship_angle++
if key_forward then
ship_x+=cos(ship_angle)*ship_speed
ship_y+=sin(ship_angle)*ship_speed
end if

3. alfie275 says:

No, in 3d. See the problem?

All that is necessary is a small adjustment.

Given X is side-to-side, Y is height, and Z is depth

int ship_pitch
int ship_yaw
//only two axes are necessary. disregard roll.
int ship_speed
int ship_x
int ship_y
int ship_z
if key_left then ship_yaw–-
if key_right then ship_yaw++
if key_up then ship_pitch–
if key_down then ship_pitch++
if key_forward then
ship_x+=cos(ship_yaw)*ship_speed
ship_z+=(sin(ship_yaw)+cos(ship_pitch))*ship_speed
ship_y+=sin(ship_pitch)*ship_speed
end if

I haven’t dealt with 3D trig in a while, so I might have one or two things off by a bit, but that’s the idea.

5. alfie275 says:

The actual axis change depending on the rotation of the ship.

I’m afraid I don’t understand what you’re trying to say.

7. alfie275 says:

I mean, if you roll the pitch becomes yaw.