#include #include #include "game.h" #include "movement.h" #include "powerup.h" #include "const.h" // powerup should spawn every other difficulty band // so the first spawn should happen somewhere 10 + (20 * rand()) int determinePowerupCooldownTime(int difficulty) { if (difficulty > MAX_DIFFICULTY) exit(1); return difficulty * 10 + rand() % 20; } // if every shot lands, you should run out slightly before the next powerup // should be available // so for the first rounds should be difficulty(1) + difficulty(2) % rand() or so int determineWeaponRounds(int difficulty) { if (difficulty > MAX_DIFFICULTY) exit(1); return difficultyBands[difficulty] / 2 + rand() % (difficultyBands[difficulty] / 8); } void processPowerupCooldown( struct PlayerPowerup *playerPowerup, struct GlobalGameState *globalGameState, struct RabbitWeaponry *rabbitWeaponry, int killCount ) { if (playerPowerup->isActive) return; //if (rabbitWeaponry->currentWeapon != WEAPON_TYPE_SINGLE_SHOT_GUN) return; playerPowerup->cooldown -= killCount; if (playerPowerup->cooldown <= 0) { playerPowerup->x = TILE_SIZE + rand() % ((ARENA_WIDTH_TILES - 2) * TILE_SIZE); playerPowerup->y = TILE_SIZE + rand() % ((ARENA_HEIGHT_TILES - 2) * TILE_SIZE); playerPowerup->isActive = 1; playerPowerup->willBeInactive = 0; playerPowerup->type = rand() % 2 + 1; playerPowerup->cooldown = determinePowerupCooldownTime(globalGameState->difficulty); } }