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/Bullets/Bullets.cpp@29:6b8411bb040a, 2019-05-04 (annotated)
- Committer:
- el17sm
- Date:
- Sat May 04 15:39:20 2019 +0000
- Revision:
- 29:6b8411bb040a
- Parent:
- 28:98848e6a77a2
added Room complete;; started Floor engine;; ; To do:; Floor generation;; More enemies;; Bosses;; Title Screen;; Score;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17sm | 13:d04a6caba40d | 1 | #include "Bullets.h" |
| el17sm | 13:d04a6caba40d | 2 | |
| el17sm | 22:7abf4581bc9b | 3 | Bullets::Bullets(float pos_x, float pos_y, int dir) |
| el17sm | 22:7abf4581bc9b | 4 | { |
| el17sm | 28:98848e6a77a2 | 5 | _damage_self_upon_collision = false; |
| el17sm | 13:d04a6caba40d | 6 | moving = true; |
| el17sm | 13:d04a6caba40d | 7 | face = 0; |
| el17sm | 13:d04a6caba40d | 8 | hp = 1; |
| el17sm | 26:abbc19edc5c1 | 9 | hitbox.width = 3; |
| el17sm | 26:abbc19edc5c1 | 10 | hitbox.height = 3; |
| el17sm | 13:d04a6caba40d | 11 | position.x = pos_x; |
| el17sm | 13:d04a6caba40d | 12 | position.y = pos_y; |
| el17sm | 26:abbc19edc5c1 | 13 | sprite_size.width = 3; |
| el17sm | 26:abbc19edc5c1 | 14 | sprite_size.height = 3; |
| el17sm | 13:d04a6caba40d | 15 | sprite_size.offset_x = 0; |
| el17sm | 15:44d5cc33d389 | 16 | sprite_size.offset_y = 1; |
| el17sm | 13:d04a6caba40d | 17 | direction = dir; |
| el17sm | 13:d04a6caba40d | 18 | } |
| el17sm | 13:d04a6caba40d | 19 | |
| el17sm | 29:6b8411bb040a | 20 | void Bullets::move(float speed, float unused, int * unused2, bool * unused3) |
| el17sm | 22:7abf4581bc9b | 21 | { |
| el17sm | 22:7abf4581bc9b | 22 | if (direction == 0) { |
| el17sm | 14:3361879490b2 | 23 | position.y -= speed; |
| el17sm | 22:7abf4581bc9b | 24 | } else if (direction == 1) { |
| el17sm | 14:3361879490b2 | 25 | position.x += speed; |
| el17sm | 22:7abf4581bc9b | 26 | } else if (direction == 2) { |
| el17sm | 14:3361879490b2 | 27 | position.y += speed; |
| el17sm | 22:7abf4581bc9b | 28 | } else if (direction == 3) { |
| el17sm | 14:3361879490b2 | 29 | position.x -= speed; |
| el17sm | 14:3361879490b2 | 30 | } |
| el17sm | 13:d04a6caba40d | 31 | } |
| el17sm | 13:d04a6caba40d | 32 | |
| el17sm | 23:5a8f75e93508 | 33 | void Bullets::take_damage(int damage) |
| el17sm | 23:5a8f75e93508 | 34 | { |
| el17sm | 23:5a8f75e93508 | 35 | hp -= damage; |
| el17sm | 23:5a8f75e93508 | 36 | } |
| el17sm | 23:5a8f75e93508 | 37 | |
| el17sm | 22:7abf4581bc9b | 38 | int * Bullets::get_frame() |
| el17sm | 22:7abf4581bc9b | 39 | { |
| el17sm | 13:d04a6caba40d | 40 | return (int *) bullets_sprite; |
| el17sm | 14:3361879490b2 | 41 | } |
| el17sm | 14:3361879490b2 | 42 | |
| el17sm | 29:6b8411bb040a | 43 | bool Bullets::out_of_bounds_check(int * map, bool * doorways) |
| el17sm | 22:7abf4581bc9b | 44 | { |
| el17sm | 29:6b8411bb040a | 45 | if (entity_to_map_collision_test(position.x, position.y, map, doorways)) { |
| el17sm | 14:3361879490b2 | 46 | return true; |
| el17sm | 14:3361879490b2 | 47 | } |
| el17sm | 22:7abf4581bc9b | 48 | if ((0 > position.x) || (position.x > 84) || (0 > position.y) || (position.y > 48)) { |
| el17sm | 14:3361879490b2 | 49 | return true; |
| el17sm | 14:3361879490b2 | 50 | } |
| el17sm | 14:3361879490b2 | 51 | return false; |
| el17sm | 13:d04a6caba40d | 52 | } |