Derby game help?
in
Programming Questions
•
2 years ago
I am new to processing and I am making this derby game and I don't understand how to hold the horses from starting until I get past the first screen by pressing ENTER.
- PImage first;
PImage back;
PImage a;
PImage b;
PImage c1;
PImage rw;
color c = color(0);
color c2 = color(100,0,0);
color c3 = color(0,100,0);
float x = 0;
float y = 100;
float speed = random(20,30);
float x2 = 0;
float y2 = 300;
float speed2 = random(20,30);
float x3 = 0;
float y3 = 500;
float speed3 = random(20,30);- void setup() {
size(screen.width-100,screen.height-100);
frameRate(10000);
smooth();
first = loadImage("derby title.JPG");
back = loadImage("grass.jpg");
a = loadImage("black horse.jpg");
b = loadImage("red horse.JPG");
c1 = loadImage("green horse.jpg");
rw = loadImage("red wins.JPG");
} - void draw() {
background(255);
move();
display();
} - void move() {
x = x + speed;
if (x > width) {
image(rw,0,0,width,height);
}
x2 = x2 + speed2;
if(x2 > width) {
x2 = 0;
}
x3 = x3 + speed3;
if(x3 > width) {
x3 = 0;
}
} - void display() {
image(first,0,0,screen.width,screen.height);
if (key == CODED);
if (key == ENTER) {
image(back,0,0,screen.width,screen.height);
image(a,x,y,100,100);
image(b,x2,y2,100,100);
image(c1,x3,y3,100,100);
}
}
1