var wallTop, wallBottom, wallLeft, wallRight;
alien=loadImage('alien.svg')
frere=loadImage('frere.svg')
fond=loadImage('fond.jpg')
wallTop = createSprite(width/2, -WALL_THICKNESS/2, width+WALL_THICKNESS*2, WALL_THICKNESS);
wallTop.immovable = true;
wallBottom = createSprite(width/2,height+WALL_THICKNESS/2, width+WALL_THICKNESS*2, WALL_THICKNESS);
wallBottom.immovable = true;
wallLeft = createSprite(-WALL_THICKNESS/2, height/2, WALL_THICKNESS, height);
wallLeft.immovable = true;
wallRight = createSprite(width+WALL_THICKNESS/2, height/2, WALL_THICKNESS, height);
wallRight.immovable = true;
for (var i = 0; i < 20; i++) {
var piece = createSprite(random(10, width-10), random(10, height-10), 20, 20);
piece.shapeColor = color(36, 236, 94);
joueur = createSprite(50, 50, 30, 30);
if(joueur.position.x<0) {
joueur.position.x = width/2;
joueur.position.y = height/2;
joueur.setSpeed(MAX_SPEED, 0);
text("perdu!", width/2, height/2);
if(joueur.position.x>width) {
joueur.position.x = width/2;
joueur.position.y = height/2;
joueur.setSpeed(MAX_SPEED, 180);
if(joueur.position.y<0) {
joueur.position.x = width/2;
joueur.position.y = height/2;
joueur.setSpeed(MAX_SPEED, 0);
if(joueur.position.y>height) {
joueur.position.x = width/2;
joueur.position.y = height/2;
joueur.setSpeed(MAX_SPEED, 180);
joueur.overlap(pieces, getPiece);
textAlign(CENTER, CENTER);
text(score, width/2, height/2);
text("Bravo, tu as reussi à les retrouver !", width/2, height/2);
function getPiece(joueur, piece) {
if (keyCode == RIGHT_ARROW) {
else if (keyCode == DOWN_ARROW) {
else if (keyCode == LEFT_ARROW) {
else if (keyCode == UP_ARROW) {