fixing sprites idk...
This commit is contained in:
parent
b1230534c5
commit
9f616e196c
3 changed files with 43 additions and 13 deletions
|
@ -37,7 +37,24 @@ void UpdateSpriteAnimation(SpriteAnimation self, float dt) {
|
|||
}
|
||||
|
||||
void DrawSpriteAnimation(SpriteAnimation spriteAnimation, Vector2 position) {
|
||||
Vector2 drawpos = Vector2Add(position, Vector2Scale(spriteAnimation->size, 2.f));
|
||||
#ifdef _DEBUG
|
||||
DrawCircleV(position, 5, DARKGREEN);
|
||||
#endif
|
||||
Rectangle destination = (Rectangle){
|
||||
0,
|
||||
0,
|
||||
spriteAnimation->size.x * spriteAnimation->scale,
|
||||
spriteAnimation->size.y * spriteAnimation->scale
|
||||
} ;
|
||||
|
||||
Vector2 origin = (Vector2){
|
||||
.x = position.x + destination.width/2.f,
|
||||
.y = position.y + destination.height/2.f
|
||||
};
|
||||
#ifdef _DEBUG
|
||||
DrawCircleV(origin, 5, RED);
|
||||
#endif
|
||||
|
||||
DrawTexturePro(
|
||||
spriteAnimation->texture,
|
||||
(Rectangle){
|
||||
|
@ -46,16 +63,14 @@ void DrawSpriteAnimation(SpriteAnimation spriteAnimation, Vector2 position) {
|
|||
spriteAnimation->sourceRect.width,
|
||||
spriteAnimation->sourceRect.height
|
||||
},
|
||||
(Rectangle){
|
||||
position.x,
|
||||
position.y,
|
||||
spriteAnimation->size.x * spriteAnimation->scale,
|
||||
spriteAnimation->size.y * spriteAnimation->scale
|
||||
},
|
||||
position,
|
||||
destination,
|
||||
origin,
|
||||
spriteAnimation->rotation,
|
||||
WHITE
|
||||
);
|
||||
#ifdef _DEBUG
|
||||
DrawRectangleLinesEx(destination, 2, BLACK);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DestroySpriteAnimation(SpriteAnimation spriteAnimation)
|
||||
|
|
BIN
assets/karl-heinz_head.png
Normal file
BIN
assets/karl-heinz_head.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
23
src/main.c
23
src/main.c
|
@ -20,24 +20,39 @@ int main(int argc, char** argv)
|
|||
{
|
||||
InitWindow(900, 600, "Colysis");
|
||||
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_UNDECORATED);
|
||||
Texture2D gery = LoadTexture(ASSETS_PATH "/gery_hand.png");
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||
Texture2D gery = LoadTexture(ASSETS_PATH "/karl-heinz_head.png");
|
||||
|
||||
SpriteAnimation geryanim = CreateSpriteAnimation(gery, (Vector2){64*5,64}, (Vector2){64,64}, 0.f, 1.f, 5, 0.2f);
|
||||
SpriteAnimation geryanim = CreateSpriteAnimation(gery, (Vector2){64*14,64}, (Vector2){64,64}, 0.f, 4.f, 5, 0.15f);
|
||||
|
||||
Camera2D camera = { 0 };
|
||||
camera.target = (Vector2){0,0};
|
||||
camera.offset = (Vector2){GetScreenWidth()/2.f,GetScreenHeight()/2.f};
|
||||
camera.rotation = 0.f;
|
||||
camera.zoom = 1.f;
|
||||
|
||||
while (!WindowShouldClose()) {
|
||||
ClearBackground((Color){ 0x00, 0x6d, 0xfb });
|
||||
float dt = GetFrameTime();
|
||||
|
||||
|
||||
|
||||
UpdateSpriteAnimation(geryanim, dt);
|
||||
|
||||
|
||||
BeginDrawing();
|
||||
{
|
||||
BeginMode2D(camera);
|
||||
{
|
||||
DrawSpriteAnimation(geryanim, (Vector2){0,0});
|
||||
|
||||
}
|
||||
EndMode2D();
|
||||
|
||||
{
|
||||
DrawTextFull(GetFontDefault(), "Darling, I'm Home!", (Vector2){20,20}, TEXT_ORIENTATION_RIGHT, 0, 24, 5, 5, RAYWHITE);
|
||||
|
||||
DrawSpriteAnimation(geryanim, (Vector2){GetScreenWidth()/2.f, GetScreenHeight()/2.f});
|
||||
}
|
||||
}
|
||||
|
||||
EndDrawing();
|
||||
|
|
Loading…
Reference in a new issue