Revisão 14
Scoreboard and balance stuff
| processing/blacklight/Scoreboard.pde | ||
|---|---|---|
| 1 |
class Scoreboard |
|
| 2 |
{
|
|
| 3 |
Level level = null; |
|
| 4 |
|
|
| 5 |
void setup () |
|
| 6 |
{
|
|
| 7 |
|
|
| 8 |
} |
|
| 9 |
void draw () |
|
| 10 |
{
|
|
| 11 |
/* fill (0); |
|
| 12 |
|
|
| 13 |
fill (0); |
|
| 14 |
stroke (255); |
|
| 15 |
strokeWeight (4); |
|
| 16 |
|
|
| 17 |
textFont (_bold_, 60); |
|
| 18 |
text (this.level.battlefield.blacks, 200, 200); |
|
| 19 |
|
|
| 20 |
fill (255); |
|
| 21 |
stroke (0); |
|
| 22 |
strokeWeight (4); |
|
| 23 |
|
|
| 24 |
textFont (_bold_, 60); |
|
| 25 |
// _bold_.draw (this.level.battlefield.whites); |
|
| 26 |
*/ |
|
| 27 |
} |
|
| 28 |
|
|
| 29 |
} |
|
| processing/blacklight/Blackminion.pde | ||
|---|---|---|
| 74 | 74 |
} |
| 75 | 75 |
|
| 76 | 76 |
void fire () |
| 77 |
{
|
|
| 77 |
{/*
|
|
| 78 |
|
|
| 78 | 79 |
Blackmatter matter = new Blackmatter (); |
| 79 | 80 |
|
| 80 | 81 |
matter.x = this.x; |
| ... | ... | |
| 82 | 83 |
|
| 83 | 84 |
matter.setup (); |
| 84 | 85 |
this.blacklord.blackmatter.add (matter); |
| 86 |
*/ |
|
| 85 | 87 |
} |
| 86 | 88 |
|
| 87 | 89 |
void bomb () |
| 88 |
{
|
|
| 90 |
{/*
|
|
| 89 | 91 |
for (int i = 0; i < 10; i++) |
| 90 | 92 |
{
|
| 91 | 93 |
Blackmatter matter = new Blackmatter (); |
| ... | ... | |
| 95 | 97 |
|
| 96 | 98 |
matter.setup (); |
| 97 | 99 |
this.blacklord.blackmatter.add (matter); |
| 98 |
} |
|
| 100 |
}*/
|
|
| 99 | 101 |
} |
| 100 |
} |
|
| 102 |
} |
|
| processing/blacklight/Logo.pde | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
} |
| 15 | 15 |
|
| 16 |
void draw (int balance) |
|
| 16 |
void draw (int balance, int whites, int blacks)
|
|
| 17 | 17 |
{
|
| 18 |
fill (balance); |
|
| 18 |
|
|
| 19 |
println ("drawing!");
|
|
| 20 |
fill (255); |
|
| 19 | 21 |
|
| 20 | 22 |
textFont (_bold_, 48); |
| 21 | 23 |
text ("BLACK", 10, 48);
|
| 24 |
text (whites, 10, 100); |
|
| 22 | 25 |
textFont (_regular_, 48); |
| 23 | 26 |
text ("LIGHT", 150, 48);
|
| 27 |
|
|
| 28 |
fill (0); |
|
| 24 | 29 |
scale (-1, 1); |
| 25 | 30 |
textFont (_bold_, 48); |
| 26 | 31 |
text ("BLACK", -_game_.width + 10, 48);
|
| 32 |
text (blacks, -_game_.width + 10, 100); |
|
| 27 | 33 |
textFont (_regular_, 48); |
| 28 | 34 |
text ("LIGHT", -_game_.width + 150, 48);
|
| 29 | 35 |
scale (-1, 1); |
| 30 | 36 |
} |
| 31 |
} |
|
| 37 |
} |
|
| processing/blacklight/Level.pde | ||
|---|---|---|
| 12 | 12 |
Battlefield battlefield = null; |
| 13 | 13 |
Blacklord blacklord = null; |
| 14 | 14 |
Lightlord lightlord = null; |
| 15 |
Scoreboard scoreboard = null; |
|
| 16 |
|
|
| 15 | 17 |
Serial port = null; |
| 16 | 18 |
|
| 17 | 19 |
// Blackmatter [] blackmatter = {};
|
| ... | ... | |
| 36 | 38 |
this.battlefield = new Battlefield (this.width, this.height); |
| 37 | 39 |
this.lightlord = new Lightlord (); |
| 38 | 40 |
this.blacklord = new Blacklord (); |
| 41 |
this.scoreboard = new Scoreboard (); |
|
| 42 |
|
|
| 39 | 43 |
|
| 40 | 44 |
this.battlefield.level = this; |
| 41 | 45 |
this.lightlord.level = this; |
| 42 | 46 |
this.blacklord.level = this; |
| 47 |
this.scoreboard.level = this; |
|
| 43 | 48 |
|
| 44 | 49 |
this.battlefield.setup (); |
| 45 | 50 |
this.lightlord.setup (); |
| 46 | 51 |
this.blacklord.setup (); |
| 52 |
this.scoreboard.setup (); |
|
| 53 |
|
|
| 47 | 54 |
|
| 48 | 55 |
String[] ports = Serial.list (); |
| 49 | 56 |
|
| ... | ... | |
| 54 | 61 |
{
|
| 55 | 62 |
this.port = _game_.leds; |
| 56 | 63 |
} |
| 64 |
|
|
| 65 |
|
|
| 57 | 66 |
} |
| 58 | 67 |
|
| 68 |
int balance () |
|
| 69 |
{
|
|
| 70 |
return this.battlefield.whites - this.battlefield.blacks; |
|
| 71 |
} |
|
| 72 |
|
|
| 59 | 73 |
void draw () |
| 60 | 74 |
{
|
| 61 | 75 |
this.battlefield.draw (); |
| ... | ... | |
| 74 | 88 |
cell.update(0); |
| 75 | 89 |
} |
| 76 | 90 |
|
| 77 |
for (int j = 0; j < this.blacklord.blackmatter.size (); j++) |
|
| 78 |
{
|
|
| 79 |
Blackmatter b = ((Blackmatter) this.blacklord.blackmatter.get (j)); |
|
| 80 |
Cell cell = this.battlefield.getCell (b.x, b.y); |
|
| 81 |
cell.update(1); |
|
| 82 |
} |
|
| 91 |
Blackminion b = (Blackminion) this.blacklord.minions [0]; |
|
| 92 |
Cell cell = this.battlefield.getCell (b.x, b.y); |
|
| 93 |
cell.update(1); |
|
| 83 | 94 |
|
| 84 | 95 |
|
| 96 |
this.scoreboard.draw (); |
|
| 97 |
|
|
| 85 | 98 |
//int balance = this.lightlord.balance (); |
| 86 | 99 |
|
| 87 | 100 |
// DESCOMENTAR!! LEDS |
| ... | ... | |
| 182 | 195 |
_game_.lightWins (); |
| 183 | 196 |
} |
| 184 | 197 |
} |
| 185 |
|
|
| 198 |
|
|
| processing/blacklight/Game.pde | ||
|---|---|---|
| 105 | 105 |
|
| 106 | 106 |
background (this.background); |
| 107 | 107 |
|
| 108 |
if (this.logo != null) |
|
| 109 |
{
|
|
| 110 |
if (this.current != null) |
|
| 111 |
this.logo.draw (this.current.lightlord.balance ()); |
|
| 112 |
else if (this.winner != null) |
|
| 113 |
this.logo.draw ((this.winner.team == 0) ? 0 : 255); |
|
| 114 |
} |
|
| 115 | 108 |
|
| 116 | 109 |
if (this.winner != null) |
| 117 | 110 |
this.winner.draw (); |
| ... | ... | |
| 123 | 116 |
|
| 124 | 117 |
if (this.current != null) |
| 125 | 118 |
this.current.draw (); |
| 119 |
|
|
| 120 |
if (this.logo != null) |
|
| 121 |
{
|
|
| 122 |
if (this.current != null) |
|
| 123 |
this.logo.draw (this.current.balance (), this.current.battlefield.whites, this.current.battlefield.blacks); |
|
| 124 |
else if (this.winner != null) |
|
| 125 |
this.logo.draw ((this.winner.team == 0) ? 0 : 255, 0, 0); |
|
| 126 |
} |
|
| 127 |
|
|
| 126 | 128 |
} |
| 127 | 129 |
|
| 128 | 130 |
void loadXml (XMLElement node) |
| ... | ... | |
| 284 | 286 |
} |
| 285 | 287 |
|
| 286 | 288 |
} |
| 287 |
} |
|
| 289 |
} |
|
| processing/blacklight/Cell.pde | ||
|---|---|---|
| 93 | 93 |
|
| 94 | 94 |
|
| 95 | 95 |
// if white conquers plays animate white |
| 96 |
if (this.lifeBar >= 255 && this.side != 0) {
|
|
| 96 |
if (this.isWhite () && (this.side != 0)) {
|
|
| 97 | 97 |
this.lifeBar = 255; |
| 98 | 98 |
animateCell(255, 0); |
| 99 | 99 |
} |
| 100 | 100 |
|
| 101 | 101 |
// if black conquers plays animate black |
| 102 |
if (this.lifeBar <= 0 && this.side != 1) {
|
|
| 102 |
if (this.isBlack () && (this.side != 1)) {
|
|
| 103 | 103 |
this.lifeBar = 0; |
| 104 | 104 |
animateCell(0, 1); |
| 105 | 105 |
} |
| 106 |
}; |
|
| 106 |
|
|
| 107 |
} |
|
| 108 |
boolean isWhite () |
|
| 109 |
{
|
|
| 110 |
return (this.lifeBar >= 255); |
|
| 111 |
} |
|
| 112 |
|
|
| 113 |
boolean isBlack () |
|
| 114 |
{
|
|
| 115 |
return (this.lifeBar <= 0); |
|
| 116 |
} |
|
| 107 | 117 |
|
| 118 |
|
|
| 108 | 119 |
/************************************************** |
| 109 | 120 |
* |
| 110 | 121 |
* Updates cell conquer power |
| ... | ... | |
| 195 | 206 |
rect (this.x, this.y, this.width - 1, this.height - 1); |
| 196 | 207 |
} |
| 197 | 208 |
|
| 198 |
}*/ |
|
| 209 |
}*/ |
|
| processing/blacklight/Battlefield.pde | ||
|---|---|---|
| 11 | 11 |
int videoScale = 80; |
| 12 | 12 |
int width = 1280; |
| 13 | 13 |
int height = 720; |
| 14 |
|
|
| 15 |
int blacks = 0; |
|
| 16 |
int whites = 0; |
|
| 14 | 17 |
|
| 15 | 18 |
int cols, rows; |
| 16 | 19 |
Cell[][] cells = {
|
| ... | ... | |
| 37 | 40 |
void draw() {
|
| 38 | 41 |
background(159, 182, 205); |
| 39 | 42 |
|
| 40 |
for (int i = 0; i < this.cells.length; i++) {
|
|
| 41 |
//rows |
|
| 43 |
|
|
| 44 |
this.blacks = 0; |
|
| 45 |
this.whites = 0; |
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
for (int i = 0; i < this.cells.length; i++) { //rows
|
|
| 42 | 50 |
for (int j = 0; j < this.cells[i].length; j++) {
|
| 43 | 51 |
this.cells [i][j].setup ( this.cells[i][j].lifeBar, this.cells[i][j].animating ); |
| 44 | 52 |
this.cells [i][j].draw(); |
| 53 |
|
|
| 54 |
if (this.cells [i][j].isWhite ()) |
|
| 55 |
{
|
|
| 56 |
whites++; |
|
| 57 |
} |
|
| 58 |
else if (this.cells [i][j].isBlack ()) |
|
| 59 |
{
|
|
| 60 |
blacks++; |
|
| 61 |
} |
|
| 45 | 62 |
} |
| 46 | 63 |
} |
| 64 |
|
|
| 47 | 65 |
} |
| 48 | 66 |
|
| 49 | 67 |
/************************************************** |
| ... | ... | |
| 82 | 100 |
return this.cells [cellX][cellY]; |
| 83 | 101 |
} |
| 84 | 102 |
} |
| 85 |
|
|
| 103 |
|
|
Também disponível em: Unified diff