diff options
Diffstat (limited to 'player.c')
-rw-r--r-- | player.c | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -178,6 +178,25 @@ void update_player_hurt(Player* p, World* w) { } } +void update_player_special(Player* p, const App* a, World* w) { + if (p->charge < player_special_hits) return; + if (!btn_just_pressed(a, btn_special)) return; + if (p->spec == special_gun) { + int sx; + Rect dz = { 0, 0, 500, 16 }; + if (p->face == face_left) + sx = (p->x >> fbits) - dz.w; + else + sx = (p->x >> fbits) + 16; + dz.x = sx; + dz.y = (p->y >> fbits); + inst_deathzone(w, &dz, 0, 0, player_gun_damage, 1, 1); + activate_laser(&w->laser, dz.x, dz.y); + w->freeze = 3; + } + p->charge = 0; +} + void update_player( Player* p, World* w, @@ -185,6 +204,7 @@ void update_player( const Map* map ) { update_player_move(p, app, w); + update_player_special(p, app, w); update_player_hurt(p, w); update_player_phys(p, map); update_player_anim(p); @@ -195,3 +215,41 @@ void ren_player(const Player* p, struct Renderer* r) { if (p->inv & 5) return; ren_map(r, p->x >> fbits, p->y >> fbits, &p->rect, b); } + +void init_laser(Laser* l) { + l->life = 0; +} + +void activate_laser(Laser* l, int x, int y) { + l->life = 10; + l->x = x; + l->y = y; +} + +void update_laser(Laser* l) { + l->life--; +} + +void ren_laser(const Laser* l, struct Renderer* r) { + const int h = 10; + const int hr = h - l->life; + const int hr2 = hr >> 1; + Rect re; + re.x = l->x; + re.y = l->y + hr2; + re.w = 500; + re.h = 10 - hr; + ren_rect(r, &re); + re.h = 1; + re.y = l->y - hr2; + ren_rect(r, &re); + re.h = 1; + re.y = l->y + h + hr2; + ren_rect(r, &re); + re.h = 1; + re.y = l->y - hr; + ren_rect(r, &re); + re.h = 1; + re.y = l->y + h + hr; + ren_rect(r, &re); +} |