ok i wrote the code. im trying to make it so that i havve a tank and i want it to move so i have the picture i think but whenever i try to run it i get a white screen. help?
final static int NORTH = 1;
final static int EAST = 2;
final static int SOUTH = 4;
final static int WEST = 8;
int result;
float x,y;//x and y for tank
int speed=5;//speed of tank
class Hero{
void display(){
background(255);
}
}
void setup(){
PImage tankup;
tankup=loadImage("Tank Up.png");
image(tankup,x,y);
size(600,600);
result=0;
x=0;
y=0;
}
void draw(){
Hero hero;
hero= new Hero();
hero.display();
switch(result) {
case NORTH: y=y-speed; break;
case EAST: x=x+speed; break;
case SOUTH: y=y+speed; break;
case WEST: x=x-speed; break;
}
}
void keyPressed(){
switch(key) {
case('w'):case('W'):result |=NORTH;speed=5;break;
case('d'):case('D'):result |=EAST;speed=5;break;
case('s'):case('S'):result |=SOUTH;speed=5;break;
case('a'):case('A'):result |=WEST;speed=5;break;
}
}
void keyReleased(){
switch(key) {
case('w'):case('W'):result ^=NORTH;break;
case('d'):case('D'):result ^=EAST;break;
case('s'):case('S'):result ^=SOUTH;break;
case('a'):case('A'):result ^=WEST;break;
}
}