État actuel du programme
int page=1;
int x=50;
int y=390;
PImage menu;
PImage play;
String selection="Selection de niveau";
boolean souris=false;
PImage facile;
PImage moyen;
PImage difficile;
PImage fond;
;
void setup ()
{
size(1000, 600);
menu=loadImage("menu.jpg");
play=loadImage("play.jpg");
facile=loadImage("facile.jpg");
moyen=loadImage("moyen.png");
difficile=loadImage("difficile.png");
fond=loadImage("fond.jpg");
}
void draw() {
Menu();
if (page==3)
{
Plateformes();
Personnages();
}
}
void Menu()
{
if (page==1)
{
image(menu, 0, 0, width, height);
image(play, 419, 500, 115, 70);
}
if (souris==true && page==2)
{
image(menu, 0, 0, width, height);
fill(#000000);
textSize(32);
text(selection, 350, 50, 400, 400);
image(facile, 225, 475, 100, 50);
image(moyen, 419, 475, 100, 50);
image(difficile, 613, 475, 100, 50);
}
if (page==3)
{
image(fond, 0, 0, width, height);
}
}
void mousePressed()
{
if (mouseX>419 && mouseX<500 && mouseY>500 && mouseY<570&&page==1)
{
souris=true;
page=2;
}
if (page==2 && mouseX>225 && mouseX<325 && mouseY>475 && mouseY<525)
{
souris=false;
page = 3;
}
}
Onglet jeu :
void Plateformes() {
fill(#955518);
noStroke();
rect(0, 450, 250, 500);
fill(#955518);
noStroke();
rect(900, 450, 500, 500);
}
void Personnages() {
PImage sonic;
sonic=loadImage("sonic.png");
image(sonic, x, y, 100, 60);
image(sonic, x, y, 100, 60);
if (key==CODED) {
if (keyCode==RIGHT) {
x=x+2;
}
if (keyCode==LEFT) {
x=x-2;
}
if (keyCode==UP) {
y=y-2;
}
}
}