move/rotate paradox
in
Programming Questions
•
2 years ago
Encountering a problem with the ordering of pushing and poping matrices.
I'm trying to re-create the movement of the ship from asteroids. I was trying to make it so it moves along the Y axis with easing, and seeing as the rotate function is awesome, steering will be handled by rotating the axis. However here in lies the problem. I need to move the rotation point with the image of the ship, however for it to move in the right direction it needs to be rotated, but I need the move to move the rotation point.......
- Is there a work around for this? or do I need to wide it and start again.
Just quickly here is the movement of the ship:
class pShip
{
int xPone, yPone, xPtwo, yPtwo, xPthree, yPthree;
float mover, rotateControl, posY;
float multiplier = .1;
pShip(int _xPone, int _yPone, int _xPtwo, int _yPtwo, int _xPthree, int _yPthree)
{
xPone = _xPone;
yPone = _yPone;
xPtwo = _xPtwo;
yPtwo = _yPtwo;
xPthree = _xPthree;
yPthree = _yPthree;
}
void draw_pShip()
{ - translate x, y by width/2 & hightt/2
- move drawing
- transate by yPone and set rotation to //rotate(rotationControl);
- translate/pop back -yPone
draw triangle
}
void control_pShip()
{
if (key == 'w')
{
multiplier = multiplier + (multiplier*.5);
mover = multiplier;
mover = constrain(mover, 0, 10);
println(+mover);
}
else
{
multiplier = multiplier - (multiplier*.5);
mover = multiplier;
mover = constrain(mover, 0, 10);
}
if (key == 'd')
{
rotateControl = rotateControl + PI/10;
}
if (key == 'a')
{
rotateControl = rotateControl - PI/10;
}
}
}
Problem encountered is it either rotates and only moves off the top of the screen or it moves onlong the rotated axis but when a rotation is required it jumps because the rotation point hasn't moved.
-thanks
-thanks
(I know my easing is wrong, I am making a key array to sort this)
1