4x4x4 LED CUBE CODE

Dependencies:   mbed

Committer:
TheOneNamedS
Date:
Thu Mar 07 21:09:04 2013 +0000
Revision:
0:6ee2b9c3c22c
First Release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TheOneNamedS 0:6ee2b9c3c22c 1 #include "mbed.h"
TheOneNamedS 0:6ee2b9c3c22c 2 #include "stdlib.h"
TheOneNamedS 0:6ee2b9c3c22c 3
TheOneNamedS 0:6ee2b9c3c22c 4 DigitalOut myled(LED1);
TheOneNamedS 0:6ee2b9c3c22c 5
TheOneNamedS 0:6ee2b9c3c22c 6 // 8 bit bus to control two FF's
TheOneNamedS 0:6ee2b9c3c22c 7 DigitalOut d0(p10);
TheOneNamedS 0:6ee2b9c3c22c 8 DigitalOut d1(p11);
TheOneNamedS 0:6ee2b9c3c22c 9 DigitalOut d2(p12);
TheOneNamedS 0:6ee2b9c3c22c 10 DigitalOut d3(p13);
TheOneNamedS 0:6ee2b9c3c22c 11 DigitalOut d4(p14);
TheOneNamedS 0:6ee2b9c3c22c 12 DigitalOut d5(p15);
TheOneNamedS 0:6ee2b9c3c22c 13 DigitalOut d6(p16);
TheOneNamedS 0:6ee2b9c3c22c 14 DigitalOut d7(p17);
TheOneNamedS 0:6ee2b9c3c22c 15
TheOneNamedS 0:6ee2b9c3c22c 16 // Two pins for the CP pins on the FF's
TheOneNamedS 0:6ee2b9c3c22c 17 DigitalOut cp0(p22);
TheOneNamedS 0:6ee2b9c3c22c 18 DigitalOut cp1(p21);
TheOneNamedS 0:6ee2b9c3c22c 19
TheOneNamedS 0:6ee2b9c3c22c 20 // Two pins for the input to to the 3 to 8 decoder
TheOneNamedS 0:6ee2b9c3c22c 21 DigitalOut a0(p24);
TheOneNamedS 0:6ee2b9c3c22c 22 DigitalOut a1(p23);
TheOneNamedS 0:6ee2b9c3c22c 23
TheOneNamedS 0:6ee2b9c3c22c 24 // 4 x 4 x 4 Cube
TheOneNamedS 0:6ee2b9c3c22c 25 const int SIDE = 4;
TheOneNamedS 0:6ee2b9c3c22c 26
TheOneNamedS 0:6ee2b9c3c22c 27 void drawLayer(int*, int);
TheOneNamedS 0:6ee2b9c3c22c 28 void selPin(int, int);
TheOneNamedS 0:6ee2b9c3c22c 29 void selLED(int*, int);
TheOneNamedS 0:6ee2b9c3c22c 30 void clear(int);
TheOneNamedS 0:6ee2b9c3c22c 31 void RotZ(int*);
TheOneNamedS 0:6ee2b9c3c22c 32 void DrawCube(int* cube);
TheOneNamedS 0:6ee2b9c3c22c 33 void effect_rain(int, double);
TheOneNamedS 0:6ee2b9c3c22c 34
TheOneNamedS 0:6ee2b9c3c22c 35 const double alph = 0.3827; // sin(22.5*)
TheOneNamedS 0:6ee2b9c3c22c 36 const double bet = 0.9239; // cos(22.5*)
TheOneNamedS 0:6ee2b9c3c22c 37 enum
TheOneNamedS 0:6ee2b9c3c22c 38 {
TheOneNamedS 0:6ee2b9c3c22c 39 XDIM, YDIM, ZDIM
TheOneNamedS 0:6ee2b9c3c22c 40 } DIM;
TheOneNamedS 0:6ee2b9c3c22c 41
TheOneNamedS 0:6ee2b9c3c22c 42 int EMPTYARRAY[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
TheOneNamedS 0:6ee2b9c3c22c 43
TheOneNamedS 0:6ee2b9c3c22c 44 int main() {
TheOneNamedS 0:6ee2b9c3c22c 45 void effect_rand(int);
TheOneNamedS 0:6ee2b9c3c22c 46 void effect_box(int);
TheOneNamedS 0:6ee2b9c3c22c 47 void clearAll();
TheOneNamedS 0:6ee2b9c3c22c 48 // int layer[16] = {1,0,0,1,1,0,0,0,1,1,0,1,1,1,0,1};
TheOneNamedS 0:6ee2b9c3c22c 49 int layer[16] = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1};
TheOneNamedS 0:6ee2b9c3c22c 50 int cube[64] = {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1};
TheOneNamedS 0:6ee2b9c3c22c 51 // layer[0] = 1;
TheOneNamedS 0:6ee2b9c3c22c 52 // layer[3] = 1;
TheOneNamedS 0:6ee2b9c3c22c 53 // layer[3] = 1;
TheOneNamedS 0:6ee2b9c3c22c 54 // layer[3] = 1;
TheOneNamedS 0:6ee2b9c3c22c 55 // layer[4] = 1;
TheOneNamedS 0:6ee2b9c3c22c 56 // layer[8] = 1;
TheOneNamedS 0:6ee2b9c3c22c 57 // layer[9] = 1;
TheOneNamedS 0:6ee2b9c3c22c 58 // layer[11] = 1;
TheOneNamedS 0:6ee2b9c3c22c 59 // layer[12] = 1;
TheOneNamedS 0:6ee2b9c3c22c 60 // layer[13] = 1;
TheOneNamedS 0:6ee2b9c3c22c 61 // layer[15] = 1;
TheOneNamedS 0:6ee2b9c3c22c 62 int x = 0;
TheOneNamedS 0:6ee2b9c3c22c 63 int y = 0;
TheOneNamedS 0:6ee2b9c3c22c 64 srand(546);
TheOneNamedS 0:6ee2b9c3c22c 65 int t = 0;
TheOneNamedS 0:6ee2b9c3c22c 66 while(1){
TheOneNamedS 0:6ee2b9c3c22c 67 // DrawCube(cube);
TheOneNamedS 0:6ee2b9c3c22c 68 // if(t>1000){
TheOneNamedS 0:6ee2b9c3c22c 69 // for(int j = 0; j<64; ++j){
TheOneNamedS 0:6ee2b9c3c22c 70 // cube[j] = rand() % 2;}
TheOneNamedS 0:6ee2b9c3c22c 71 // t=0;
TheOneNamedS 0:6ee2b9c3c22c 72 clearAll();wait(1);
TheOneNamedS 0:6ee2b9c3c22c 73 effect_rand(8000);
TheOneNamedS 0:6ee2b9c3c22c 74 clearAll();wait(1);
TheOneNamedS 0:6ee2b9c3c22c 75 effect_box(8000);
TheOneNamedS 0:6ee2b9c3c22c 76 clearAll();wait(1);
TheOneNamedS 0:6ee2b9c3c22c 77 effect_rain(15, 0.16);
TheOneNamedS 0:6ee2b9c3c22c 78
TheOneNamedS 0:6ee2b9c3c22c 79 }
TheOneNamedS 0:6ee2b9c3c22c 80 // ++t;
TheOneNamedS 0:6ee2b9c3c22c 81
TheOneNamedS 0:6ee2b9c3c22c 82 }
TheOneNamedS 0:6ee2b9c3c22c 83 // Draw a layer using a 16 int array (SIDE*SIDE)
TheOneNamedS 0:6ee2b9c3c22c 84 void drawLayer(int* layer, int selLayer){
TheOneNamedS 0:6ee2b9c3c22c 85 switch(selLayer){
TheOneNamedS 0:6ee2b9c3c22c 86 case 0:
TheOneNamedS 0:6ee2b9c3c22c 87 a0 = 0;
TheOneNamedS 0:6ee2b9c3c22c 88 a1 = 0;
TheOneNamedS 0:6ee2b9c3c22c 89 break;
TheOneNamedS 0:6ee2b9c3c22c 90 case 1:
TheOneNamedS 0:6ee2b9c3c22c 91 a0 = 1;
TheOneNamedS 0:6ee2b9c3c22c 92 a1 = 0;
TheOneNamedS 0:6ee2b9c3c22c 93 break;
TheOneNamedS 0:6ee2b9c3c22c 94 case 2:
TheOneNamedS 0:6ee2b9c3c22c 95 a0 = 0;
TheOneNamedS 0:6ee2b9c3c22c 96 a1 = 1;
TheOneNamedS 0:6ee2b9c3c22c 97 break;
TheOneNamedS 0:6ee2b9c3c22c 98 case 3:
TheOneNamedS 0:6ee2b9c3c22c 99 a0 = 1;
TheOneNamedS 0:6ee2b9c3c22c 100 a1 = 1;
TheOneNamedS 0:6ee2b9c3c22c 101 break;
TheOneNamedS 0:6ee2b9c3c22c 102 }
TheOneNamedS 0:6ee2b9c3c22c 103
TheOneNamedS 0:6ee2b9c3c22c 104 for(int i = 0; i < (SIDE*SIDE); i+=8){
TheOneNamedS 0:6ee2b9c3c22c 105 int ffSel = i >> 3; // divide by 8 to determine which FF (will give 0 or 1)
TheOneNamedS 0:6ee2b9c3c22c 106 selLED(layer+ffSel*8, ffSel);
TheOneNamedS 0:6ee2b9c3c22c 107 }
TheOneNamedS 0:6ee2b9c3c22c 108 }
TheOneNamedS 0:6ee2b9c3c22c 109 // selLED will turn on the selected LEDS on a layer (8 at a time)
TheOneNamedS 0:6ee2b9c3c22c 110 // cp = 0 for first FF
TheOneNamedS 0:6ee2b9c3c22c 111 // cp = 1 for second FF
TheOneNamedS 0:6ee2b9c3c22c 112 void selLED(int* ffOut, int cp){
TheOneNamedS 0:6ee2b9c3c22c 113 // change data, bring latch low then high to latch input to output
TheOneNamedS 0:6ee2b9c3c22c 114 for(int i = 0; i < 8; i++){
TheOneNamedS 0:6ee2b9c3c22c 115 selPin(i, ffOut[i]);
TheOneNamedS 0:6ee2b9c3c22c 116 }
TheOneNamedS 0:6ee2b9c3c22c 117 if(cp == 0){
TheOneNamedS 0:6ee2b9c3c22c 118 cp0 = 0; // pull latch low
TheOneNamedS 0:6ee2b9c3c22c 119 // wait() ??
TheOneNamedS 0:6ee2b9c3c22c 120 cp0 = 1;
TheOneNamedS 0:6ee2b9c3c22c 121 cp1 = 0;
TheOneNamedS 0:6ee2b9c3c22c 122 }
TheOneNamedS 0:6ee2b9c3c22c 123 if(cp == 1){
TheOneNamedS 0:6ee2b9c3c22c 124 cp1 = 0; // pull latch low
TheOneNamedS 0:6ee2b9c3c22c 125 // wait() ??
TheOneNamedS 0:6ee2b9c3c22c 126 cp0 = 0;
TheOneNamedS 0:6ee2b9c3c22c 127 cp1 = 1;
TheOneNamedS 0:6ee2b9c3c22c 128 }
TheOneNamedS 0:6ee2b9c3c22c 129 }
TheOneNamedS 0:6ee2b9c3c22c 130
TheOneNamedS 0:6ee2b9c3c22c 131 // Turn the selected pin on the FF to the input value
TheOneNamedS 0:6ee2b9c3c22c 132 void selPin(int i, int val){
TheOneNamedS 0:6ee2b9c3c22c 133 switch(i){
TheOneNamedS 0:6ee2b9c3c22c 134 case 0:
TheOneNamedS 0:6ee2b9c3c22c 135 d0 = val;
TheOneNamedS 0:6ee2b9c3c22c 136 break;
TheOneNamedS 0:6ee2b9c3c22c 137 case 1:
TheOneNamedS 0:6ee2b9c3c22c 138 d1 = val;
TheOneNamedS 0:6ee2b9c3c22c 139 break;
TheOneNamedS 0:6ee2b9c3c22c 140 case 2:
TheOneNamedS 0:6ee2b9c3c22c 141 d2 = val;
TheOneNamedS 0:6ee2b9c3c22c 142 break;
TheOneNamedS 0:6ee2b9c3c22c 143 case 3:
TheOneNamedS 0:6ee2b9c3c22c 144 d3 = val;
TheOneNamedS 0:6ee2b9c3c22c 145 break;
TheOneNamedS 0:6ee2b9c3c22c 146 case 4:
TheOneNamedS 0:6ee2b9c3c22c 147 d4 = val;
TheOneNamedS 0:6ee2b9c3c22c 148 break;
TheOneNamedS 0:6ee2b9c3c22c 149 case 5:
TheOneNamedS 0:6ee2b9c3c22c 150 d5 = val;
TheOneNamedS 0:6ee2b9c3c22c 151 break;
TheOneNamedS 0:6ee2b9c3c22c 152 case 6:
TheOneNamedS 0:6ee2b9c3c22c 153 d6 = val;
TheOneNamedS 0:6ee2b9c3c22c 154 break;
TheOneNamedS 0:6ee2b9c3c22c 155 case 7:
TheOneNamedS 0:6ee2b9c3c22c 156 d7 = val;
TheOneNamedS 0:6ee2b9c3c22c 157 break;
TheOneNamedS 0:6ee2b9c3c22c 158 }
TheOneNamedS 0:6ee2b9c3c22c 159 }
TheOneNamedS 0:6ee2b9c3c22c 160
TheOneNamedS 0:6ee2b9c3c22c 161 // Random voxels light up at the top layer and falls to the bottom layer.
TheOneNamedS 0:6ee2b9c3c22c 162 void effect_rain (int iterations, double speed){
TheOneNamedS 0:6ee2b9c3c22c 163 int numi = 70;
TheOneNamedS 0:6ee2b9c3c22c 164 int count = 0;
TheOneNamedS 0:6ee2b9c3c22c 165
TheOneNamedS 0:6ee2b9c3c22c 166 int layer[16];
TheOneNamedS 0:6ee2b9c3c22c 167 int layer2[16];
TheOneNamedS 0:6ee2b9c3c22c 168 count = 0;
TheOneNamedS 0:6ee2b9c3c22c 169
TheOneNamedS 0:6ee2b9c3c22c 170 /* count = 0;
TheOneNamedS 0:6ee2b9c3c22c 171 while ( !(count > 0 && count <=3)){
TheOneNamedS 0:6ee2b9c3c22c 172 count = 0;
TheOneNamedS 0:6ee2b9c3c22c 173 for(int i = 0; i < 16; i++){
TheOneNamedS 0:6ee2b9c3c22c 174 layer2[i] = rand() % 2;
TheOneNamedS 0:6ee2b9c3c22c 175 if(layer2[i]) count++;
TheOneNamedS 0:6ee2b9c3c22c 176 }
TheOneNamedS 0:6ee2b9c3c22c 177 }
TheOneNamedS 0:6ee2b9c3c22c 178 */
TheOneNamedS 0:6ee2b9c3c22c 179 clear(3); clear(2); clear(1); clear(0);
TheOneNamedS 0:6ee2b9c3c22c 180
TheOneNamedS 0:6ee2b9c3c22c 181 int i = 0;
TheOneNamedS 0:6ee2b9c3c22c 182 while(i < iterations){
TheOneNamedS 0:6ee2b9c3c22c 183 count = 0;
TheOneNamedS 0:6ee2b9c3c22c 184 // Get new L1
TheOneNamedS 0:6ee2b9c3c22c 185 while ( !(count > 0 && count <=3)){
TheOneNamedS 0:6ee2b9c3c22c 186 count = 0;
TheOneNamedS 0:6ee2b9c3c22c 187 for(int i = 0; i < 16; i++){
TheOneNamedS 0:6ee2b9c3c22c 188 layer[i] = rand() % 2;
TheOneNamedS 0:6ee2b9c3c22c 189 if(layer[i]) count++;
TheOneNamedS 0:6ee2b9c3c22c 190 }
TheOneNamedS 0:6ee2b9c3c22c 191 }
TheOneNamedS 0:6ee2b9c3c22c 192
TheOneNamedS 0:6ee2b9c3c22c 193 clear(0);clear(2);
TheOneNamedS 0:6ee2b9c3c22c 194 for(int test = 0 ; test < numi ; test++){
TheOneNamedS 0:6ee2b9c3c22c 195 clear(1);
TheOneNamedS 0:6ee2b9c3c22c 196 drawLayer(layer, 3);
TheOneNamedS 0:6ee2b9c3c22c 197 wait(0.001);
TheOneNamedS 0:6ee2b9c3c22c 198 clear(3);
TheOneNamedS 0:6ee2b9c3c22c 199 drawLayer(layer2,1);
TheOneNamedS 0:6ee2b9c3c22c 200 wait(0.001);
TheOneNamedS 0:6ee2b9c3c22c 201 }
TheOneNamedS 0:6ee2b9c3c22c 202
TheOneNamedS 0:6ee2b9c3c22c 203 clear(3);clear(1);
TheOneNamedS 0:6ee2b9c3c22c 204 for(int test = 0 ; test < numi ; test++){
TheOneNamedS 0:6ee2b9c3c22c 205 drawLayer(layer, 2);
TheOneNamedS 0:6ee2b9c3c22c 206 wait(0.001);
TheOneNamedS 0:6ee2b9c3c22c 207 clear(2);
TheOneNamedS 0:6ee2b9c3c22c 208 drawLayer(layer2,0);
TheOneNamedS 0:6ee2b9c3c22c 209 wait(0.001);
TheOneNamedS 0:6ee2b9c3c22c 210 clear(0);
TheOneNamedS 0:6ee2b9c3c22c 211 }
TheOneNamedS 0:6ee2b9c3c22c 212 // Swap layer
TheOneNamedS 0:6ee2b9c3c22c 213 for(int i = 0 ; i<16 ;i++){
TheOneNamedS 0:6ee2b9c3c22c 214 layer2[i]=layer[i];
TheOneNamedS 0:6ee2b9c3c22c 215 }
TheOneNamedS 0:6ee2b9c3c22c 216 // Get new L1
TheOneNamedS 0:6ee2b9c3c22c 217 count = 0;
TheOneNamedS 0:6ee2b9c3c22c 218 while ( !(count > 0 && count <=3)){
TheOneNamedS 0:6ee2b9c3c22c 219 count = 0;
TheOneNamedS 0:6ee2b9c3c22c 220 for(int i = 0; i < 16; i++){
TheOneNamedS 0:6ee2b9c3c22c 221 layer[i] = rand() % 2;
TheOneNamedS 0:6ee2b9c3c22c 222 if(layer[i]) count++;
TheOneNamedS 0:6ee2b9c3c22c 223 }
TheOneNamedS 0:6ee2b9c3c22c 224 }
TheOneNamedS 0:6ee2b9c3c22c 225
TheOneNamedS 0:6ee2b9c3c22c 226 clear(2);clear(0);
TheOneNamedS 0:6ee2b9c3c22c 227 for(int test = 0 ; test < numi; test++){
TheOneNamedS 0:6ee2b9c3c22c 228 drawLayer(layer2, 1);
TheOneNamedS 0:6ee2b9c3c22c 229 wait(0.001);
TheOneNamedS 0:6ee2b9c3c22c 230 clear(1);
TheOneNamedS 0:6ee2b9c3c22c 231 drawLayer(layer,3);
TheOneNamedS 0:6ee2b9c3c22c 232 wait(0.001);
TheOneNamedS 0:6ee2b9c3c22c 233 clear(3);
TheOneNamedS 0:6ee2b9c3c22c 234 }
TheOneNamedS 0:6ee2b9c3c22c 235 //wait(speed);
TheOneNamedS 0:6ee2b9c3c22c 236
TheOneNamedS 0:6ee2b9c3c22c 237 clear(1);clear(3);
TheOneNamedS 0:6ee2b9c3c22c 238 for(int test = 0 ; test < numi ; test++){
TheOneNamedS 0:6ee2b9c3c22c 239 drawLayer(layer2, 0);
TheOneNamedS 0:6ee2b9c3c22c 240 wait(0.001);
TheOneNamedS 0:6ee2b9c3c22c 241 clear(0);
TheOneNamedS 0:6ee2b9c3c22c 242 drawLayer(layer,2);
TheOneNamedS 0:6ee2b9c3c22c 243 wait(0.001);
TheOneNamedS 0:6ee2b9c3c22c 244 clear(2);
TheOneNamedS 0:6ee2b9c3c22c 245 }
TheOneNamedS 0:6ee2b9c3c22c 246 // Swap layer
TheOneNamedS 0:6ee2b9c3c22c 247 for(int i = 0 ; i<16 ;i++){
TheOneNamedS 0:6ee2b9c3c22c 248 layer2[i]=layer[i];
TheOneNamedS 0:6ee2b9c3c22c 249 }
TheOneNamedS 0:6ee2b9c3c22c 250 i++;
TheOneNamedS 0:6ee2b9c3c22c 251 }
TheOneNamedS 0:6ee2b9c3c22c 252
TheOneNamedS 0:6ee2b9c3c22c 253 }
TheOneNamedS 0:6ee2b9c3c22c 254
TheOneNamedS 0:6ee2b9c3c22c 255 void RotZ(int* cube){
TheOneNamedS 0:6ee2b9c3c22c 256 int x,y,z = 0; // init coordinates
TheOneNamedS 0:6ee2b9c3c22c 257 int temp[SIDE*SIDE*SIDE];
TheOneNamedS 0:6ee2b9c3c22c 258 int* ptemp = &temp[0];
TheOneNamedS 0:6ee2b9c3c22c 259 int newx,newy,newz;
TheOneNamedS 0:6ee2b9c3c22c 260
TheOneNamedS 0:6ee2b9c3c22c 261 for(int i = 0; i < SIDE*SIDE*SIDE ; i++){
TheOneNamedS 0:6ee2b9c3c22c 262 z = i/(SIDE*SIDE);
TheOneNamedS 0:6ee2b9c3c22c 263 int newi = i - z*SIDE*SIDE;
TheOneNamedS 0:6ee2b9c3c22c 264 y = newi / SIDE;
TheOneNamedS 0:6ee2b9c3c22c 265 x = newi - y*SIDE;
TheOneNamedS 0:6ee2b9c3c22c 266
TheOneNamedS 0:6ee2b9c3c22c 267 newx = bet*x - alph*y;
TheOneNamedS 0:6ee2b9c3c22c 268 newy = alph*x + bet*y;
TheOneNamedS 0:6ee2b9c3c22c 269 newz = z;
TheOneNamedS 0:6ee2b9c3c22c 270 ptemp[SIDE*SIDE*newz + SIDE*newy + newx] = 1;
TheOneNamedS 0:6ee2b9c3c22c 271 }
TheOneNamedS 0:6ee2b9c3c22c 272
TheOneNamedS 0:6ee2b9c3c22c 273 for(int i = 0; i < SIDE*SIDE*SIDE ; i++){
TheOneNamedS 0:6ee2b9c3c22c 274 cube[i] = ptemp[i];
TheOneNamedS 0:6ee2b9c3c22c 275 }
TheOneNamedS 0:6ee2b9c3c22c 276
TheOneNamedS 0:6ee2b9c3c22c 277 }
TheOneNamedS 0:6ee2b9c3c22c 278
TheOneNamedS 0:6ee2b9c3c22c 279 void DrawCube(int* cube){
TheOneNamedS 0:6ee2b9c3c22c 280 double t = 0.45;
TheOneNamedS 0:6ee2b9c3c22c 281 for(int i = 0; i<SIDE*SIDE*SIDE ; i+= SIDE*SIDE){
TheOneNamedS 0:6ee2b9c3c22c 282 drawLayer(EMPTYARRAY, i/(SIDE*SIDE));
TheOneNamedS 0:6ee2b9c3c22c 283 drawLayer((cube+i),i/(SIDE*SIDE));
TheOneNamedS 0:6ee2b9c3c22c 284 wait(0.0001);
TheOneNamedS 0:6ee2b9c3c22c 285 }
TheOneNamedS 0:6ee2b9c3c22c 286
TheOneNamedS 0:6ee2b9c3c22c 287 }
TheOneNamedS 0:6ee2b9c3c22c 288
TheOneNamedS 0:6ee2b9c3c22c 289 void clear(int layer){
TheOneNamedS 0:6ee2b9c3c22c 290 drawLayer(EMPTYARRAY, layer);
TheOneNamedS 0:6ee2b9c3c22c 291 }
TheOneNamedS 0:6ee2b9c3c22c 292
TheOneNamedS 0:6ee2b9c3c22c 293 void effect_rand(int it){
TheOneNamedS 0:6ee2b9c3c22c 294 int i = 0;
TheOneNamedS 0:6ee2b9c3c22c 295 int cube[64];
TheOneNamedS 0:6ee2b9c3c22c 296 int x = 0;
TheOneNamedS 0:6ee2b9c3c22c 297 while (i<it){
TheOneNamedS 0:6ee2b9c3c22c 298
TheOneNamedS 0:6ee2b9c3c22c 299 if(x > 500){
TheOneNamedS 0:6ee2b9c3c22c 300 for(int k = 0; k < 64 ; k++){
TheOneNamedS 0:6ee2b9c3c22c 301 cube[k] = rand() % 2;
TheOneNamedS 0:6ee2b9c3c22c 302 }
TheOneNamedS 0:6ee2b9c3c22c 303 x = 0;
TheOneNamedS 0:6ee2b9c3c22c 304 }
TheOneNamedS 0:6ee2b9c3c22c 305 DrawCube(cube);
TheOneNamedS 0:6ee2b9c3c22c 306 x++;
TheOneNamedS 0:6ee2b9c3c22c 307
TheOneNamedS 0:6ee2b9c3c22c 308
TheOneNamedS 0:6ee2b9c3c22c 309 i++;
TheOneNamedS 0:6ee2b9c3c22c 310 }
TheOneNamedS 0:6ee2b9c3c22c 311
TheOneNamedS 0:6ee2b9c3c22c 312 }
TheOneNamedS 0:6ee2b9c3c22c 313 void effect_box(int it){
TheOneNamedS 0:6ee2b9c3c22c 314
TheOneNamedS 0:6ee2b9c3c22c 315 int cube[64] = {1,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1, 1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1, 1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1, 1,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1};
TheOneNamedS 0:6ee2b9c3c22c 316 int i = 0;
TheOneNamedS 0:6ee2b9c3c22c 317 while(i < it){i++;
TheOneNamedS 0:6ee2b9c3c22c 318 DrawCube(cube);
TheOneNamedS 0:6ee2b9c3c22c 319 }
TheOneNamedS 0:6ee2b9c3c22c 320
TheOneNamedS 0:6ee2b9c3c22c 321 }
TheOneNamedS 0:6ee2b9c3c22c 322
TheOneNamedS 0:6ee2b9c3c22c 323 void clearAll(){clear(0);clear(1);clear(2);clear(3);}