A retro platform game
git clone git://soophie.de/freezo
blob: 3b68016a8f5d5f5cc8c2147b87fe3f049089168c (1491 bytes)[doc][blame][raw]
1
#include <stdlib.h>2
#include <math.h>4
#include "../include/boss.h"5
#include "../include/const.h"6
#include "../include/entity.h"7
#include "../include/effect.h"9
boss_t *boss_create(pos_t pos, boss_e type) {10
boss_t *boss = malloc(sizeof(boss_t));11
*boss = (boss_t) {12
.pos = pos,13
.type = type,14
.on_ground = false,15
.velocity = 0.0,16
.gravity = 0.0,17
.dir = 1,18
.stunned = false,19
.frozen = false,20
.frozen_timer = 0,21
.fall_height = 0.0,22
.timer_walking = fz_timer_create(9, 8),23
.timer_sneaking = fz_timer_create(9, 16),24
};25
return boss;26
}28
void boss_update(boss_t *boss, game_t *game) {29
(void) boss;30
(void) game;31
}33
void boss_draw(boss_t *boss, game_t *game) {34
pos_t pos = pos_snap(boss->pos);35
DrawTextureRec(game->assets.entities, texture_rect_v(10, 6, 2, 1, ENEMY_WIDTH, ENEMY_HEIGHT), pos, WHITE);36
}38
void boss_kill(boss_t *boss, game_t *game) {39
for (int i = 0; i < game->entities_len; i++) {40
if (game->entities[i].type == ENTITY_BOSS && game->entities[i].boss == boss) {41
if (i + 1 < game->entities_len) {42
for (int j = i; j < game->entities_len - 1; j++) {43
game->entities[j] = game->entities[j + 1];44
}45
}46
game->entities_len--;47
game->entities = realloc(game->entities, sizeof(entity_t) * game->entities_len);48
game->xp += 10;49
break;50
}51
}52
}54
void boss_free(boss_t *boss) {55
fz_timer_free(boss->timer_walking);56
fz_timer_free(boss->timer_sneaking);57
free(boss);58
}