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
Enemy/Enemy2.cpp
- Committer:
- S_Tingle
- Date:
- 2019-05-04
- Revision:
- 13:c3b550fc2445
- Parent:
- 12:200a1266ceee
- Child:
- 14:d0650d0de063
File content as of revision 13:c3b550fc2445:
#include "Enemy2.h" Enemy2::Enemy2(){ x_enem = 67; y_enem = 20; } Enemy2::~Enemy2(){ } void Enemy2::init(int x,int y){ x_enem = x; y_enem = y; } int Enemy2::get_x_enem() { return x_enem; } int Enemy2::get_y_enem() { return y_enem; } void Enemy2::drawSprite(N5110 &lcd){ lcd.drawSprite(x_enem,y_enem,7,7,(int *)enemy_B); } void Enemy2::movement(N5110 &lcd){ accel = 1; for (int i = 0; i < 14; i++) { if (20 < y_enem < 32){ y_enem += accel; } if (y_enem == 32){ y_enem -= accel; } } } bool Enemy2::northCollision(int x, int y, N5110 &lcd){ for (int i = 0; i < 7; i++) { if (lcd.getPixel(x + i,y) == 1) { return true; } } return false; } bool Enemy2::southCollision(int x, int y, N5110 &lcd){ for (int i = 0; i < 7; i++) { if (lcd.getPixel(x + i,y + 7) == 1) { return true; } } return false; }