feat: draw_enemy function
This commit is contained in:
parent
17666c232a
commit
83967090c2
20
game.c
20
game.c
|
@ -36,6 +36,13 @@ int goal_x = 5;
|
|||
int goal_y = 5;
|
||||
bool is_goal_reached = 0;
|
||||
|
||||
struct enemy {
|
||||
int x, y, attack, health;
|
||||
};
|
||||
|
||||
struct enemy enemies[20] = {0};
|
||||
size_t enemy_count = 0;
|
||||
|
||||
#define DIRECTIONS 6
|
||||
struct eye direction[DIRECTIONS] = {
|
||||
{.x = 0, .y = -1},
|
||||
|
@ -257,6 +264,14 @@ void print(struct image canvas, char *string, size_t xpos, size_t ypos, struct c
|
|||
}
|
||||
}
|
||||
|
||||
void draw_enemy(struct image canvas, int attack, int health, size_t xpos, size_t ypos) {
|
||||
char a[] = {(attack + '0'), 0};
|
||||
char h[] = {(health + '0'), 0};
|
||||
draw_glyph(canvas, (uint32_t) 0b00111011111101011111111111101010, camera_x + xpos * EYE_SIZE + 2, camera_y + ypos * EYE_SIZE + 3, (struct color) {255, 0, 0, 255});
|
||||
print(canvas, a, camera_x + xpos * EYE_SIZE + 8, camera_y + ypos * EYE_SIZE, (struct color) {255, 0, 0, 255});
|
||||
print(canvas, h, camera_x + xpos * EYE_SIZE + 8, camera_y + ypos * EYE_SIZE + 6, (struct color) {255, 0, 0, 255});
|
||||
}
|
||||
|
||||
void render(struct image canvas) {
|
||||
for (size_t i = 0; i < canvas.bufsize; i++) canvas.buf[i] = 0;
|
||||
|
||||
|
@ -273,6 +288,8 @@ void render(struct image canvas) {
|
|||
|
||||
draw_glyph(canvas, (uint32_t) 0b00011000111001100010000100011100, camera_x + goal_x * EYE_SIZE + 3, camera_y + goal_y * EYE_SIZE + 3, (struct color) {255, 255, 0, 255});
|
||||
|
||||
draw_enemy(canvas, 6, 3, 0, 3);
|
||||
|
||||
// hand
|
||||
for (size_t i = 0; i < hand_count; i++) {
|
||||
struct brick *b = &hand[i];
|
||||
|
@ -295,6 +312,9 @@ void render(struct image canvas) {
|
|||
print(canvas, "Drag Dominos from your inventory onto the chain to", 3, 2, (struct color) {255, 255, 255, 255});
|
||||
print(canvas, "reach the goal. Press [R] to rotate", 3, 9, (struct color) {255, 255, 255, 255});
|
||||
|
||||
draw_glyph(canvas, 0b00010101111111111011100010000000, 3, 20, (struct color) {255, 0, 0, 255});
|
||||
print(canvas, "10", 10, 20, (struct color) {255, 255, 255, 255});
|
||||
|
||||
if (is_goal_reached) {
|
||||
print(canvas, game_over, (canvas.width - (sizeof(game_over)-1) * 5) / 2, 20, (struct color) {255, 255, 255, 255});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue