Mise en ligne du code actuel.
06/05/2016 11:30
PImage circuit1;
PImage circuit2;
PImage circuitarriere;
PImage circuit;
PImage taxi;
boolean fond0=false;
boolean fond1=false;
boolean fond2=false;
boolean fond3=false;
boolean fond4=false;
int page= 1;
int x=225;
int y=50;
int vitesse=1;
color c= color(#004D00);
void setup() {
background(0);
size(600, 600);
fill(#55D126);
// rect(10, 370, 580, 210, 10);
circuit1 = loadImage ("images1.jpg");
circuit2 = loadImage( "images.png");
circuitarriere = loadImage ( "circuitarriere.jpg");
circuit = loadImage("circuit.jpg");
taxi= loadImage("taxi.png");
image(circuitarriere, 0, 0);
}
void draw() {
Menu();
bougervoiture();
if (fond0==true) {
Page0();
}
if (fond1==true) {
Page1();
}
if (fond2==true) {
Page2();
}
if (fond3==true) {
Page3();
}
}
void Menu() {
page=1;
textSize(50);
fill(#FFFFFF);
text("MENU", 230, 110);
textSize(90);
fill(#23DB31);
text("Démarrer", 80, 500);
}
void mousePressed() {
if (mouseX<580 && mouseX>10 &&mouseY>370 &&mouseY<210+370 && page==1) {
fond1=true;
}
if (mouseX<280 && mouseX>10 &&mouseY>250 &&mouseY<100+250 && page==1) {
fond2=true;
}
if (mouseX<310+250 && mouseX>310 && mouseY>250 && mouseY<100+250 && page==1) {
fond3=true;
}
if (mouseX<110 && mouseX>10 && mouseY<60 && mouseY>10 && page==2) {
fond0=true;
}
}
void Page0() {
Menu();
}
void Page1() { // bouton démarrer
page= 2;
background(0);
image(circuit, 0, 0);
image(taxi, x, y, 140, 80);
fill(#E01223);
}
void Page2() { // bouton véhicules
page= 3;
background(0);
fill(#E01223);
rect(10, 10, 100, 50, 10);
textSize(25);
fill(#050000);
text("Menu", 20, 40);
}
void Page3() { // bouton circuits
page= 4;
fill(#E01223);
rect(10, 10, 100, 50, 10);
textSize(25);
fill(#050000);
text("Menu", 20, 40);
}
void bougervoiture() {
if (keyPressed) {
if (key == CODED) {
if (keyCode == UP) {
if (green(get(x, y-5))==0) {
y=y;
} else {
y = y-2;
}
}
}
}
if (keyPressed) {
if (key == CODED) {
if (keyCode == LEFT) {
if (green(get(x-5, y))==0) {
x=x;
} else {
x = x-2;
}
}
}
}
if (keyPressed) {
if (key == CODED) {
if (keyCode == RIGHT) {
if (green(get(x+141, y))==0) {
x=x;
} else {
x = x+2;
}
if (x==450) {
}
}
}
if (keyPressed) {
if (key == CODED) {
if (keyCode == DOWN) {
if (green(get(x, y+81))==0) {
y=y;
} else {
y = y+2;
}
}
}
}
if ( x > 530) {
pushMatrix();
translate(width/2, height/2);
rotate(PI/2);
image(taxi, 500, 200, 140, 80);
popMatrix();
}
}
}