Originally Posted by
NJK
This is a snake game I made and It would be cool if it was added to the arcade and they would give you more tickets depending on how many balls you ate.
Here's the code scripted and tested:
int x= 245;
int y= 245;
int randomx;
int randomy;
color below;
int speed=0;
void setup(){
size(500,500);
drawApple();
}
void draw(){
fill(235,0,0);
if (keyCode ==40){
below = get(x, y+26);
y = y + speed;
}
if (keyCode ==37){
x = x - speed;
below = get(x-1, y);
}
if (keyCode == 38){
y = y - speed;
below = get (x, y-1);
}
if (keyCode == 39){
x = x + speed;
below = get(x+26,y);
}
if(frameCount % 1000 == 0 && speed < 10) {
speed = speed + 1;
}
rect(x,y,25,25);
if (x < 0){
textSize(40);
fill(#F50000);
rect(x,y,25,25);
text("Game Over", 170, 100);
noLoop();
}
if (y < 0){
textSize(40);
fill(#F50000);
rect(x,y,25,25);
text("Game Over", 170, 100);
noLoop();
}
if (x > 475){
textSize(40);
fill(#F50000);
rect(x,y,25,25);
text("Game Over", 170, 100);
noLoop();
}
if (y > 475){
textSize(40);
fill(#F50000);
rect(x,y,25,25);
text("Game Over", 170, 100);
noLoop();
}
println(below);
if (below == -13369495){
println("green");
}
if (below == -5373){
println("yellow");
drawApple();
}
}
void gameOver(){
textSize(40);
text("Game Over Fool!", 150, 100);
rect(x, y, 25, 25);
noLoop();
}
void drawApple(){
speed = speed + 1;
background(255);
fill(#FFEB03);
stroke(#33FF69);
randomx = int(random(20,480));
randomy = int(random(20,480));
ellipse(randomx, randomy, 50, 50);
}