forked from ManalHasan/OOP-Project-Manal-Moiz-Naaseh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectBird.cpp
More file actions
55 lines (48 loc) · 1.18 KB
/
SelectBird.cpp
File metadata and controls
55 lines (48 loc) · 1.18 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "SelectBird.hpp"
SelectBird::SelectBird(){
isChosenB=false;
}
//loading the background
void SelectBird::Initialize(SDL_Renderer* ren){
m.CreateTexture("image/SelectBird.png", ren);
}
//determing which bird is selected by comparing the click x and y coordibate with the one in the background
int SelectBird::EventHandling(SDL_Event& b)
{
SDL_PollEvent(&b);
if (b.type == SDL_QUIT)
{
return -1;
}
//blue bird coordinates
else if (b.type == SDL_MOUSEBUTTONDOWN && b.motion.x > 100 && b.motion.x < 250 && b.motion.y > 280 && b.motion.y < 350)
{
bird=1;
isChosenB = true;
}
//yellow bird coordinates
else if (b.type == SDL_MOUSEBUTTONDOWN && b.motion.x > 350 && b.motion.x < 500 && b.motion.y > 280 && b.motion.y < 350)
{
bird=2;
isChosenB = true;
}
//owl coordinates
else if (b.type == SDL_MOUSEBUTTONDOWN && b.motion.x > 550 && b.motion.x < 730 && b.motion.y > 280 && b.motion.y < 350)
{
bird=3;
isChosenB = true;
}
return 0;
}
void SelectBird::Render(SDL_Renderer* ren)
{
m.Render(ren);
}
//Accessors
bool SelectBird::getChosenB()
{
return isChosenB;
}
int SelectBird::getBird(){
return bird;
}