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
Diff: Entity/Player/Bullets/Bullets.cpp
- Revision:
- 32:fe6359ef9916
- Child:
- 33:4f3948dcd2f7
diff -r ab24d028ddfd -r fe6359ef9916 Entity/Player/Bullets/Bullets.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Entity/Player/Bullets/Bullets.cpp Mon May 06 08:56:48 2019 +0000
@@ -0,0 +1,61 @@
+#include "Bullets.h"
+
+Bullets::Bullets(float pos_x, float pos_y, int dir)
+{
+ _damage_self_upon_collision = false;
+ moving = true;
+ face = 0;
+ hp = 1;
+ hitbox.width = 3;
+ hitbox.height = 3;
+ position.x = pos_x;
+ position.y = pos_y;
+ sprite_size.width = 3;
+ sprite_size.height = 3;
+ sprite_size.offset_x = 0;
+ sprite_size.offset_y = 1;
+ direction = dir;
+}
+
+void Bullets::move(float speed, float unused, int * unused2, bool * unused3)
+{
+ if (direction == 0) {
+ position.y -= speed;
+ } else if (direction == 1) {
+ position.x += speed;
+ } else if (direction == 2) {
+ position.y += speed;
+ } else if (direction == 3) {
+ position.x -= speed;
+ }
+}
+
+void Bullets::draw(N5110 &lcd)
+{
+ lcd.drawSpriteTransparent(position.x-sprite_size.offset_x,
+ position.y-sprite_size.offset_y,
+ sprite_size.height,
+ sprite_size.width,
+ get_frame());
+}
+
+void Bullets::take_damage(int damage)
+{
+ hp -= damage;
+}
+
+bool Bullets::out_of_bounds_check(int * map, bool * doorways)
+{
+ if (entity_to_map_collision_test(position.x, position.y, map, doorways)) {
+ return true;
+ }
+ if ((0 > position.x) || (position.x > 84) || (0 > position.y) || (position.y > 48)) {
+ return true;
+ }
+ return false;
+}
+
+int * Bullets::get_frame()
+{
+ return (int *) bullets_sprite;
+}
\ No newline at end of file