add texture player

This commit is contained in:
_N3m0 2024-03-20 12:21:21 +01:00
parent a9b20ba754
commit 5d7756fa16
4 changed files with 13 additions and 3 deletions

View File

@ -1,10 +1,10 @@
$(shell mkdir -p build)
all:
gcc main.c -o build/main -lraylib -lm
gcc -Wall -Wextra main.c -o build/main -lraylib -lm
release:
gcc -O3 -DRELEASE main.c -o build/main -lraylib -m
gcc -Wall -Wextra -O3 -DRELEASE main.c -o build/main -lraylib -m
run: all
./build/main

BIN
data/player.aseprite Normal file

Binary file not shown.

BIN
data/player.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 B

12
main.c
View File

@ -46,6 +46,7 @@ Rectangle trap = {
.height = trap_len,
};
Texture player_t;
Vec2i player;
const int player_radius = 25;
const int player_speed = 5;
@ -171,6 +172,8 @@ void move_map(Vector2 *map, Cardinal direction, const int speed, const float DT)
map->y -= diag_step;
map->x += diag_step;
break;
default:
break;
}
}
@ -182,6 +185,7 @@ int main(void)
SetTargetFPS(60);
player = (Vec2i) {.x = screen.width/2, .y = screen.height/2};
player_t = LoadTexture("data/player.png");
map = LoadTexture("data/map2.png");
map_coord = (Vector2){
screen.width/2 - map.width*map_factor/2,
@ -205,7 +209,13 @@ int main(void)
}
DrawTextureEx(map, map_coord, 0.0f, map_factor, WHITE);
DrawCircle(player.x, player.y, player_radius, BLUE);
DrawTexture(
player_t,
player.x-player_t.width/2,
player.y-player_t.height/2,
WHITE
);
// DrawRectangleLinesEx(trap, 1, RED);
}
EndDrawing();