Skip to content

Commit

Permalink
Fix enemy spawn script in game.c
Browse files Browse the repository at this point in the history
  • Loading branch information
savaughn committed Dec 20, 2023
1 parent 7f80341 commit 54c4f7f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/screens/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int enemy_count = 0;
static bool is_level_initialized = false;
static int frame_count = 0;

static struct enemy *level1SpawnScript[MAX_FRAMES_LEVEL1];
static struct enemy level1SpawnScript[MAX_FRAMES_LEVEL1];

void init_game(void)
{
Expand All @@ -35,18 +35,18 @@ void init_game(void)
}
for (int i = 0; i < MAX_FRAMES_LEVEL1; i++)
{
level1SpawnScript[i] = &(struct enemy){.active = false};
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};
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};
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};
level1SpawnScript[i] = (struct enemy){.position = (Vector2){300, -300}, .type = BASIC, .speed = 96.0f, .active = true, .health = 1};
}
}
}
Expand Down Expand Up @@ -139,11 +139,10 @@ void draw_game_screen(const struct opts *opts, const int *selectedWidth, const i

if (frame_count < MAX_FRAMES_LEVEL1)
{
struct enemy *enemy_spawn = level1SpawnScript[frame_count];
if (enemy_spawn->active)
struct enemy enemy_spawn = level1SpawnScript[frame_count];
if (enemy_spawn.active)
{
enemies[enemy_count] = *enemy_spawn;
enemies[enemy_count].active = true;
enemies[enemy_count] = enemy_spawn;
enemy_count++;
}
frame_count++;
Expand Down

0 comments on commit 54c4f7f

Please sign in to comment.