Revisão 18
Future Places RC
| processing/blacklight/Input.pde | ||
|---|---|---|
| 104 | 104 |
|
| 105 | 105 |
boolean fire () |
| 106 | 106 |
{
|
| 107 |
return ((this.bZ == 1) || (keyPressed)); |
|
| 107 |
|
|
| 108 |
return ((this.bZ == 1) || (keyPressed && ( keyCode == ENTER ))); |
|
| 108 | 109 |
|
| 109 | 110 |
// return true; |
| 110 | 111 |
// return (this.bZ == 1); |
| ... | ... | |
| 351 | 352 |
|
| 352 | 353 |
|
| 353 | 354 |
} |
| 354 |
*/ |
|
| 355 |
*/ |
|
| processing/blacklight/Logo.pde | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
} |
| 15 | 15 |
|
| 16 |
void draw (int balance, int whites, int blacks)
|
|
| 16 |
void draw (int timer, int whites, int blacks)
|
|
| 17 | 17 |
{
|
| 18 | 18 |
|
| 19 | 19 |
//println ("drawing!");
|
| ... | ... | |
| 21 | 21 |
|
| 22 | 22 |
textFont (_bold_, 60); |
| 23 | 23 |
text ("LIGHT", 10, 55);
|
| 24 |
text ( timer, 10, _game_.height - 10 ); |
|
| 24 | 25 |
textFont (_bold_, 24); |
| 25 | 26 |
text (whites + " cells", 186, 31); |
| 26 |
text ("23 battles", 186, 55);
|
|
| 27 |
text ( _game_.lightBattles + " battles", 186, 55); |
|
| 28 |
|
|
| 27 | 29 |
|
| 28 | 30 |
fill (0); |
| 29 | 31 |
scale (-1 , 1); |
| 30 | 32 |
textFont (_bold_, 57); |
| 31 | 33 |
text ("BLACK", -_game_.width + 12, 55);
|
| 34 |
text ( timer, -_game_.width + 12, _game_.height - 10 ); |
|
| 32 | 35 |
textFont (_bold_, 24); |
| 33 | 36 |
text (blacks + " cells", -_game_.width + 190, 31); |
| 34 |
text ("1 battles", -_game_.width + 190, 55);
|
|
| 37 |
text ( _game_.blackBattles + " battles", -_game_.width + 190, 55);
|
|
| 35 | 38 |
scale (-1, 1); |
| 39 |
|
|
| 40 |
|
|
| 36 | 41 |
} |
| 37 |
} |
|
| 42 |
} |
|
| processing/blacklight/Winner.pde | ||
|---|---|---|
| 26 | 26 |
|
| 27 | 27 |
|
| 28 | 28 |
this.countdown--; |
| 29 |
|
|
| 29 | 30 |
|
| 30 |
|
|
| 31 |
textFont (_bold_, 48); |
|
| 31 |
textFont (_bold_, 40); |
|
| 32 | 32 |
text (message, 50, _game_.height / 2 + 50); |
| 33 | 33 |
text ("next battle in " + this.countdown + " time units.", 50, _game_.height / 2 + 100);
|
| 34 | 34 |
|
| processing/blacklight/blacklight.pde | ||
|---|---|---|
| 24 | 24 |
void setup () |
| 25 | 25 |
{
|
| 26 | 26 |
size (1024, 768, OPENGL); |
| 27 |
|
|
| 27 | 28 |
_root_ = this; |
| 28 | 29 |
|
| 30 |
// smooth (); |
|
| 31 |
// frameRate (30); |
|
| 29 | 32 |
|
| 30 | 33 |
println ("the beat starts here.");
|
| 31 |
_fs_ = new SoftFullScreen (this); |
|
| 32 |
_fs_.enter (); |
|
| 34 |
/*_fs_ = new SoftFullScreen (this);
|
|
| 35 |
_fs_.enter ();*/
|
|
| 33 | 36 |
|
| 34 | 37 |
Ess.start (this); |
| 35 | 38 |
_bold_ = loadFont ("Code-Bold-48.vlw");
|
| ... | ... | |
| 51 | 54 |
void draw () |
| 52 | 55 |
{
|
| 53 | 56 |
_game_.draw (); |
| 54 |
} |
|
| 57 |
} |
|
| processing/blacklight/Level.pde | ||
|---|---|---|
| 13 | 13 |
Blacklord blacklord = null; |
| 14 | 14 |
Lightlord lightlord = null; |
| 15 | 15 |
Scoreboard scoreboard = null; |
| 16 |
int timer = 0; |
|
| 16 | 17 |
|
| 17 | 18 |
Serial port = null; |
| 18 | 19 |
|
| ... | ... | |
| 34 | 35 |
return; |
| 35 | 36 |
} |
| 36 | 37 |
|
| 37 |
|
|
| 38 |
this.timer = 1000; |
|
| 39 |
|
|
| 38 | 40 |
this.battlefield = new Battlefield (1024, 768); |
| 39 | 41 |
this.lightlord = new Lightlord (); |
| 40 | 42 |
this.blacklord = new Blacklord (); |
| ... | ... | |
| 88 | 90 |
|
| 89 | 91 |
for (int j = 0; j < this.blacklord.blackmatter.size (); j++) |
| 90 | 92 |
{
|
| 91 |
Blackmatter b = (Blackmatter) this.blacklord.blackmatter.get (j); |
|
| 92 |
Cell cell = this.battlefield.getCell (b.x, b.y); |
|
| 93 |
cell.update(1); |
|
| 93 |
Blackmatter b = (Blackmatter) this.blacklord.blackmatter.get (j);
|
|
| 94 |
Cell cell = this.battlefield.getCell (b.x, b.y);
|
|
| 95 |
cell.update(1);
|
|
| 94 | 96 |
} |
| 95 | 97 |
|
| 96 | 98 |
this.scoreboard.draw (); |
| ... | ... | |
| 99 | 101 |
|
| 100 | 102 |
// DESCOMENTAR!! LEDS |
| 101 | 103 |
//this.output (balance); |
| 104 |
if ( this.timer <= 0 ) this.outcome (); |
|
| 105 |
this.timer--; |
|
| 102 | 106 |
|
| 103 |
//this.outcome (balance); |
|
| 104 | 107 |
|
| 105 |
|
|
| 106 | 108 |
// this.blacklord.attack (); |
| 107 | 109 |
|
| 108 | 110 |
// this.lightlord.defend (); |
| ... | ... | |
| 132 | 134 |
// println (value); |
| 133 | 135 |
} |
| 134 | 136 |
|
| 135 |
void outcome (int balance)
|
|
| 137 |
void outcome () |
|
| 136 | 138 |
{
|
| 137 |
this.rate--; |
|
| 139 |
int score = this.battlefield.blacks - this.battlefield.whites; |
|
| 140 |
|
|
| 141 |
if ( score > 0 ) {
|
|
| 142 |
_game_.blackWins (); |
|
| 143 |
} else if ( score < 0 ) {
|
|
| 144 |
_game_.lightWins (); |
|
| 145 |
} else {
|
|
| 146 |
this.timer += 1000; |
|
| 147 |
} |
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
/* this.rate--; |
|
| 138 | 152 |
|
| 139 | 153 |
if (this.rate == 0) |
| 140 | 154 |
{
|
| ... | ... | |
| 192 | 206 |
if (blackpower == 6) |
| 193 | 207 |
_game_.blackWins (); |
| 194 | 208 |
else if (lightpower == 6) |
| 195 |
_game_.lightWins (); |
|
| 209 |
_game_.lightWins ();*/
|
|
| 196 | 210 |
} |
| 197 | 211 |
} |
| 198 |
|
|
| 212 |
|
|
| processing/blacklight/Detector.pde | ||
|---|---|---|
| 20 | 20 |
void setup () |
| 21 | 21 |
{
|
| 22 | 22 |
println ("camera!!");
|
| 23 |
this.cam = new GSCapture(_root_, this.width, this.height, 30);
|
|
| 23 |
this.cam = new GSCapture(_root_, this.width, this.height); |
|
| 24 | 24 |
this.cam.start (); |
| 25 | 25 |
this.total_pixels = this.width * this.height; |
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
int[] image () |
| 29 | 29 |
{
|
| 30 |
this.cam.read (); |
|
| 30 |
|
|
| 31 | 31 |
|
| 32 | 32 |
return this.cam.pixels; |
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 | 35 |
void draw () |
| 36 | 36 |
{
|
| 37 |
|
|
| 37 | 38 |
} |
| 39 |
|
|
| 40 |
|
|
| 38 | 41 |
} |
| 39 | 42 |
|
| 40 | 43 |
|
| 44 |
public void captureEvent(GSCapture c) {
|
|
| 45 |
|
|
| 46 |
c.read(); |
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| processing/blacklight/Game.pde | ||
|---|---|---|
| 24 | 24 |
AudioChannel sfx = null; |
| 25 | 25 |
Serial leds = null; |
| 26 | 26 |
|
| 27 |
int blackBattles = 0; |
|
| 28 |
int lightBattles = 0; |
|
| 27 | 29 |
|
| 30 |
|
|
| 28 | 31 |
PImage bgimage = null; |
| 29 | 32 |
|
| 30 | 33 |
void setup () |
| ... | ... | |
| 120 | 123 |
if (this.logo != null) |
| 121 | 124 |
{
|
| 122 | 125 |
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 |
this.logo.draw (this.current.timer, this.current.battlefield.whites, this.current.battlefield.blacks);
|
|
| 127 |
//else if (this.winner != null)
|
|
| 128 |
//this.logo.draw ((this.winner.team == 0) ? 0 : 255, 0, 0);
|
|
| 126 | 129 |
} |
| 127 | 130 |
|
| 128 | 131 |
} |
| ... | ... | |
| 250 | 253 |
this.ost.stop (); |
| 251 | 254 |
println ("The new black.");
|
| 252 | 255 |
this.current = null; |
| 256 |
this.blackBattles ++; |
|
| 253 | 257 |
this.winner = new Winner (); |
| 254 | 258 |
this.winner.setup (0); |
| 255 | 259 |
this.playBlackWins (); |
| ... | ... | |
| 261 | 265 |
this.ost.stop (); |
| 262 | 266 |
println ("Whitey.");
|
| 263 | 267 |
this.current = null; |
| 268 |
this.lightBattles ++; |
|
| 264 | 269 |
this.winner = new Winner (); |
| 265 | 270 |
this.winner.setup (1); |
| 266 | 271 |
this.playLightWins (); |
| ... | ... | |
| 286 | 291 |
} |
| 287 | 292 |
|
| 288 | 293 |
} |
| 289 |
} |
|
| 294 |
} |
|
| processing/blacklight/Lightminion.pde | ||
|---|---|---|
| 30 | 30 |
|
| 31 | 31 |
this.lighted = new ArrayList (); |
| 32 | 32 |
|
| 33 |
for(int y = 0; y < this.detector.height; y += 5)
|
|
| 33 |
for(int y = 0; y < this.detector.height; y += 10)
|
|
| 34 | 34 |
{
|
| 35 |
for(int x = 0; x < this.detector.width; x += 5)
|
|
| 35 |
for(int x = 0; x < this.detector.width; x += 10)
|
|
| 36 | 36 |
{
|
| 37 | 37 |
float av = (red(img[y*this.detector.width+x])+green(img[y*this.detector.width+x])+blue(img[y*this.detector.width+x]))/3.0; |
| 38 | 38 |
|
| ... | ... | |
| 55 | 55 |
|
| 56 | 56 |
this.lighted.add (l); |
| 57 | 57 |
|
| 58 |
ellipse (l[0], l[1], 10, 10);
|
|
| 59 |
// ellipse (l[0], l[1], this.lightlord.level.battlefield.cell_width, this.lightlord.level.battlefield.cell_height);
|
|
| 58 |
ellipse (l[0], l[1], 50, 50);
|
|
| 59 |
//ellipse (l[0], l[1], this.lightlord.level.battlefield.videoScale, this.lightlord.level.battlefield.videoScale);
|
|
| 60 | 60 |
// point (x, y, 0); |
| 61 | 61 |
} |
| 62 | 62 |
} |
| processing/blacklight/Blackminion.pde | ||
|---|---|---|
| 10 | 10 |
{
|
| 11 | 11 |
int x = 200; |
| 12 | 12 |
int y = 200; |
| 13 |
int diameter = 20;
|
|
| 13 |
int diameter = 50;
|
|
| 14 | 14 |
Input input = null; |
| 15 | 15 |
Blacklord blacklord = null; |
| 16 | 16 |
|
| ... | ... | |
| 42 | 42 |
this.x = this.x + (this.input.horizontal ()/10); |
| 43 | 43 |
this.y = this.y + (this.input.vertical ()/10); |
| 44 | 44 |
|
| 45 |
if (this.x >= _game_.width - 20 - this.diameter)
|
|
| 46 |
this.x = _game_.width - 20 - this.diameter;
|
|
| 47 |
if (this.y >= _game_.height - 20 - this.diameter)
|
|
| 48 |
this.y = _game_.height - 20 - this.diameter;
|
|
| 49 |
if (this.x <= this.diameter + 20)
|
|
| 50 |
this.x = this.diameter + 20;
|
|
| 51 |
if (this.y <= this.diameter + 20)
|
|
| 52 |
this.y = this.diameter + 20;
|
|
| 45 |
if (this.x >= _game_.width - 10 - this.diameter)
|
|
| 46 |
this.x = _game_.width - 10 - this.diameter;
|
|
| 47 |
if (this.y >= _game_.height - 10 - this.diameter)
|
|
| 48 |
this.y = _game_.height - 10 - this.diameter;
|
|
| 49 |
if (this.x <= this.diameter + 10)
|
|
| 50 |
this.x = this.diameter + 10;
|
|
| 51 |
if (this.y <= this.diameter + 10)
|
|
| 52 |
this.y = this.diameter + 10;
|
|
| 53 | 53 |
|
| 54 | 54 |
// if (this.input.fire () && (this.jammed == false)) |
| 55 | 55 |
// {
|
| ... | ... | |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 | 69 |
fill (1); |
| 70 |
stroke (255, 75); |
|
| 71 |
strokeWeight (3); |
|
| 70 |
noStroke(); |
|
| 72 | 71 |
ellipse (this.x, this.y, this.diameter, this.diameter); |
| 73 |
strokeWeight (1); |
|
| 74 | 72 |
} |
| 75 | 73 |
|
| 76 | 74 |
void fire () |
| ... | ... | |
| 92 | 90 |
{
|
| 93 | 91 |
Blackmatter matter = new Blackmatter (); |
| 94 | 92 |
|
| 95 |
matter.x = int (random (20, _game_.width - 20)); |
|
| 96 |
matter.y = int (random (20, _game_.height - 20)); |
|
| 93 |
// matter.x = int (random (20, _game_.width - 20)); |
|
| 94 |
// matter.y = int (random (20, _game_.height - 20)); |
|
| 95 |
|
|
| 96 |
matter.x = this.x; //int (random (20, _game_.width - 20)); |
|
| 97 |
matter.y = this.y; // int (random (20, _game_.height - 20)); |
|
| 98 |
matter.vx = random (-5, 5); |
|
| 99 |
matter.vy = random (-5, 5); |
|
| 100 |
|
|
| 97 | 101 |
|
| 98 | 102 |
matter.setup (); |
| 99 | 103 |
this.blacklord.blackmatter.add (matter); |
| 100 | 104 |
} |
| 101 | 105 |
} |
| 102 |
} |
|
| 106 |
} |
|
| processing/blacklight/Blackmatter.pde | ||
|---|---|---|
| 13 | 13 |
int y = 0; |
| 14 | 14 |
int diameter = 50; |
| 15 | 15 |
boolean dead = false; |
| 16 |
float vx = 0; |
|
| 17 |
float vy = 0; |
|
| 16 | 18 |
|
| 17 | 19 |
void setup () |
| 18 | 20 |
{
|
| ... | ... | |
| 29 | 31 |
|
| 30 | 32 |
ellipse (this.x, this.y, this.diameter, this.diameter); |
| 31 | 33 |
|
| 34 |
|
|
| 35 |
if ( ( this.x + vx <= 0 ) || ( this.x + vx >= _game_.width) ) {
|
|
| 36 |
this.vx = -vx; |
|
| 37 |
} |
|
| 38 |
if ( ( this.y + vy <= 0 ) || ( this.y + vy >= _game_.height) ) {
|
|
| 39 |
this.vy = -vy; |
|
| 40 |
} |
|
| 41 |
|
|
| 42 |
this.x += vx; |
|
| 43 |
this.y += vy; |
|
| 44 |
|
|
| 45 |
|
|
| 32 | 46 |
if (this.diameter > 0) |
| 33 | 47 |
this.diameter--; |
| 34 | 48 |
|
| ... | ... | |
| 67 | 81 |
return false; |
| 68 | 82 |
*/ |
| 69 | 83 |
} |
| 70 |
} |
|
| 84 |
} |
|
Também disponível em: Unified diff