Code ISN

23/03/2020

int page=0;
int x=400;
int y=600;
float xcone=0;
float xcone2=0;
float xtrou=0;
float ycone=0;
float ycone2=0;
float ytrou=0;
float xvoiture=0;
float yvoiture=0;
PImage fond;
PImage route666;
PImage route;
PImage logo;
PImage moto;
PImage cone;
PImage cone2;
PImage trou;
PImage voiture;
PImage perdu;
int xroute=0;
int yroute=0;
int score=0;
int scoremax=0;
int temps=1;

void setup() {
size(800, 800);
route666 = loadImage("route666.jpg");
fond = loadImage("fond.jpg");
route = loadImage("route.png");
logo = loadImage("logo.png");
moto = loadImage("moto.png");
cone = loadImage("cone.png");
cone2 = loadImage("cone2.png");
trou = loadImage("trou.png");
voiture = loadImage("voiture.png");
perdu = loadImage("perdu.jpg");
ycone = random(-600, 0);
xcone = random(100, 600);
ycone2 = random(-600, 0);
xcone2 = random(100, 600);
xtrou = random(100, 600);
ytrou = random(-600, 0);
xvoiture = random(100, 500);
yvoiture = random(-600, 0);
}

void draw() {
if (page==0) {
menu();
}
if (page==1) {
regles();
}
if (page==2) {
jeux();
obstacle();
score = score+1;
}
if (page==3) {
perdu();
}
}

void menu()
{
//background(#867E81);
image(fond,0,0,800,800);
image(logo,45,150);
// textSize(100);
// text("Death Riding",100,200);
fill(#FF0000);
rect(325, 500, 200, 100);
fill(#000000);
textSize(80);
text("PLAY", 330, 580);
if (mouseX > 325 && 525 > mouseX && mouseY > 500 && 600 > mouseY) {
if (mousePressed) {
page=page+1;
}
}
}

void regles () {
// background(#FFFFFF);
image(route666, 0, 0, 800, 800);
textSize(30);
fill(255);
text("Règles : ", 120, 130);
text("Le but du jeu est de faire le plus gros score", 100, 180);
text("à bord de sa moto sans aucune collisions.", 100, 210);
text("en esquivant les obstacles qui apparaissent.", 100, 240);
text("Pour pouvoir se déplacer sur la route, avec", 100, 270);
text("sa moto, il faudra utiliser les flèches", 100, 300);
text("directionnelles gauche et droite.", 100, 330);
textSize(90);
text("↔", 380, 430);
fill(#B7110B);
rect(325, 600, 200, 100);
fill(#000000);
textSize(30);
text("J'ai compris", 340, 665);
if (mouseX > 325 && 525 > mouseX && mouseY > 600 && 700 > mouseY) {
if (mousePressed) {
page=page+1;
}
}
}

void jeux() {
if (yroute<-799) {
temps=temps+1;
}
println(temps);
yroute=yroute+temps;
if (yroute>0) {
yroute=-800;
}
// println(yroute);
// background(0);
image(route, xroute, yroute);
image(moto, x, y);
textSize(32);
text("Score = "+score, 330, 40);
if (keyPressed) {
if (key == CODED) {
if (keyCode == LEFT) {
if (red(get(x-1, y))==0) {
x=x;
} else {
x = x-5;
}
}
}
}
if (keyPressed) {
if (key == CODED) {
if (keyCode == RIGHT) {
if (red(get(x+81, y))==0) {
x=x;
} else {
x = x+5;
}
}
}
}
}

ycone = ycone+temps;
ycone2 = ycone2+temps;
ytrou = ytrou+temps;
yvoiture = yvoiture+temps;
if (ycone>1000) {
ycone=random(-600, 0);
xcone=random(100, 600);
}
if (ycone2>1000) {
ycone2=random(-600, 0);
xcone2=random(100, 600);
}
if (ytrou>1000) {
ytrou=random(-600, 0);
xtrou=random(100, 600);
}
if (yvoiture>1000) {
yvoiture=random(-600, 0);
xvoiture=random(100, 500);
}

image(cone, xcone, ycone, 150, 80);
image(cone2, xcone2, ycone2, 150, 80);
image(trou, xtrou, ytrou, 150, 80);
image(voiture, xvoiture, yvoiture, 300, 150);
if (y < ycone+5 && y > ycone-5) {
if (x > (xcone-20) && x < xcone+100) {
scoremax=score;
page=page+1;
}
}
if (y < ycone2+5 && y > ycone2-5) {
if (x > (xcone2-20) && x < xcone2+100) {
scoremax=score;
page=page+1;
}
}
if (y < ytrou+5 && y > ytrou-5) {
if (x > (xtrou-20) && x < xtrou+100) {
scoremax=score;
page=page+1;
}
}
if (y < yvoiture+5 && y > yvoiture-5) {
if (x > (xvoiture+10) && x < xvoiture+200) {
scoremax=score;
page=page+1;
}
}
}

void perdu () {
//background(255);
image(perdu, 0, 0, 800, 800);
fill(0);
textSize(100);
text("PERDU", 250, 400);
text("Score = "+ scoremax, 100, 500);
fill(255);
rect(310, 600, 200, 100);
fill(0);
textSize(28);
text("Recommencer", 315, 660);
if (mouseX > 310 && 510 > mouseX && mouseY > 600 && 700 > mouseY) {
if (mousePressed) {
ycone=random(-600, 0);
ycone2=random(-600, 0);
ytrou=random(-600, 0);
yvoiture=random(-600, 0);
yroute=-800;
score=0;
temps=1;
page=page-1;
}
}
}

Créez votre site web gratuitement ! Ce site internet a été réalisé avec Webnode. Créez le votre gratuitement aujourd'hui ! Commencer