tank game, rotation & direction/angle, with Raylib C
E16 A
0:00 / 0:00
tank game, rotation & direction/angle, with Raylib C
26 просмотров · 13 дней назад
E16 A
1 подписчик
26 просмотров · 13 дней назад
Rotated rectangle drawing is done by "DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color);".
Rotation and how it relates to the object's position is a sort of "black box" for me at the moment.
Direction/Angle described and translated between degree, radian, normalized vector, vector.
vector ---(Pythagorean theorem, a^2+b^2=c^2, a/c, b/c, vector scaled to a unit of magnitude/length_of_hypotenus)--- normalized vector ---(cosf(angle), sinf(angle))--- degree ---(multiplying by PI/180, 180/PI)--- radian (a unit = the radius, PI = ratio between circumference and half a circle).
magnitude/speed is set to 1 for both rotation and movement.
rotation variable
tank rotates.
turret rotates with tank and without tank.
bullet rotates with turret.
position/movement variable
bullet moves to the tip of the rotated turret.
bullet moves in the turret's rotated direction.
tank moves forward and backward in the rotated direction.