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@14:d0650d0de063, 2019-05-06 (annotated)
- Committer:
- S_Tingle
- Date:
- Mon May 06 14:13:09 2019 +0000
- Revision:
- 14:d0650d0de063
- Parent:
- 13:c3b550fc2445
- Child:
- 16:37d98c281eb3
added start screen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
S_Tingle | 12:200a1266ceee | 1 | #include "Enemy2.h" |
S_Tingle | 12:200a1266ceee | 2 | |
S_Tingle | 12:200a1266ceee | 3 | Enemy2::Enemy2(){ |
S_Tingle | 12:200a1266ceee | 4 | x_enem = 67; |
S_Tingle | 12:200a1266ceee | 5 | y_enem = 20; |
S_Tingle | 12:200a1266ceee | 6 | } |
S_Tingle | 12:200a1266ceee | 7 | |
S_Tingle | 12:200a1266ceee | 8 | Enemy2::~Enemy2(){ |
S_Tingle | 12:200a1266ceee | 9 | |
S_Tingle | 12:200a1266ceee | 10 | } |
S_Tingle | 12:200a1266ceee | 11 | |
S_Tingle | 12:200a1266ceee | 12 | void Enemy2::init(int x,int y){ |
S_Tingle | 12:200a1266ceee | 13 | x_enem = x; |
S_Tingle | 12:200a1266ceee | 14 | y_enem = y; |
S_Tingle | 12:200a1266ceee | 15 | } |
S_Tingle | 12:200a1266ceee | 16 | |
S_Tingle | 14:d0650d0de063 | 17 | int Enemy2::get_x_enem(){ |
S_Tingle | 12:200a1266ceee | 18 | return x_enem; |
S_Tingle | 12:200a1266ceee | 19 | } |
S_Tingle | 12:200a1266ceee | 20 | |
S_Tingle | 14:d0650d0de063 | 21 | int Enemy2::get_y_enem(){ |
S_Tingle | 12:200a1266ceee | 22 | return y_enem; |
S_Tingle | 12:200a1266ceee | 23 | } |
S_Tingle | 12:200a1266ceee | 24 | |
S_Tingle | 12:200a1266ceee | 25 | void Enemy2::drawSprite(N5110 &lcd){ |
S_Tingle | 12:200a1266ceee | 26 | lcd.drawSprite(x_enem,y_enem,7,7,(int *)enemy_B); |
S_Tingle | 12:200a1266ceee | 27 | } |
S_Tingle | 12:200a1266ceee | 28 | |
S_Tingle | 12:200a1266ceee | 29 | void Enemy2::movement(N5110 &lcd){ |
S_Tingle | 12:200a1266ceee | 30 | accel = 1; |
S_Tingle | 13:c3b550fc2445 | 31 | for (int i = 0; i < 14; i++) { |
S_Tingle | 13:c3b550fc2445 | 32 | if (20 < y_enem < 32){ |
S_Tingle | 13:c3b550fc2445 | 33 | y_enem += accel; |
S_Tingle | 13:c3b550fc2445 | 34 | } |
S_Tingle | 13:c3b550fc2445 | 35 | if (y_enem == 32){ |
S_Tingle | 13:c3b550fc2445 | 36 | y_enem -= accel; |
S_Tingle | 13:c3b550fc2445 | 37 | } |
S_Tingle | 12:200a1266ceee | 38 | } |
S_Tingle | 12:200a1266ceee | 39 | } |
S_Tingle | 12:200a1266ceee | 40 | |
S_Tingle | 12:200a1266ceee | 41 | bool Enemy2::northCollision(int x, int y, N5110 &lcd){ |
S_Tingle | 12:200a1266ceee | 42 | |
S_Tingle | 12:200a1266ceee | 43 | for (int i = 0; i < 7; i++) { |
S_Tingle | 13:c3b550fc2445 | 44 | if (lcd.getPixel(x + i,y) == 1) { |
S_Tingle | 12:200a1266ceee | 45 | return true; |
S_Tingle | 12:200a1266ceee | 46 | } |
S_Tingle | 12:200a1266ceee | 47 | } |
S_Tingle | 12:200a1266ceee | 48 | return false; |
S_Tingle | 12:200a1266ceee | 49 | } |
S_Tingle | 12:200a1266ceee | 50 | |
S_Tingle | 12:200a1266ceee | 51 | bool Enemy2::southCollision(int x, int y, N5110 &lcd){ |
S_Tingle | 12:200a1266ceee | 52 | |
S_Tingle | 12:200a1266ceee | 53 | for (int i = 0; i < 7; i++) { |
S_Tingle | 12:200a1266ceee | 54 | if (lcd.getPixel(x + i,y + 7) == 1) { |
S_Tingle | 12:200a1266ceee | 55 | return true; |
S_Tingle | 12:200a1266ceee | 56 | } |
S_Tingle | 12:200a1266ceee | 57 | } |
S_Tingle | 12:200a1266ceee | 58 | return false; |
S_Tingle | 12:200a1266ceee | 59 | } |