Projeto

Geral

Perfil

Revisão 16

Adicionado por Dinis Adriano Domingosmais de 9 anos atrás

New grid layout

Ver diferenças:

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