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
Alien/Alien.cpp
- Committer:
- fy14lkaa
- Date:
- 2019-05-08
- Revision:
- 134:2da2db5871bd
- Parent:
- 133:eed60548d170
- Child:
- 137:fe80c0f2da9d
File content as of revision 134:2da2db5871bd:
#include "Alien.h" Alien::Alien() { } Alien::~Alien() { } void Alien::init(int x_alien,int y_alien, int speed_alien) { _x_alien = x_alien; _y_alien = y_alien; _speed_alien = speed_alien; _alive = true; } void Alien::draw(N5110 &lcd) { lcd.drawSprite(_x_alien,_y_alien,32,32,(int *)alien2); } void Alien::update(Direction d,float mag) { _speed_alien = int(mag*10.0f); } srand(time(NULL)); _y_alien += rand() % 17 - 8; if(_y_alien>=30) { _y_alien=30; } else if(_y_alien<=0) { _y_alien=0; } } int Alien::get_pos_x() { return _x_alien; } int Alien::get_pos_y() { return _y_alien; } void Alien::set_pos(int x, int y) { _x_alien = x; _y_alien = y; } void Alien::add_score() { _score++; } int Alien::get_score() { return _score; } bool Alien::isAlive() { return _alive; } void Alien::setAlive(bool alive) { _alive = alive; }