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 (32 loc) · 846 Bytes
/
obstacle.cpp
File metadata and controls
40 lines (32 loc) · 846 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() {
draw_bitmap(box, x, y, option_to_screen());
}
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;
}
}
void Obstacle::deceaseSpeed(int newSpeed){
this->speed = newSpeed;
std::cout << "The Speed equal to 2 now" << std::endl;
}