Introduction: Makey Makey: Don't Tap the White Tile

Hi there, our creative friends! We are a group of 3 students from International Burch University, Sarajevo. We are having competition at our university in making Makey Makey projects. We decided to do this project because we think it is very interesting. We hope you will like it. :D

Step 1: Needed Components

- Makey Makey
- 9 jumpers
- 5 two sided clamps
- 5x10 cm cardboard
- some aluminum foil
- sellotape

Step 2: Making Software Part - Code Logic

Create an array for one column of tiles. Create same size array for black tiles. When creating column of tiles, check black tiles array. If box number is equal to tile number make tile back color black else make tile back color white. After drawing the table, get character input from user. If character equals the black input play piano key remove last row. Move rows one block down. Create new row, put the new row as last row, else plat fail sound.

Step 3: Writing the Code

HERE COMES THE CODE FOR THE GAME. It is done in C#.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Media;

namespace WindowsFormsApplication1 { public partial class Form1 : Form { Random rnd = new Random();

int[] tiles = new int[4] { 2 ,1,0,3 };
Panel[] row = new Panel[4];
Panel[][] rows = new Panel[4][];
SoundPlayer a = new SoundPlayer(WindowsFormsApplication1.Properties.Resources._1);
SoundPlayer b = new SoundPlayer(WindowsFormsApplication1.Properties.Resources._2);
SoundPlayer c = new SoundPlayer(WindowsFormsApplication1.Properties.Resources._3);
SoundPlayer d = new SoundPlayer(WindowsFormsApplication1.Properties.Resources._4);
SoundPlayer f = new SoundPlayer(WindowsFormsApplication1.Properties.Resources._5);
Random r = new Random();

//List tilesP = new List ();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

// this.Shuffle(tiles);
//this.TopMost = true;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;

int FormHeight = this.Size.Height;
int FormWidth = this.Size.Width;

for (int i = 0; i < 4; i++) {
Panel[] p = new Panel[4];
for (int j = 0; j < 4; j++)
{

row[j] = new Panel();

row[j].Size = new Size(FormWidth / 4, FormHeight / 4);
row[j].Location = new Point((i * FormWidth / 4), (j * FormHeight / 4));
row[j].BackColor = Color.White;
if (j == tiles[i]) row[j].BackColor = Color.Black;
row[j].BorderStyle = BorderStyle.FixedSingle;
this.Controls.Add(row[j]);
p[j] = row[j];
}
rows[i] = p;
}

//draw the tiles
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {

int FormHeight = this.Size.Height;
int FormWidth = this.Size.Width;

switch (keyData)
{
case Keys.A:
{
if (tiles[3] == 0)
{
a.Stop();
b.Stop();
c.Stop();
d.Stop();
f.Stop();

a.Play();

Random r = new Random();
int inr = r.Next(0, 4);

int[] s = new int[4];
Array.Copy(tiles, s, 4);

for (int i = 3; i > 0; i--)
{
tiles[i] = s[i - 1];
}
tiles[0] = inr;

for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++) {

Control p = this.GetChildAtPoint(new Point((i * FormWidth / 4), (j * FormHeight / 4))); rows[i][j] = (Panel)p;

}}

for (int i = 0; i < 4; i++)
{

for (int j = 0; j < 4; j++)
{

rows[i][j].Location = new Point((i * FormWidth / 4), ((j + 1) * FormHeight / 4));

}}

for (int i = 0; i < 4; i++)
{
rows[i][0] = new Panel();
rows[i][0].Size = new Size(FormWidth / 4, FormHeight / 4);
rows[i][0].Location = new Point((i * FormWidth / 4), (0 * FormHeight / 4));
rows[i][0].BackColor = Color.White;
if (i == inr) rows[i][0].BackColor = Color.Black;
rows[i][0].BorderStyle = BorderStyle.FixedSingle;
this.Controls.Add(rows[i][0]);
}}
else
{

a.Stop();
b.Stop();
c.Stop();
d.Stop();
f.Stop();
f.Play();

}
return true;

}
case Keys.S: {
if (tiles[3] == 1)
{

a.Stop();
b.Stop();
c.Stop();
d.Stop();
f.Stop();

b.Play();

int inr = r.Next(0, 4);

int[] s = new int[4];
Array.Copy(tiles, s, 4);

for (int i = 3; i > 0; i--)

{
tiles[i] = s[i - 1];
} tiles[0] = inr;

for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{

Control p = this.GetChildAtPoint(new Point((i * FormWidth / 4), (j * FormHeight / 4))); rows[i][j] = (Panel)p;

}
}

for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{

rows[i][j].Location = new Point((i * FormWidth / 4), ((j + 1) * FormHeight / 4));

}
}

for (int i = 0; i < 4; i++)
{
rows[i][0] = new Panel();
rows[i][0].Size = new Size(FormWidth / 4, FormHeight / 4);
rows[i][0].Location = new Point((i * FormWidth / 4), (0 * FormHeight / 4));
rows[i][0].BackColor = Color.White;
if (i == inr) rows[i][0].BackColor = Color.Black;
rows[i][0].BorderStyle = BorderStyle.FixedSingle;
this.Controls.Add(rows[i][0]);
}}
else {
a.Stop();
b.Stop();
c.Stop();
d.Stop();
f.Stop();

f.Play();
}

return true;
}
case Keys.D:
{
if (tiles[3] == 2)
{

a.Stop();
b.Stop();
c.Stop();
d.Stop();
f.Stop();

c.Play();

Random r = new Random();
int inr = r.Next(0, 4);

int[] s = new int[4];
Array.Copy(tiles, s, 4);

for (int i = 3; i > 0; i--)
{
tiles[i] = s[i - 1];
}
tiles[0] = inr;
for (int i = 0; i < 4; i++)

{
for (int j = 0; j < 4; j++)
{

Control p = this.GetChildAtPoint(new Point((i * FormWidth / 4), (j * FormHeight / 4))); rows[i][j] = (Panel)p;

}}
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{

rows[i][j].Location = new Point((i * FormWidth / 4), ((j + 1) * FormHeight / 4));
}}

for (int i = 0; i < 4; i++)
{
rows[i][0] = new Panel();

rows[i][0].Size = new Size(FormWidth / 4, FormHeight / 4);
rows[i][0].Location = new Point((i * FormWidth / 4), (0 * FormHeight / 4));

rows[i][0].BackColor = Color.White;

if (i == inr) rows[i][0].BackColor = Color.Black;
rows[i][0].BorderStyle = BorderStyle.FixedSingle;
this.Controls.Add(rows[i][0]);
} }
else
{
a.Stop();
b.Stop();
c.Stop();
d.Stop();
f.Stop();

f.Play();
}

