Also
Die Objekte:
GlDummyCube1
hat in sich den
Kopf
hat
Kamera in sich
Code:
if IsKeyDown(VK_RIGHT) then
GLDummyCube1.TurnAngle := GLDummyCube1.TurnAngle - speedx * 10;
if IsKeyDown(VK_LEFT) then
GLDummyCube1.TurnAngle := GLDummyCube1.TurnAngle + speedx * 10;
if IsKeyDown(VK_UP) then Kopf.PitchAngle :=Kopf.PitchAngle - 1;
if IsKeyDown(VK_DOWN) then Kopf.PitchAngle := Kopf.PitchAngle + 1;
Und dann noch in die Richtung laufen
Code:
if IsKeyDown('W') then
begin
if (GLDummyCube1.TurnAngle > -90) and (GLDummyCube1.TurnAngle < 90) then
begin
GLHUDText6.Text := 'Z: Hinten';
if back_z = false then GLDummyCube1.Position.z := GLDummyCube1.Position.z - Cos(GLDummyCube1.TurnAngle * (PI / 180)) * (speedz);
end
else
begin
GLHUDText6.Text := 'Z: Vorne';
if for_z = false then GLDummyCube1.Position.z := GLDummyCube1.Position.z - Cos(GLDummyCube1.TurnAngle * (PI / 180)) * (speedz);
end;
if (GLDummyCube1.TurnAngle < 0) and (GLDummyCube1.TurnAngle > -180) then
begin
GLHUDText6.Text := GLHUDText6.Text + '; X: Vorne';
if for_x = false then GLDummyCube1.Position.X := GLDummyCube1.Position.X - Sin(GLDummyCube1.TurnAngle * (PI / 180)) * (speedx);
end
else
begin
GLHUDText6.Text := GLHUDText6.Text + '; X: Hinten';
if back_x = false then GLDummyCube1.Position.X := GLDummyCube1.Position.X - Sin(GLDummyCube1.TurnAngle * (PI / 180)) * (speedx);
end;
end;
if IsKeyDown('S') then
begin
if (GLDummyCube1.TurnAngle > -90) and (GLDummyCube1.TurnAngle < 90) then
begin
GLHUDText6.Text := 'Z: Vorne';
if for_z = false then GLDummyCube1.Position.z := GLDummyCube1.Position.z + Cos(GLDummyCube1.TurnAngle * (PI / 180)) * (speedz);
end
else
begin
GLHUDText6.Text := 'Z: Hinten';
if back_z = false then GLDummyCube1.Position.z := GLDummyCube1.Position.z + Cos(GLDummyCube1.TurnAngle * (PI / 180)) * (speedz);
end;
if (GLDummyCube1.TurnAngle < 0) and (GLDummyCube1.TurnAngle > -180) then
begin
GLHUDText6.Text := GLHUDText6.Text + '; X: Hinten';
if back_x = false then GLDummyCube1.Position.X := GLDummyCube1.Position.X + Sin(GLDummyCube1.TurnAngle * (PI / 180)) * (speedx)
end
else
begin
GLHUDText6.Text := GLHUDText6.Text + '; X: Vorne';
if for_x = false then GLDummyCube1.Position.X := GLDummyCube1.Position.X + Sin(GLDummyCube1.TurnAngle * (PI / 180)) * (speedx);
end;
end;