static void spawnEnemies(void)
{
Entity *enemy;
if (--enemySpawnTimer <= 0)
{
enemy = malloc(sizeof(Entity));
memset(enemy, 0, sizeof(Entity));
stage.fighterTail->next = enemy;
stage.fighterTail = enemy;
enemy->x = SCREEN_WIDTH;
enemy->y = rand() % SCREEN_HEIGHT;
enemy->texture = enemyTexture;
SDL_QueryTexture(enemy->texture, NULL, NULL, &enemy->w, &enemy->h);
enemy->dx = -(2 + (rand() % 4));
enemySpawnTimer = 30 + (rand() % 60);
}
}
This is the code that i have and i tried using new insted of malloc but it doesnt seem to work i tried now vector but it didnt work. https://github.com/brandonto/sdl-space-shooter.git this is a link to the code i have at the moment