voleur/ninja.c

30 lines
692 B
C

#include "raylib.h"
#include "raymath.h"
#include "stdio.h"
Texture ninja_texture;
void load_ninja()
{
ninja_texture = LoadTexture("data/ninja.png");
}
float ninja_radius()
{
return fmax(ninja_texture.width, ninja_texture.height)/2;
}
void draw_ninja(Vector2 pos)
{
Texture n = ninja_texture;
// DrawTexture(n, pos.x - n.width/2, pos.y - n.height/2, WHITE);
Rectangle source = {0, 0, n.width, n.height};
Rectangle dest = {pos.x, pos.y, n.width, n.height};
Vector2 origin = {n.width/2, n.height/2};
float angle = -Vector2LineAngle(pos, GetMousePosition());
angle *= 180/PI;
angle += 90;
DrawTexturePro(n, source, dest, origin, angle, WHITE);
}