Skip to content

Commit

Permalink
fixed uint8 for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
savaughn committed Dec 20, 2023
1 parent b7b8dc1 commit f1d6d05
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
15 changes: 5 additions & 10 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#define MAX_FRAMES_LEVEL1 200

typedef unsigned char uint8;

enum player_action
{
NONE = -1,
Expand All @@ -32,10 +34,10 @@ struct enemy
Vector2 position;
float speed;
bool active;
u_int8_t health;
uint8 health;
bool hit;
enum enemy_type type;
u_int8_t hitbox_r;
uint8 hitbox_r;
};

static struct enemy basic_enemy = {
Expand Down Expand Up @@ -64,7 +66,7 @@ struct player
Vector2 velocity;
int bullet_count;
struct bullet bullets[MAX_BULLETS];
u_int8_t hitbox_r;
uint8 hitbox_r;
};

struct opts
Expand All @@ -87,13 +89,6 @@ struct enemy_spawn_info
enum enemy_type type;
};

static struct enemy *level1SpawnScript[MAX_FRAMES_LEVEL1] = {
[0 ... 199] = &(struct enemy){.active = false},
[60] = &(struct enemy){.position = (Vector2){100, -100}, .type = BASIC, .speed = 96.0f, .active = true, .health = 1},
[120] = &(struct enemy){.position = (Vector2){200, -200}, .type = BASIC, .speed = 96.0f, .active = true, .health = 1},
[180] = &(struct enemy){.position = (Vector2){300, -300}, .type = BASIC, .speed = 96.0f, .active = true, .health = 1},
};

static struct bullet common_bullet = {
.position = (Vector2){0, 0},
.speed = 800.0f,
Expand Down
18 changes: 18 additions & 0 deletions src/screens/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ static int enemy_count = 0;
static bool is_level_initialized = false;
static int frame_count = 0;

static struct enemy *level1SpawnScript[MAX_FRAMES_LEVEL1];

void init_game(void)
{
for (int i = 0; i < MAX_BULLETS; i++)
Expand All @@ -31,6 +33,22 @@ void init_game(void)
.position = (Vector2){0, 0},
.hitbox_r = 12};
}
for (int i = 0; i < MAX_FRAMES_LEVEL1; i++)
{
level1SpawnScript[i] = &(struct enemy){.active = false};
if (i == 60)
{
level1SpawnScript[i] = &(struct enemy){.position = (Vector2){100, -100}, .type = BASIC, .speed = 96.0f, .active = true, .health = 1};
}
if (i == 120)
{
level1SpawnScript[i] = &(struct enemy){.position = (Vector2){200, -200}, .type = BASIC, .speed = 96.0f, .active = true, .health = 1};
}
if (i == 180)
{
level1SpawnScript[i] = &(struct enemy){.position = (Vector2){300, -300}, .type = BASIC, .speed = 96.0f, .active = true, .health = 1};
}
}
}

void draw_game_screen(const struct opts *opts, const int *selectedWidth, const int *selectedHeight, const RenderTexture2D *target, const Shader *shader, const Camera2D *camera)
Expand Down

0 comments on commit f1d6d05

Please sign in to comment.