xxxxxxxxxx
//GAME//
/* @pjs preload= "Background.png,caixa3.png,amarelo1.png,plastico2.png"; */
to hist.add(pos.get());
PFont font;
PImage amarelo;
PImage plastico;
PImage caixa;
PImage rug;
int grid = 80; //tamanho da grelha
PVector food;
PVector enemy;
int speed = 10;
boolean dead = false;
int highscore = 0;
Snake snake;
void setup() {
//plastico = loadImage("plastico2.png");
// amarelo = loadImage("amarelo1.png");
//caixa = loadImage("caixa3.png");
//rug = loadImage("Background.png");
// fish = loadImage("food.png");
// cat = loadImage("grumpy.png");
// dog = loadImage("enemy.png");
// rug = loadImage("Background.png");
size(960, 960);
snake = new Snake();
food = new PVector();
enemy =new PVector();
newFood();
newEnemy();
frameRate(30);
}
void draw() {
// background(im);
PImage im = loadImage("plastico2.png");
PImage im = loadImage("amarelo1.png");
PImage im = loadImage("caixa3.png");
//PImage im = loadImage("Background.png");
image(im, 0,0);
if (!dead) {
if (frameCount % speed == 0) {
snake.update();
}
snake.show();
snake.eat();
image(plastico, food.x, food.y, grid, grid);
image(caixa, enemy.x, enemy.y, grid, grid);
// The font must be located in the sketch's
// "data" directory to load successfully
font = createFont("DialogInput.bold",50);
textFont(font);
// textSize(20);
fill(0);
// text("Score: " + snake.len, 10, 20);
} else {
// textSize(35);
textAlign(CENTER, CENTER);
fill(0);
// text("EcoGame\nGAME OVER\nEnter to start" + "\nHighscore: " + highscore, width/2, height/2);
text("GAME OVER" , width/2, height/5);
// font = createFont("InkFree",50);
textSize(80);
fill(18,180,92);
text("EcoGame", width/2, height/8);
}
}
void newFood() {
food.x = floor(random(width));
food.y = floor(random(height));
food.x = floor(food.x/grid) * grid;
food.y = floor(food.y/grid) * grid;
}
void newEnemy() {
enemy.x = floor(random(width));
enemy.y = floor(random(height));
enemy.x = floor(enemy.x/grid) * grid;
enemy.y = floor(enemy.y/grid) * grid;
}