//Name: //Date: //Game title: //Theme: var bg = createSprite(200, 200); bg.setAnimation("OpeningScreen"); //Game Sprites //start everything off screen and not moving var sprite = createSprite(-100, 100); sprite.setAnimation(""); sprite.scale = 0.3; //to track the current position var mode = "1 - opening"; function draw() { drawSprites(); //playing the correct mode if (mode=="1 - opening") { opening(); } else if (mode=="2 - instructions") { instructions(); } else if (mode=="3 - start") { start(); } else if (mode=="4 - play") { play(); } else if (mode=="5 - win") { win(); } else if (mode=="6 - lose") { lose(); } //space to move on if (keyWentDown("space")) { if (mode=="1 - opening") { mode = "2 - instructions"; } else if (mode=="2 - instructions") { mode = "3 - start"; } else if (mode=="5 - win") { mode = "3 - start"; } else if (mode=="6 - lose") { mode = "3 - start"; } } } function opening(){ //displays the opening screen textSize(40); fill("black"); text("Opening", 120, 75); textSize(20); text("By Ida Knowe", 200, 350); text("Press space to begin", 200, 380); } function instructions(){ //displays the instructions screen textSize(40); fill("black"); text("Instructions", 100, 75); textSize(20); text("Press space to begin", 200, 380); } function start(){ //begin the game bg.setAnimation("gameScreen"); //move sprites onscreen //start them moving //set the mode to play mode ="4 - play"; } function play(){ //the code to play the game //handle screen scrolling if needed //move the pieces //move the main character //point increase //point decrease //handle win //handle loss } function win(){ //Display win screen bg.setAnimation("WinScreen"); mode="5 - win"; freeze(); textSize(50); fill("black"); text("You win!", 100, 150); textSize(30); text("Press space to play again", 30, 350); } function lose(){ //Display lose screen bg.setAnimation("LoseScreen"); mode="6 - lose"; freeze(); textSize(50); fill("black"); text("You lose", 100, 150); textSize(30); text("Press space to play again", 30, 350); } function freeze(){ //freeze game sprites (velocityX & velocityY = 0) //move game sprites all off screen (x and y are negative) }