Here's some more information that I was asked for at: Projects – Make: DIY Projects and Ideas for Makers
So, I've included another feature into my gaming machine, a keno( a kind of lottery, you know)-machine. The keno system gives a (rather) randomly 8 numbers, or dots, for that matter, every one second. It stops changing numbers after a pushbutton is pressed, and gives 13 more more dots, the winning dots. Then the system counts the number of the dots which are common between player's and machine's rows. If there's enough common dots, the machine gives a payout equal to the amount of right dots. Since the numbers are given (quite) randomly, I've included a code snippet which double checks if there are two or more dots in player's or machine's row sharing one coordinate in the matrix. If it finds one, (eg. your row would have only 7 dots, not 8 like it should) it gives another coordinates for one of the two dots in same place and checks them too. All this happens before player sees any of his/her numbers. It's not perfect system, but I have played about 300 rounds of my keno and never saw only 7 dots in my row.
The other four game modes should become quite clear on the video.
There's also a nice memory for intros in my system; it will show intros only once before getting to the desired game mode, not every time you enter to mode selection and choose the same mode you played earlier.
Btw, the name 'Pelikone' means 'A game machine' in finnish.
Edit: Individual letters are no more shown in the beginning (like on the video), since I replaced them with a scrolling text.
And here's my way badly commented code. It has over 860 lines and compiles to 13874 bytes, and since I hadn't commented it when I coded it, it would be too tough task to do completely. I added some comments to it, though. For clearance, I'll say that here: I have wired my system so that it needs a coin to register any push button pushes. It's possible to reduce the size of my sketch significantly, and I tried to include sounds into it, but they sounded so bad that I removed them.
//Code by Timo Herva, timo.herva@gmail.com
#include <Matrix.h>
#include <binary.h>
#include <Sprite.h>
Matrix mymatrix = Matrix(12, 11, 10);
//some important pins
int power = 7;
int push = 6;
int sole1 = 4;
int sole2 = 3;
//Arrays for your numbers in keno
int vary[] = {0, 1, 2, 3, 4, 5, 6, 7};
int varx[] = {0, 0, 0, 0, 0, 0, 0, 0};
//Arrays for machine's numbers in keno
int kenox[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int kenoy[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
//variables for other game modes
int valx1 = 0;
int valx2 = 0;
int valx3 = 0;
int valx4 = 0;
int valy1 = 0;
int valy2 = 0;
int valy3 = 0;
int valy4 = 0;
int xvar = 7;
//Should be quite clear
int kenopayout = 0;
int kenonumbers = 0;
int randomdelay = 0;
int delaytime = 100;
int leddelay = 100;
int multiply = 0;
//pin for a potentiometer
int analog = 3;
//250 lines of definitions for needed alphabet, numbers,...
Sprite arrow = Sprite(
8, 8,
B00000000,
B01111100,
B01100000,
B01010000,
B01001000,
B01000100,
B00000010,
B00000001
);
Sprite line = Sprite(
1, 8,
B1,
B1,
B1,
B1,
B1,
B1,
B1,
B1
);
Sprite hline = Sprite(
8, 1,
B11111111
);
//some badly named variables
int gamemode = 1;
int x = 8;
int x2 = 8;
int y2 = 0;
int y = 8;
int z = 0;
int q = 0;
int w = 0;
int m = 0;
int r = 0;
int t = 0;
int p = 0;
int u = 0;
int j = 0;
int keno = 0;
Sprite smiley = Sprite(
6, 5,
B010010,
B010010,
B000000,
B100001,
B011110
);
Sprite unsmiley = Sprite(
6, 5,
B010010,
B010010,
B000000,
B011110,
B100001
);
Sprite P = Sprite(
5, 7,
B11110,
B10001,
B10001,
B11110,
B10000,
B10000,
B10000
);
Sprite K = Sprite(
5, 7,
B10001,
B10001,
B10010,
B10100,
B11100,
B10010,
B10001
);
Sprite e = Sprite(
5, 7,
B00000,
B01110,
B10001,
B11110,
B10000,
B10001,
B01110
);
Sprite l = Sprite(
1, 7,
B1,
B1,
B1,
B1,
B1,
B1,
B1
);
Sprite i = Sprite(
1, 7,
B0,
B1,
B0,
B1,
B1,
B1,
B1
);
Sprite k = Sprite(
4, 7,
B1000,
B1000,
B1001,
B1010,
B1100,
B1010,
B1001
);
Sprite o = Sprite(
5, 7,
B00000,
B00000,
B01110,
B10001,
B10001,
B10001,
B01110
);
Sprite n = Sprite(
5, 7,
B00000,
B00000,
B10110,
B11001,
B10001,
B10001,
B10001
);
Sprite v = Sprite(
5, 7,
B00000,
B00000,
B10001,
B10001,
B01010,
B01010,
B00100
);
Sprite dot = Sprite(
1, 7,
B0,
B0,
B0,
B0,
B0,
B0,
B1
);
Sprite W = Sprite(
7, 7,
B1000001,
B1000001,
B1000001,
B1001001,
B0101010,
B0110110,
B0100010
);
Sprite r2 = Sprite(
4, 7,
B0000,
B0000,
B1011,
B1100,
B1000,
B1000,
B1000
);
Sprite linecut = Sprite(
1, 5,
B1,
B1,
B0,
B1,
B1
);
Sprite n5 = Sprite(
5, 7,
B11111,
B10000,
B11110,
B10001,
B00001,
B10001,
B01110
);
Sprite n4 = Sprite(
5, 7,
B00010,
B00100,
B01000,
B10010,
B11111,
B00010,
B00010
);
Sprite n3 = Sprite(
5, 7,
B01110,
B10001,
B00001,
B00110,
B00001,
B10001,
B01110
);
Sprite n2 = Sprite(
5, 7,
B01110,
B10001,
B00001,
B00010,
B00100,
B01000,
B11111
);
Sprite n1 = Sprite(
5, 7,
B00010,
B00110,
B01010,
B00010,
B00010,
B00010,
B00111
);
Sprite n0 = Sprite(
5, 7,
B01110,
B10001,
B10001,
B10001,
B10001,
B10001,
B01110
);