various fixes and formatting tweaks
This commit is contained in:
parent
1cd7027256
commit
4cae195763
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
#include <math.h>
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
|
|
@ -68,9 +69,15 @@ int main(void)
|
|||
}
|
||||
|
||||
// Reset frame index to zero on overflow
|
||||
if (anim >= 4)
|
||||
if (anim >= 4) anim = 0;
|
||||
|
||||
// Find the current direction frame based on the camera position to the billboard object
|
||||
float dir = (float)floor(((Vector2Angle((Vector2){ 2.0f, 0.0f }, (Vector2){ camera.position.x, camera.position.z })/PI)*4.0f) + 0.25f);
|
||||
|
||||
// Correct frame index if angle is negative
|
||||
if (dir < 0.0f)
|
||||
{
|
||||
anim = 0;
|
||||
dir = 8.0f - (float)abs((int)dir);
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -84,15 +91,6 @@ int main(void)
|
|||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
// Find the current direction frame based on the camera position to the billboard object
|
||||
float dir = (float)floor(((Vector2Angle((Vector2){ 2.0f, 0.0f }, (Vector2){ camera.position.x, camera.position.z })/PI)*4.0f) + 0.25f);
|
||||
|
||||
// Correct frame index if angle is negative
|
||||
if (dir < 0.0f)
|
||||
{
|
||||
dir = 8.0f - (float)abs((int)dir);
|
||||
}
|
||||
|
||||
// Draw billboard pointing straight up to the sky, rotated relative to the camera and offset from the bottom
|
||||
DrawBillboardPro(camera, skillbot, (Rectangle){ 0.0f + (anim*24.0f), 0.0f + (dir*24.0f), 24.0f, 24.0f }, Vector3Zero(), (Vector3){ 0.0f, 1.0f, 0.0f }, Vector2One(), (Vector2){ 0.5f, 0.0f }, 0, WHITE);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user