-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFuelCheck.cpp
62 lines (50 loc) · 976 Bytes
/
FuelCheck.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
#include"../FuelCheck.h"
#include<SFML/Graphics.hpp>
#include<SFML/System/Clock.hpp>
#include<iostream>
bool FuelCheck::isFinished(bool collision)
{
static sf::Clock clk;
static int previousTime = 0;
static int startFuel = 100;
static int lifes = 3;
static bool fuelFinished = false;
static float dt = 0.0f;
dt += clk.getElapsedTime().asSeconds();
std::cout << int(dt) << std::endl;
if (int(dt) > 0 && int(dt) != previousTime)
{
if (int(dt) % 2 == 0) {
startFuel -=5;
std::cout << "Fuel Decreases";
}
if (startFuel == 0)
{
lifes--;
startFuel = 100;
}
}
previousTime = int(dt);
if (collision)
{
if (startFuel < 100)
{
std::cout << "Fuel Increases";
startFuel += 5;
}
else
{
startFuel = 100;
}
std::cout << "gg " << std::endl;
}
if (lifes == 0)
{
fuelFinished = true;
}
setFuel(startFuel);
setLife(lifes);
std::cout << "The value is :" << getFuel() << "\n";
clk.restart();
return fuelFinished;
}