forked from liueugene/reversabomb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoreboard.cpp
67 lines (55 loc) · 1.21 KB
/
scoreboard.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
63
64
65
66
67
//
// scoreboard.cpp
//
//
// Created by Josh Camarena on 5/17/16.
//
//
#include "scoreboard.h"
#include <SPI.h>
#include <Adafruit_DotStar.h>
#include "globals.cpp"
Scoreboard::Scoreboard(Adafruit_DotStar *strip)
: m_strip(strip), m_leftLife(7), m_rightLife(7), m_rightBegin(7), m_rightEnd(15), m_leftBegin(0), m_leftEnd(7), m_update(true)
{
m_strip->begin();
m_strip->clear();
m_strip->setBrightness(100);
this->update();
}
void Scoreboard::loseLife(bool TEAM) //0 left, 1 right
{
if(TEAM)
m_rightLife--;
else
m_leftLife--;
m_update = true;
return;
}
void Scoreboard::update()
{
if (!m_update)
return;
for (int i = 0; i < MAXLIVES; i++)
{
if (i < m_rightLife)
m_strip->setPixelColor(i + m_rightBegin, 0xFF0000);
else
m_strip->setPixelColor(i + m_rightBegin, 0);
if (i < m_leftLife)
m_strip->setPixelColor(i + m_leftBegin, 0x0000FF);
else
m_strip->setPixelColor(i + m_leftBegin, 0);
}
m_update = false;
m_strip->show();
return;
}
bool Scoreboard::rightDead()
{
return m_rightLife < 1;
}
bool Scoreboard::leftDead()
{
return m_leftLife < 1;
}