return true;
} // up arrow key pressed
case Keys.F: {
if (tiles[3] == 3)
{

a.Stop();
b.Stop();

c.Stop();
d.Stop();
f.Stop();

d.Play();

Random r = new Random();
int inr = r.Next(0, 4);

int[] s = new int[4];
Array.Copy(tiles, s, 4);

for (int i = 3; i > 0; i--)
{
tiles[i] = s[i - 1];
}
tiles[0] = inr;

for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{

Control p = this.GetChildAtPoint(new Point((i * FormWidth / 4), (j * FormHeight / 4)));
rows[i][j] = (Panel)p;
}}

for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{

rows[i][j].Location = new Point((i * FormWidth / 4), ((j + 1) * FormHeight / 4));

}}

for (int i = 0; i < 4; i++)
{
rows[i][0] = new Panel();
rows[i][0].Size = new Size(FormWidth / 4, FormHeight / 4);
rows[i][0].Location = new Point((i * FormWidth / 4), (0 * FormHeight / 4));
rows[i][0].BackColor = Color.White;
if (i == inr) rows[i][0].BackColor = Color.Black;
rows[i][0].BorderStyle = BorderStyle.FixedSingle;
this.Controls.Add(rows[i][0]);
} }
else
{
a.Stop();
b.Stop();
c.Stop();
d.Stop();
f.Stop();
f.Play();

}
return true;

} }

return base.ProcessCmdKey(ref msg, keyData);
}
void Shuffle(T[] array)
{
int n = array.Length; for (int i = 0; i < n; i++)
{
// NextDouble returns a random number between 0 and 1.
// ... It is equivalent to Math.random() in Java.
int r = i + (int)(rnd.NextDouble() * (n - i));
T t = array[r];
array[r] = array[i];
array[i] = t;
} } } }

Step 4: Hardware Part - Connecting All Components

Step 5: Final Product

After doing all hardware and software work, we enjoyed playing the game. We hope you will like it too.

Comments

author
TriciaI3 made it!(author)2017-02-09

your code sucks this is garbage

author
BuciNida made it!(author)2015-06-07

coool

author
milicagoriboze1 made it!(author)2015-06-07

it was really good. and i made it :D keep going

author
VildanT made it!(author)2015-05-26

Nice, I like this project, hope I will have time to try it out :)

Here is C# code on .NET Fiddle https://dotnetfiddle.net/nBT9Rq

Have a nice one, can't wait to see more projects from you :)

author
BatuhanD made it!(author)2015-05-26

author
naushahmed made it!(author)2015-05-26

awesome

author
Follyy made it!(author)2015-05-26

Thumbs up!

About This Instructable

5,917views

88favorites

License:

Bio: Our aims are to improve science with new and innovative solutions, set of practical activities, implementing new ideas, enlarging peoples will for improving and creating ... More »
More by makerspace_burch:Makey Makey: Don't Tap The White TileMakeyMakey: FIFAMakey Makey : Piano Glove
Add instructable to: