var wallTop, wallBottom, wallLeft, wallRight
smImg = loadImage ('joueur_final.png');
energie = loadImage ('flash.png');
vaisseau1 = loadImage ('vaisseau.png');
fond = loadImage('galaxy.jpg')
planete = loadImage ("planetes.png")
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 < 8; i++) {
var flash = createSprite(random(10, width-10), random(10, height-10), 10, 10);
flash.addImage(energie) }
for (var i = 0 ; i < 20; i++) {
var mur = createSprite(random(150, width-155), (height/10)*i, random(30, 15), random(155, 10));
joueur = createSprite(width/20, height/20);
vaisseau = createSprite(width/8, height/10);
vaisseau.addImage(vaisseau1)
vaisseau.position.x = 790;
vaisseau.position.y = 790;
joueur.overlap(flash1, getflash);
joueur.bounce(wallBottom)
text("AIDE BOB A RECUPERER TOUTE L'ENERGIE POUR REPARER SON VAISSEAU", width/13, height/14);
textAlign(CENTER, CENTER);
if ((flash1.length > 0)) {
text(score, width/2, height/2);
if((joueur.overlap(vaisseau)) && (flash1.length = 8)){
text("Bravo !", width/2, height/2);
function getflash(joueur, flash) {
if (keyCode == RIGHT_ARROW) {
else if (keyCode == DOWN_ARROW) {
joueur.setSpeed(4.5, 90);
else if (keyCode == LEFT_ARROW) {
joueur.setSpeed(4.5, 180);
else if (keyCode == UP_ARROW) {
joueur.setSpeed(4.5, 270);