-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbee.cpp
62 lines (57 loc) · 1.11 KB
/
bee.cpp
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
56
57
58
59
60
61
62
#pragma once
#include <iostream>
#include "bee.hpp"
using namespace std;
// Sprite will form at x and y coordinates of screen
Bee::Bee(int x, int y) : Unit()
{
Unit::srcRect = {63, 619, 151, 166};
Unit::moverRect = {x, y, 50, 50};
}
void Bee::fly()
{
// Sprite will flap it wings
switch (frame)
{
case 0:
srcRect = {63, 619, 151, 166};
frame = 1;
break;
case 1:
srcRect = {234, 630, 163, 162};
frame = 2;
break;
case 2:
srcRect = {409, 650, 171, 147};
frame = 0;
break;
}
// 1% probability of sprite for hovering
if (hover == true && counter != 10)
{
counter++;
}
else if (hover == true && counter == 10)
{
hover = false;
counter = 0;
}
if (hover == false)
{
int r = (rand() % 100) + 1;
cout << r << endl;
if (r == 1)
{
hover = true;
}
}
// Sprite will rotate on this condition
if (hover == false)
{
moverRect.x += 3;
}
if (moverRect.x >= 1000)
{
moverRect.x = 0;
}
}