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 MotionSensor
Entity/Collectibles/Health/Health.cpp@33:4f3948dcd2f7, 2019-05-06 (annotated)
- Committer:
- el17sm
- Date:
- Mon May 06 13:27:26 2019 +0000
- Revision:
- 33:4f3948dcd2f7
- Parent:
- 32:fe6359ef9916
- Child:
- 34:1d5b4da3935e
Saved space using char to print screen instead of int (reduction by 4x)
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17sm | 32:fe6359ef9916 | 1 | #include "Health.h" |
| el17sm | 32:fe6359ef9916 | 2 | |
| el17sm | 32:fe6359ef9916 | 3 | Health::Health(float pos_x, float pos_y) |
| el17sm | 32:fe6359ef9916 | 4 | { |
| el17sm | 32:fe6359ef9916 | 5 | _damage_self_upon_collision = true; |
| el17sm | 32:fe6359ef9916 | 6 | _hp_drop_chance = 0; // out of 10 |
| el17sm | 32:fe6359ef9916 | 7 | moving = true; |
| el17sm | 32:fe6359ef9916 | 8 | face = 0; |
| el17sm | 32:fe6359ef9916 | 9 | hp = 1; |
| el17sm | 32:fe6359ef9916 | 10 | attack = -1; |
| el17sm | 32:fe6359ef9916 | 11 | hitbox.width = 7; |
| el17sm | 32:fe6359ef9916 | 12 | hitbox.height = 7; |
| el17sm | 32:fe6359ef9916 | 13 | position.x = pos_x; |
| el17sm | 32:fe6359ef9916 | 14 | position.y = pos_y; |
| el17sm | 32:fe6359ef9916 | 15 | sprite_size.width = 7; |
| el17sm | 32:fe6359ef9916 | 16 | sprite_size.height = 7; |
| el17sm | 32:fe6359ef9916 | 17 | sprite_size.offset_x = 0; |
| el17sm | 32:fe6359ef9916 | 18 | sprite_size.offset_y = 0; |
| el17sm | 32:fe6359ef9916 | 19 | } |
| el17sm | 32:fe6359ef9916 | 20 | |
| el17sm | 32:fe6359ef9916 | 21 | void Health::move(float unused, float unused1, int * unused2, bool * unused3) |
| el17sm | 32:fe6359ef9916 | 22 | { |
| el17sm | 32:fe6359ef9916 | 23 | |
| el17sm | 32:fe6359ef9916 | 24 | } |
| el17sm | 32:fe6359ef9916 | 25 | |
| el17sm | 32:fe6359ef9916 | 26 | void Health::draw(N5110 &lcd) |
| el17sm | 32:fe6359ef9916 | 27 | { |
| el17sm | 32:fe6359ef9916 | 28 | lcd.drawSpriteTransparent(position.x-sprite_size.offset_x, |
| el17sm | 32:fe6359ef9916 | 29 | position.y-sprite_size.offset_y, |
| el17sm | 32:fe6359ef9916 | 30 | sprite_size.height, |
| el17sm | 32:fe6359ef9916 | 31 | sprite_size.width, |
| el17sm | 32:fe6359ef9916 | 32 | get_frame()); |
| el17sm | 32:fe6359ef9916 | 33 | } |
| el17sm | 32:fe6359ef9916 | 34 | |
| el17sm | 33:4f3948dcd2f7 | 35 | char * Health::get_frame() |
| el17sm | 32:fe6359ef9916 | 36 | { |
| el17sm | 33:4f3948dcd2f7 | 37 | return (char *) health_sprite; |
| el17sm | 32:fe6359ef9916 | 38 | } |
| el17sm | 32:fe6359ef9916 | 39 | |
| el17sm | 32:fe6359ef9916 | 40 | void Health::take_damage(int damage) |
| el17sm | 32:fe6359ef9916 | 41 | { |
| el17sm | 32:fe6359ef9916 | 42 | hp -= damage; |
| el17sm | 32:fe6359ef9916 | 43 | } |