Projeto

Geral

Perfil

Revisão 16

Adicionado por Dinis Adriano Domingosmais de 9 anos atrás

New grid layout

Ver diferenças:

processing/blacklight/data/xml/config.xml
1 1
<?xml version="1.0"?>
2 2
<blacklight>
3 3
  <screen>
4
	  <width>1280</width>
5
	  <height>720</height> 
4
	  <width>1024</width>
5
	  <height>768</height> 
6 6
		<background>FFcccccc</background>
7 7
		<fill>FFAAAAAA</fill>
8 8
	</screen>
processing/blacklight/blacklight.pde
23 23

  
24 24
void setup ()
25 25
  {
26
  size (1280, 720, OPENGL);
26
  size (1024, 768, OPENGL);
27 27
  _root_ = this;
28 28

  
29 29
  
processing/blacklight/Level.pde
35 35
    }  
36 36

  
37 37

  
38
    this.battlefield = new Battlefield (this.width, this.height);
38
    this.battlefield = new Battlefield (1024, 768);
39 39
    this.lightlord = new Lightlord ();
40 40
    this.blacklord = new Blacklord ();
41 41
    this.scoreboard = new Scoreboard ();
processing/blacklight/Battlefield.pde
8 8

  
9 9
class Battlefield
10 10
{
11
  int videoScale = 80;
12
  int width = 1280;
13
  int height = 720;
11
  int videoScale = 64;
12
  int width;
13
  int height;
14 14

  
15 15
  int blacks = 0;
16 16
  int whites = 0;
......
22 22

  
23 23
  Battlefield (int w, int h)
24 24
  {
25
    this.width = 1280;
26
    this.height = 720;
25
    this.width = w;
26
    this.height = h;
27 27

  
28 28
    println ("Battlefield " + this.width + "x" + this.height + " created");
29 29
  }
......
35 35
  }
36 36

  
37 37
  void draw() {
38
    background(159, 182, 205);
38
   // background(159, 182, 205);
39
   background(100);
39 40

  
40 41
    this.blacks = 0;
41 42
    this.whites = 0;
......
43 44
    for (int i = 0; i < this.cells.length; i++) { 
44 45
      //rows
45 46
      for (int j = 0; j < this.cells[i].length; j++) {
46
        this.cells [i][j].setup ( this.cells[i][j].lifeBar, this.cells[i][j].animating );
47
        this.cells [i][j].setup ( this.cells[i][j].lifeBar, this.cells[i][j].animating, this.videoScale );
47 48
        this.cells [i][j].draw();
48 49

  
49 50
        if (this.cells [i][j].isWhite ())
processing/blacklight/Cell.pde
16 16

  
17 17
  int animX = 0;
18 18
  int animY = 0;
19

  
19
 
20
 int fillBlack = 0;
21
 int fillWhite = 255;
22
 int fillNeutral = 127;
23
 int opacity = 50;
24
 
20 25
  // Propreties
21 26
  int lifeBar = 127;
22 27
  Boolean animating = false;
......
39 44
   * and state from cell in same position
40 45
   *
41 46
   ***************************************************/
42
  void setup ( int lifeBar, Boolean animating ) {
47
  void setup ( int lifeBar, Boolean animating, int cellArea ) {
43 48
    this.lifeBar = lifeBar;
44 49
    this.animating = animating;
45 50
    this.side = side;
......
48 53
    if (this.lifeBar >= 255) this.lifeBar = 255; 
49 54
    if (this.lifeBar <= 0) this.lifeBar = 0; 
50 55

  
51
    stroke (159, 182, 205);
56
    stroke (150, this.opacity);
52 57
    strokeWeight (2);
53 58

  
54 59
    // paints cell according to side
55 60
    switch(this.side) {
56 61
    case 2: 
57
      fill(127); 
62
      fill( this.fillNeutral, this.opacity ); 
58 63
      break;
59 64
    case 0: 
60
      fill(255); 
65
      fill( this.fillWhite, this.opacity ); 
61 66
      break;
62 67
    case 1: 
63
      fill(0); 
68
      fill( this.fillBlack, this.opacity ); 
64 69
      break;
65 70
    }
66 71
  };
......
71 76

  
72 77
    // if is not between animation draw cell and circle color
73 78
    if ( this.animating == false ) {
79
      fill(lifeBar, this.opacity + 20 ) ;
74 80
      rect ( posX, posY, area, area );
75
      fill(lifeBar) ;
76
      noStroke();
81
      
82
    //  noStroke();
77 83
      // arc(this.posX + 40, this.posY + 40, 30, 30, 0, 360);
78
      ellipse(this.posX + 40, this.posY + 40, 30, 30);
84
      //ellipse(this.posX + (this.area / 2 ), this.posY + ( this.area / 2), 30, 30);
79 85
    }
80 86

  
81 87
    // if white conquers plays animate white
82 88
    if (this.isWhite () && (this.side != 0)) {
83 89
      this.lifeBar = 255;
84
      animateCell(255, 0);
90
      animateCell( this.fillWhite, 0);
85 91
    }
86 92

  
87 93
    // if black conquers plays animate black
88 94
    if (this.isBlack () && (this.side != 1)) {
89 95
      this.lifeBar = 0;
90
      animateCell(0, 1);
96
      animateCell( this.fillBlack , 1);
91 97
    }
92 98
  }
93 99
  boolean isWhite ()
......
138 144
  void animateCell( int clr, int side ) {
139 145
    this.animating = true;
140 146
    if (  animX <= this.area) {
147
      fill(clr, this.opacity );  
141 148
      
142 149
      //this is a mess got to solve better
143
      if ( animX > area /2 ) {
144
        fill(clr);        
150
     /* if ( animX > area /2 ) {
151
        fill(clr, this.opacity );        
145 152
        //print("animX " + animX);
146 153
      } else if ( this.side != 2 ) {
147 154
        switch(this.side) {
148 155
        case 0: 
149
          fill(255); 
156
        println("fillWhite");
157
          fill( this.fillWhite, this.opacity );
150 158
          break;
151 159
        case 1: 
152
          fill(0); 
160
          fill( this.fillBlack, this.opacity ); 
153 161
          break;
154 162
        }
155 163
      } else {
156
        fill(127);
157
      }
164
        fill( this.fillNeutral, this.opacity );
165
      }*/
158 166
      
167
      noStroke();
159 168
      rect ( posX + animX, posY, area - animX * 2, area);
160 169
      
161 170
    } else {
......
165 174

  
166 175
      // draw last frame animated to prevent blinking
167 176
      if ( this.side == 0 ) 
168
        fill(255);
177
        fill( this.fillWhite, this.opacity + 20 );
169 178
      else if ( this.side == 1 )
170
        fill(0);
179
        fill( this.fillBlack, this.opacity + 20);
171 180

  
172 181
      rect ( posX + animX, posY, area - animX * 2, area);
173 182
    }
174
    animX +=3*0.7;
175
    animY += 3;
183
    animX +=5*0.9;
184
    animY += 5;
176 185
  };
177 186
  
178 187
}

Também disponível em: Unified diff