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.
Diff: ParentClasses/CheckCollisions/CheckCollision.cpp
- Revision:
- 82:3211b31e9421
- Parent:
- 36:27aa597db3d2
- Child:
- 85:87bc28b151d8
--- a/ParentClasses/CheckCollisions/CheckCollision.cpp Mon May 25 15:59:14 2020 +0000
+++ b/ParentClasses/CheckCollisions/CheckCollision.cpp Mon May 25 18:39:51 2020 +0000
@@ -3,39 +3,39 @@
bool CheckCollision::check_collision(Weapons bullet) {
bool collision = false;
Vector2D bullet_pos = bullet.get_pos();
- //printf ("Collision 1 = %d\n", collision);
+ // printf ("Collision 1 = %d\n", collision);
- // checks collision if bullet is going in east direction
- if(bullet.get_direction()){
- //int bullet_pos_twox = bullet_pos.x;
- //int bullet_pos_twoy = bullet_pos.y;
- //printf ("alien x = %d, bullet x = %d\n", position_x_,bullet_pos_twox);
- //printf ("alien y = %d, bullet y = %d\n", position_y_,bullet_pos_twoy);
+ // Checks collision if bullet is going in east direction
+ if(bullet.get_direction()) {
+ // int bullet_pos_twox = bullet_pos.x;
+ // int bullet_pos_twoy = bullet_pos.y;
+ // printf ("alien x = %d, bullet x = %d\n", position_x_,bullet_pos_twox);
+ // printf ("alien y = %d, bullet y = %d\n", position_y_,bullet_pos_twoy);
// Collision if the bullet is inside of the xy ranges of sprite drawing
if((bullet_pos.x + 1) >= position_x_ &&
(bullet_pos.x + 1) <= (position_x_ + sprite_x_length ) &&
position_y_ <= bullet_pos.y &&
- bullet_pos.y <= (position_y_ + sprite_y_length )){
+ bullet_pos.y <= (position_y_ + sprite_y_length )) {
collision = true;
}
- //printf ("Collision 2 = %d\n", collision);
+ // printf ("Collision 2 = %d\n", collision);
- // checks collision if bullet is going in west direction
- }else if(!bullet.get_direction()){
+ // Checks collision if bullet is going in west direction
+ }else if(!bullet.get_direction()) {
if(bullet_pos.x <= (position_x_ + sprite_x_length ) &&
bullet_pos.x >= position_x_ &&
position_y_ <= bullet_pos.y &&
- bullet_pos.y <= (position_y_ + sprite_y_length )){
+ bullet_pos.y <= (position_y_ + sprite_y_length )) {
collision = true;
}
- //printf ("Collision 3 = %d\n", collision);
+ // printf ("Collision 3 = %d\n", collision);
}
- //printf ("Collision 4 = %d\n", collision);
+ // printf ("Collision 4 = %d\n", collision);
return collision;
}