int x = 0;
int y = 0;
int bomb[][] = new int[21][21];
void setup()
{
background(125,125,125);
size(500,500);
for (int i = 0; i < 21;i++)
{
for (int j = 0; j < 21;j++)
{
bomb[i][j] = (int)(random(10));
}
}
for (int i = 0; i < 500;i+=25)
{
for (int j = 0; j < 500;j+=25)
{
fill(0,255,0);
rect(i,j,25,25);
}
}
}
void draw()
{
}
void keyPressed() {
if (keyCode == RIGHT && x < 475){
x += 25;
}
if (keyCode == LEFT && x > 0)
{
x -= 25;
}
if (keyCode == UP && y > 0)
{
y -= 25;
}
if (keyCode == DOWN && y < 475){
y += 25;
}
for (int i = 0; i < 500;i+=25)
{
for (int j = 0; j < 500;j+=25)
{
fill(0,255,0);
rect(i,j,25,25);
}
}
fill(255,0,0);
rect(x,y,25,25);
for (int i = 0; i < 21;i++)
{
for (int j = 0; j < 21;j++)
{
if (bomb[i][j] == 9)
{
fill(0,0,255);
rect(i*25,j*25,25,25);
}
}
}
for (int i = 0; i < 21;i++)
{
for (int j = 0; j < 21;j++)
{
if (bomb[i][j] == 9)
{
if (i*25 == x && j*25 == y)
{
background(125,125,125);
textSize(32);
text("Ты проиграл",0,height/2);
}
}
}
}
}
|