//intro void eyeball(int x, int y) { stroke(1); line(x, y, x, (y+1)); line((x+1), y, (x+1), (y+1)); } ////////////////define functions////////////// void make_slots() { stroke(2); //make slots //slot 1 line(2, 5, 7, 5); line(2, 0, 7, 0); line(2, 5, 2, 0); line(7, 0, 7, 5); //slot 2 line(2, 13, 7, 13); line(2, 8, 7, 8); line(2, 13, 2, 8); line(7, 8, 7, 13); } //dollar sign void dollar_sign(int x, int y) { stroke(1); line(x, y, x, (y+3)); line(x, (y+4), (x+3), (y+4)); line((x+3), y, (x+3), (y+4)); line((x+3), y, (x+6), y); line((x+6), y, (x+6), (y+4)); line((x-1), (y+1), (x+7), (y+1)); line((x-1), (y+3), (x+7), (y+3)); } void reset_outputs() { :0 = 0; :1 = 0; :2 = 0; :3 = 0; :4 = 0; :5 = 0; :6 = 0; :7 = 0; } //make designs void clear(int slot) { stroke(0); if(slot == 1) { line(3, 1, 6, 1); line(3, 2, 6, 2); line(3, 3, 6, 3); line(3, 4, 6, 4); } if(slot == 2) { line(3, 9, 6, 9); line(3, 10, 6, 10); line(3, 11, 6, 11); line(3, 12, 6, 12); } } void design1(int slot) { stroke(1); if(slot == 1) { line(3, 1, 6, 4); line(3, 4, 6, 1); } if(slot == 2) { line(3, 12, 6, 9); line(3, 9, 6, 12); } } void design2(int slot) { stroke(1); if(slot == 1) { line(3, 1, 3, 4); line(3, 1, 6, 1); line(3, 1, 6, 4); } if(slot == 2) { line(3, 9, 6, 9); line(3, 9, 3, 12); line(3, 9, 6, 12); } } void design3(int slot) { stroke(1); if(slot == 1) { line(6, 1, 6, 4); line(6, 4, 3, 4); line(3, 1, 6, 4); } if(slot == 2) { line(6, 9, 6, 12); line(6, 12, 3, 12); line(3, 9, 6, 12); } } void design4(int slot) { stroke(1); if(slot == 1) { line(4, 1, 4, 4); line(5, 1, 5, 4); } if(slot == 2) { line(4, 9, 4, 12); line(5, 9, 5, 12); } } void design5(int slot) { stroke(1); if(slot == 1) { line(3, 2, 3, 3); design4(1); line(6, 2, 6, 3); } if(slot == 2) { line(3, 10, 3, 11); design4(2); line(6, 10, 6, 11); } } void design6(int slot) { stroke(1); if(slot == 1) { line(6, 1, 6, 4); line(5, 2, 5, 3); } if(slot == 2) { line(6, 9, 6, 12); line(5, 10, 5, 11); } } void design7(int slot) { stroke(1); if(slot == 1) { line(3, 1, 3, 4); line(4, 2, 4, 3); } if(slot == 2) { line(3, 9, 3, 12); line(4, 10, 4, 11); } } void design8(int slot) { stroke(1); if(slot == 1) { line(4, 2, 4, 3); line(5, 2, 5, 3); } if(slot == 2) { line(4, 10, 4, 11); line(5, 10, 5, 11); } } //main program //generate random numbers int rseed = 98; int bb = 2987; int mm = 987; int RAND_MIN = 1; int RAND_MAX = 8; int Random() { int bl = (rseed*bb+1); rseed = (bl % mm); return (RAND_MIN + (rseed % (RAND_MAX+1))); } //boolean start_spin = false; int spinning = 0; int slot1 = -1; int slot2 = -2; //initially make slots make_slots(); while(true) { if((@0 == 0) && (@1 == 1)) //spin on and stop off { spinning = 1; } if(spinning == 1) { //spin make_slots(); slot1 = Random(); slot2 = Random(); //clear slots clear(1); clear(2); //spin slot 1 if(slot1 == 1) { design1(1); } else if(slot1 == 2) { design2(1); } else if(slot1 == 3) { design3(1); } else if(slot1 == 4) { design4(1); } else if(slot1 == 5) { design5(1); } else if(slot1 == 6) { design6(1); } else if(slot1 == 7) { design7(1); } else if(slot1 == 8) { design8(1); } else { design1(1); } //spin slot 2 if(slot2 == 1) { design1(2); } else if(slot2 == 2) { design2(2); } else if(slot2 == 3) { design3(2); } else if(slot2 == 4) { design4(2); } else if(slot2 == 5) { design5(2); } else if(slot2 == 6) { design6(2); } else if(slot2 == 7) { design7(2); } else if(slot2 == 8) { design8(2); } else { design1(2); } } if((spinning == 1) && (@1 == 0)) //spin on and stop on { //ignore spin button and check values int i; //both match if(slot1 == slot2) { //you win for(i = 0; i < 5; i++) { if(slot2 == 1) { :0 = 1; } else if(slot2 == 2) { :1 = 1; } else if(slot2 == 3) { :2 = 1; } else if(slot2 == 4) { :3 = 1; } else if(slot2 == 5) { :4 = 1; } else if(slot2 == 6) { :5 = 1; } else if(slot2 == 7) { :6 = 1; } else if(slot2 == 8) { :7 = 1; } else { :0 = 1; } canvas(); dollar_sign(2, 1); dollar_sign(2, 8); pause(10); canvas(); } pause(20); } //none match else { //you lose for(i = 6; i > 2; i--) { line(i, 1, i, 4); line(i, 9, i, 12); pause(10); } } spinning = 0; } if(spinning == 0) { make_slots(); reset_outputs(); //wait and move eyes eyeball(4, 2); eyeball(4, 10); pause(50); clear(1); clear(2); eyeball(4, 1); eyeball(4, 9); pause(55); clear(1); clear(2); eyeball(4, 2); eyeball(4, 10); pause(40); clear(1); clear(2); eyeball(4, 3); eyeball(4, 11); pause(25); clear(1); clear(2); } }