Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Alien/Alien.cpp
- Revision:
- 18:828e9f6ddfdb
- Parent:
- 17:8b1d16d56ad2
- Child:
- 19:43de9fd725ba
--- a/Alien/Alien.cpp Fri May 01 14:24:20 2020 +0000 +++ b/Alien/Alien.cpp Fri May 01 14:44:08 2020 +0000 @@ -10,11 +10,14 @@ Y = y; Size = size; Speed = 1; + alien_bullet_vector.init(); + } void Alien::render(N5110 &lcd) { if(Alive == true){ lcd.drawRect(X, Y, Size, Size, FILL_BLACK); + alien_bullet_vector.render(lcd); } } @@ -23,8 +26,9 @@ return p; } -void Alien::update(int step_x, int remainder_x, Gamepad &pad) { +void Alien::update(int step_x, int remainder_x, Gamepad &pad, int counter) { X+=Speed; + int c = counter; int _step_x = step_x; int _remainder_x = remainder_x; if (X < 1 + _remainder_x*_step_x) { @@ -37,6 +41,9 @@ Speed = -Speed; Y = Y + 2; } + flag_set(c); + alien_bullet_vector.update(X,Y,Shoot); + Shoot = false; } void Alien::set_life(bool x){ @@ -48,3 +55,11 @@ return x; } +void Alien::flag_set(int counter){ + int c = counter; + + if(c%7 == 1){ + Shoot = true; + } +} +