Richard Rodriguez Final project sad_ants
GD-105
Link to the playable version without the pixels movement & leafs:
https://drive.google.com/open?id=0B6q8foXNaSBTQTE4ZHZreHdNTnM
what's not working: 1-pixels movement detection (the code its fine, it is just that the background image has tons of pixels of different colors because it was ripped in photoshop)! 2- the game mechanic of picking the leafs before the water destroys them. 3-sound: processing 2.2.1 minim conflict with gif libraries. Missing menu.
CODE:
//creating variables and importing libraries
import gifAnimation.*; Gif ant, water; PImage bg; PImage win; PImage lose;
int posX; int posY; int radius; int Speed; color a; color b = color(72,86,106); color c = color(91,55,21); color d = color(255,255,255);
int waterpos; int time; int wait = 10000;
//setting up the background & game assets values
void setup(){
size(800,850);
noCursor();
smooth();
posX = 400; posY = 800; radius = 25; Speed = 3; waterpos = 825;
time = millis();
water = new Gif(this,"water(6).gif");
bg = loadImage("bg ants.png");
ant = new Gif(this,"eadward.gif");
win = loadImage("win.png");
lose = loadImage("lose.jpeg");
water.play();
ant.play();
}
//placing assets in the game
void draw(){
background(91,55,21);
image(water,0,waterpos,width,height);
image(bg,0,0,width,height);
image(ant,posX,posY,30,30);
a = get(posX,posY);
//timer for the water
if(millis() - time >= wait){
waterpos = waterpos - 40;
time = millis(); //resetting timer
}
fill(a);
rect(550,650,50,50);
//testing lose condition
if(a == b){
noLoop();
image(lose,0,0,width,height);
}
//testing win condition
if(a == d){
noLoop();
image(win,0,0,width,height);
}
}
//movement
void keyPressed(){
//testing pixels for movement
if(a == c){
if ( (keyCode == LEFT) && (posX > radius) )
{
posX = posX - Speed;
}
if ( (keyCode == RIGHT) && (posX < width-radius) )
{
posX = posX + Speed;
}
if ( (keyCode == UP) && (posY > radius) )
{
posY = posY - Speed;
}
if ( (keyCode == DOWN) && (posY < height-radius) )
{
posY = posY + Speed;
}
}
else{
//can't complete the “else” condition due to discrepancy in the pixels of the background.
}
}








