forked from zhusim222/Bee-game
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathobstacle.cpp
More file actions
40 lines (33 loc) · 986 Bytes
/
obstacle.cpp
File metadata and controls
40 lines (33 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "obstacle.h"
#include "globals.h"
#include "splashkit.h"
#include <algorithm>
#include <iostream>
Obstacle::Obstacle(float x, float y,int speed){
this->x = x;
this->y = y;
this->speed = speed;
this->width = bitmap_width(box);
this->height = bitmap_height(box);
this->collision = false;
}
void Obstacle::update(){
this->y = this->y + this->speed;
}
void Obstacle::draw() {
double center_x = this->x + this->width/2;
double center_y = this->y + this->height/2;
point_2d box_position = point_at(center_x,center_y);
circle scaled_box_circle = bitmap_cell_circle(box, box_position,1);
draw_bitmap(box, x, y, option_to_screen());
draw_circle(COLOR_RED,scaled_box_circle);
}
void Obstacle::CollisionUpdate(bool is_collision) {
this->collision = is_collision;
if(is_collision){
std::cout << "Bee touched the box!" << std::endl;
}
else{
std::cout << "collision ends" << std::endl;
}
}