Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
1 |
Richtungsvektor(cos(alpha), cos(alpha)) |
Phili
unregistriert
Quellcode |
|
1 |
sin(alpha + pi/2) = cos(alpha) |
Zitat
Richtungsvektor(cos(alpha), sin(alpha+1.670796f))
Quellcode |
|
1 |
Richtungsvektor(cos(alpha), cos(alpha)) |
Phili
unregistriert
Quellcode |
|
1 |
sin(alpha + pi/2) = cos(alpha) |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
class CAuto { public: static const float MAX_SPEED = 20.0f; // Speed in EpS (Einheit pro Sekunde) static const float MAX_ACCEL = 0.5f; // Maximale Beschleunigung static const float TURN_SPEED = PI / 5.0f; // 10 Sekunden für komplette Rotation Vec2d _direction (0.0f, 1.0f); // Start in Richtung y Vec2d _location (0.0f, 0.0f); // Start im Ursprung float _speed = 0.0f; // Aktuelle Geschwindingkeit void Move (float time) { _location += time * _speed * _direction; } void OnTurnLeft (float time) { float angle = TURN_SPEED * time; _direction = MatrixRotate2d (-angle) * _direction; } void OnTurnRight (float time) { float angle = TURN_SPEED * time; _direction = MatrixRotate2d (angle) * _direction; } void OnAccelerate (float time) { _speed = min (MAX_SPEED, _speed + time * MAX_ACCEL); } void OnDecelerate (float time) { _speed = max (-MAX_SPEED, _speed - time * MAX_ACCEL); } void OnNeutralGas (float time) { if (_speed < 0.0f) { OnAccelerate (time); _speed = min (0.0f, _speed); } else { OnDecelerate (time); _speed = max (0.0f, _speed); } } }; MatrixRotate2d (angle) { // Rotation im Uhrzeigersinn mit Winkel "angle", Indices [x][y] _m[0][0] = cos (angle); _m[1][0] = sin (angle); _m[0][1] = -sin (angle); _m[1][1] = cos (angle); } |
Zitat von »"spacegaier"«
Was ist time? Die Zeit, die seit dem letzten Frame vergagngen ist (also GetLastTickCount)?
Zitat
Und gibt es Vektor als Typ in WinApi und ist das oben nur in Verbindung mit D9) möglich?
Werbeanzeige