Spawn life/bomb fragments every 50k/20k points earned

numbers subject to change
This commit is contained in:
Andrei "Akari" Alexeyev 2017-03-25 20:18:24 +02:00
parent 31bbef7aae
commit 33cdd71be0
4 changed files with 30 additions and 6 deletions

View file

@ -113,11 +113,11 @@ void process_items(void) {
play_sound("item_generic");
break;
case Point:
global.plr.points += 100;
player_add_points(&global.plr, 100);
play_sound("item_generic");
break;
case BPoint:
global.plr.points += 1;
player_add_points(&global.plr, 1);
play_sound("item_generic");
break;
case Life:

View file

@ -435,8 +435,9 @@ void player_input_workaround(Player *plr) {
}
void player_graze(Player *plr, complex pos, int pts) {
plr->points += pts;
plr->graze++;
player_add_points(&global.plr, pts);
play_sound("graze");
int i = 0; for(i = 0; i < 5; ++i) {
@ -493,6 +494,25 @@ void player_add_bombs(Player *plr, int bombs) {
player_add_bomb_fragments(plr, PLR_MAX_BOMB_FRAGMENTS);
}
static void try_spawn_bonus_item(Player *plr, ItemType type, unsigned int oldpoints, unsigned int reqpoints) {
int items = plr->points / reqpoints - oldpoints / reqpoints;
if(items > 0) {
complex p = creal(plr->pos);
create_item(p, -5*I, type);
spawn_items(p, type, --items, NULL);
}
}
void player_add_points(Player *plr, unsigned int points) {
unsigned int old = plr->points;
plr->points += points;
try_spawn_bonus_item(plr, LifeFrag, old, PLR_SCORE_PER_LIFE_FRAG);
try_spawn_bonus_item(plr, BombFrag, old, PLR_SCORE_PER_BOMB_FRAG);
}
void player_preload(void) {
const int flags = RESF_DEFAULT;

View file

@ -23,6 +23,9 @@ enum {
PLR_START_LIVES = 2,
PLR_START_BOMBS = 3,
PLR_SCORE_PER_LIFE_FRAG = 50000,
PLR_SCORE_PER_BOMB_FRAG = 20000,
};
typedef enum {
@ -62,7 +65,7 @@ typedef struct {
short power;
int graze;
int points;
unsigned int points;
int lives;
int bombs;
@ -130,6 +133,7 @@ void player_add_life_fragments(Player *plr, int frags);
void player_add_bomb_fragments(Player *plr, int frags);
void player_add_lives(Player *plr, int lives);
void player_add_bombs(Player *plr, int bombs);
void player_add_points(Player *plr, unsigned int points);
void player_preload(void);

View file

@ -94,7 +94,7 @@ int collision_projectile(Projectile *p) {
while(e != NULL) {
if(e->hp != ENEMY_IMMUNE && cabs(e->pos - p->pos) < 15) {
global.plr.points += damage * 0.5;
player_add_points(&global.plr, damage * 0.5);
e->hp -= damage;
return 2;
}
@ -103,7 +103,7 @@ int collision_projectile(Projectile *p) {
if(global.boss && cabs(global.boss->pos - p->pos) < 42
&& global.boss->current->type != AT_Move && global.boss->current->type != AT_SurvivalSpell && global.boss->current->starttime < global.frames) {
global.plr.points += damage * 0.2;
player_add_points(&global.plr, damage * 0.2);
global.boss->dmg += damage;
return 2;
}