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/Player/Bullets/Bullets.cpp@51:4d0cd75e7ed3, 2019-05-09 (annotated)
- Committer:
- el17sm
- Date:
- Thu May 09 07:39:49 2019 +0000
- Revision:
- 51:4d0cd75e7ed3
- Parent:
- 41:0697508a28ba
- Child:
- 53:93338b52489d
Removed moving boolean from entity, finished commenting room.cpp
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17sm | 32:fe6359ef9916 | 1 | #include "Bullets.h" |
| el17sm | 32:fe6359ef9916 | 2 | |
| el17sm | 32:fe6359ef9916 | 3 | Bullets::Bullets(float pos_x, float pos_y, int dir) |
| el17sm | 32:fe6359ef9916 | 4 | { |
| el17sm | 32:fe6359ef9916 | 5 | face = 0; |
| el17sm | 32:fe6359ef9916 | 6 | hp = 1; |
| el17sm | 32:fe6359ef9916 | 7 | hitbox.width = 3; |
| el17sm | 32:fe6359ef9916 | 8 | hitbox.height = 3; |
| el17sm | 32:fe6359ef9916 | 9 | position.x = pos_x; |
| el17sm | 32:fe6359ef9916 | 10 | position.y = pos_y; |
| el17sm | 32:fe6359ef9916 | 11 | sprite_size.width = 3; |
| el17sm | 32:fe6359ef9916 | 12 | sprite_size.height = 3; |
| el17sm | 40:cbcbf6fc1421 | 13 | sprite_size.offset_x = -1; |
| el17sm | 41:0697508a28ba | 14 | sprite_size.offset_y = -4; |
| el17sm | 32:fe6359ef9916 | 15 | direction = dir; |
| el17sm | 32:fe6359ef9916 | 16 | } |
| el17sm | 32:fe6359ef9916 | 17 | |
| el17sm | 34:1d5b4da3935e | 18 | void Bullets::move(float speed, float unused, char * unused2, bool * unused3) |
| el17sm | 32:fe6359ef9916 | 19 | { |
| el17sm | 32:fe6359ef9916 | 20 | if (direction == 0) { |
| el17sm | 32:fe6359ef9916 | 21 | position.y -= speed; |
| el17sm | 32:fe6359ef9916 | 22 | } else if (direction == 1) { |
| el17sm | 32:fe6359ef9916 | 23 | position.x += speed; |
| el17sm | 32:fe6359ef9916 | 24 | } else if (direction == 2) { |
| el17sm | 32:fe6359ef9916 | 25 | position.y += speed; |
| el17sm | 32:fe6359ef9916 | 26 | } else if (direction == 3) { |
| el17sm | 32:fe6359ef9916 | 27 | position.x -= speed; |
| el17sm | 32:fe6359ef9916 | 28 | } |
| el17sm | 32:fe6359ef9916 | 29 | } |
| el17sm | 32:fe6359ef9916 | 30 | |
| el17sm | 32:fe6359ef9916 | 31 | void Bullets::draw(N5110 &lcd) |
| el17sm | 32:fe6359ef9916 | 32 | { |
| el17sm | 35:06cd6be999ad | 33 | lcd.drawSpriteTransparent(position.x+sprite_size.offset_x, |
| el17sm | 35:06cd6be999ad | 34 | position.y+sprite_size.offset_y, |
| el17sm | 32:fe6359ef9916 | 35 | sprite_size.height, |
| el17sm | 32:fe6359ef9916 | 36 | sprite_size.width, |
| el17sm | 32:fe6359ef9916 | 37 | get_frame()); |
| el17sm | 32:fe6359ef9916 | 38 | } |
| el17sm | 32:fe6359ef9916 | 39 | |
| el17sm | 32:fe6359ef9916 | 40 | void Bullets::take_damage(int damage) |
| el17sm | 32:fe6359ef9916 | 41 | { |
| el17sm | 32:fe6359ef9916 | 42 | hp -= damage; |
| el17sm | 32:fe6359ef9916 | 43 | } |
| el17sm | 32:fe6359ef9916 | 44 | |
| el17sm | 34:1d5b4da3935e | 45 | bool Bullets::out_of_bounds_check(char * map, bool * doorways) |
| el17sm | 32:fe6359ef9916 | 46 | { |
| el17sm | 32:fe6359ef9916 | 47 | if (entity_to_map_collision_test(position.x, position.y, map, doorways)) { |
| el17sm | 32:fe6359ef9916 | 48 | return true; |
| el17sm | 32:fe6359ef9916 | 49 | } |
| el17sm | 32:fe6359ef9916 | 50 | if ((0 > position.x) || (position.x > 84) || (0 > position.y) || (position.y > 48)) { |
| el17sm | 32:fe6359ef9916 | 51 | return true; |
| el17sm | 32:fe6359ef9916 | 52 | } |
| el17sm | 32:fe6359ef9916 | 53 | return false; |
| el17sm | 32:fe6359ef9916 | 54 | } |
| el17sm | 32:fe6359ef9916 | 55 | |
| el17sm | 33:4f3948dcd2f7 | 56 | char * Bullets::get_frame() |
| el17sm | 32:fe6359ef9916 | 57 | { |
| el17sm | 33:4f3948dcd2f7 | 58 | return (char *) bullets_sprite; |
| el17sm | 32:fe6359ef9916 | 59 | } |