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: 4DGL-uLCD-SE PinDetect mbed
Enemy.cpp
00001 #include "Enemy.h" 00002 00003 Enemy::Enemy(int x, uLCD_4DGL *uLCD) { 00004 _health = 2; 00005 _x = x; 00006 _y = -10; 00007 _uLCDptr = uLCD; 00008 _cockpit.init(0,0,uLCD); 00009 _cockpit.setRadius(10); 00010 _glare1.init(3,3,uLCD); 00011 _glare1.setRadius(4); 00012 _glare2.init(-3,-3,uLCD); 00013 _glare2.setRadius(3); 00014 _gun.init(0,10,uLCD); 00015 _gun.setDimensions(4,2); 00016 _engine.init(-2,-15,uLCD); 00017 _engine.setDimensions(5,5); 00018 _healthBar.init(-9, 16,uLCD); 00019 _healthBar.setDimensions(1,20); 00020 } 00021 00022 void Enemy::drawEnemy() { 00023 _cockpit.drawCircle(_x, _y, EnemyCockpitColor); 00024 _glare1.drawCircle(_x, _y, EnemyGlareColor1); 00025 _glare2.drawCircle(_x, _y, EnemyGlareColor2); 00026 _gun.drawRect(_x, _y, EnemyGunColor); 00027 _engine.drawRect(_x, _y, EnemyEngineColor); 00028 if(_health == 2) { 00029 _healthBar.setDimensions(1,20); 00030 } 00031 else if(_health == 1) { 00032 _healthBar.setDimensions(1,10); 00033 } 00034 else { 00035 _healthBar.setDimensions(1,1); 00036 } 00037 _healthBar.drawRect(_x,_y, HealthColor); 00038 } 00039 00040 void Enemy::addY(int dy) { 00041 _y += dy; 00042 } 00043 00044 int Enemy::getY() { 00045 return _y; 00046 } 00047 00048 Point Enemy::hitBoxStart() { 00049 Point hitStart; 00050 hitStart.x = _x - 11; 00051 hitStart.y = _y - 11; 00052 return hitStart; 00053 } 00054 00055 Point Enemy::hitBoxDim() { 00056 Point hitDim; 00057 hitDim.x = 21; 00058 hitDim.y = 21; 00059 return hitDim; 00060 } 00061 00062 Point Enemy::getGunLoc() { 00063 Point gunLocation; 00064 gunLocation.x = _x; 00065 gunLocation.y = _y + 5; 00066 return gunLocation; 00067 } 00068 00069 void Enemy::damage(int dmg) { 00070 _health -= dmg; 00071 } 00072 00073 int Enemy::getHealth() { 00074 return _health; 00075 }
Generated on Sun Jul 17 2022 07:39:55 by
1.7.2