Mr. Mansour's Classroom
  • Home
    • Video Supplements for 551
    • HSPT Math Practice
    • Physics Interactives
    • Electricity PHETs
    • 3d
    • Green Monkey
    • Geometry Rotations
    • Movie Tips
    • Probability Games
    • Norris Football
  • Assignments
  • Movies
    • Robotics Class Movie 2023
    • Math Movies 2021
    • Math Movies 2022
    • Lost in Time >
      • Lost in Time 1
      • Lost in Time 2
      • Lost in Time 3
      • Lost in Time 4
      • Lost in Time 5
      • Lost in Time 6
      • Lost in Time 7
      • Lost in Time 8
      • Lost in Time 9
      • Lost in Time X
      • Lost in Time XI
      • Lost in Time XII
      • Lost in Time XIII
      • Lost in Time XIV
      • Lost in Time XV
    • Service Projects
  • Resources
    • Plans and Sample Lessons >
      • Course Plans
      • Lesson Plans
      • Substitute Plans
      • Careers
    • Novel Units >
      • Because of Winn Dixie
      • Jackie and Me
      • Maniac Magee
      • The Mouse and the Motorcycle
      • Shark Beneath the Reef
      • Sounder
      • Wrinkle in Time
      • Yellow Bird and Me
    • Super Six for Online Learning (2020)
    • Ultimate Guide to Online Tools (2018)
    • Math Skills Supplement
    • Math Supplement Challenge
  • Norris Home
  • About Me
​//GAME SETUP
// Create the sprites
var mario = createSprite(200, 350);
mario.setAnimation("mario");
mario.scale = 3;
var bb = createSprite(200, 200);
bb.setAnimation("bb");
bb.scale = 0.25;
bb.velocityX = -5;
mario.debug = false;
bb.debug = false;
// set velocity for the obstacle and the target


//create the variables
var score = 0;
var health = 100;

function draw() {
  if (bb.x < 0) {
    bb.velocityX = 5;
    bb.setAnimation("bb3");
  }
  if (bb.x > 400) {
    bb.velocityX = -5;
    bb.setAnimation("bb");
  }
  // BACKGROUND
  background("cyan");
  // draw the ground and other background

  // SPRITE INTERACTIONS
  // if the player touches the obstacle
  // the health goes down, and the obstacle turns
  if (mario.y > 350) {
    mario.velocityY = 0;
  }
  if (keyDown("up")) {
    mario.velocityY = -20;
  }
  if (mario.y < 100) {
    mario.velocityY = 20;
  }
  if (keyDown("down")) {
    if (bb.isTouching(mario)) {
      mario.y = 260;
      mario.velocityY = 20;
      mario.rotation = 0;
    }
  }
  if (keyDown("left")) {
    mario.velocityX = -10;
  }
  if (keyDown("right")) {
    mario.velocityX = 10;
  }

  // if the player touches the target
  // the score goes up, the target resets
  if (bb.isTouching(mario)) {
    mario.velocityY = 0;
    mario.x = bb.x;
    mario.rotation = randomNumber(-30, 30);
  }

  // JUMPING
  // if the player has reached the ground
  // stop moving down

  // if the player presses the up arrow
  // start moving up

  // if the player reaches the top of the jump
  // start moving down

  // LOOPING
  // if the obstacle has gone off the left hand side of the screen, 
  // move it to the right hand side of the screen

  // if the target has gone off the left hand side of the screen,
  // move it to the right hand side of the screen

  // DRAW SPRITES
  drawSprites();
  
  // SCOREBOARD
  // add scoreboard and health meter
  fill("black");
  textSize(20);
  text("Health:", 280, 30);
  text (health, 350, 30);
  // GAME OVER
  // if health runs out
  // show Game over
  if (health < 0) {
    background("black");
    fill("green");
    textSize(50);
    text("Game Over!" , 40, 200);
  }
}

1. Copy the Code in Red
​2. Click the button at Right -->

HTML Practice


<iframe src="https://docs.google.com/presentation/d/e/2PACX-1vRGny4ESo4j7KGQZ5X4CoH0eYNG9dAB--1_Qrw-C6Q9QaGj31PaISe4I0I71uFyIv_fa4cfmt_Van1o/embed?start=false&loop=false&delayms=3000" frameborder="0" width="960" height="569" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>


<iframe width="725" height="453" src="https://www.tinkercad.com/embed/1OGPtyZ5w94?editbtn=1" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
MrMansour.com  2023

Picture
  • Home
    • Video Supplements for 551
    • HSPT Math Practice
    • Physics Interactives
    • Electricity PHETs
    • 3d
    • Green Monkey
    • Geometry Rotations
    • Movie Tips
    • Probability Games
    • Norris Football
  • Assignments
  • Movies
    • Robotics Class Movie 2023
    • Math Movies 2021
    • Math Movies 2022
    • Lost in Time >
      • Lost in Time 1
      • Lost in Time 2
      • Lost in Time 3
      • Lost in Time 4
      • Lost in Time 5
      • Lost in Time 6
      • Lost in Time 7
      • Lost in Time 8
      • Lost in Time 9
      • Lost in Time X
      • Lost in Time XI
      • Lost in Time XII
      • Lost in Time XIII
      • Lost in Time XIV
      • Lost in Time XV
    • Service Projects
  • Resources
    • Plans and Sample Lessons >
      • Course Plans
      • Lesson Plans
      • Substitute Plans
      • Careers
    • Novel Units >
      • Because of Winn Dixie
      • Jackie and Me
      • Maniac Magee
      • The Mouse and the Motorcycle
      • Shark Beneath the Reef
      • Sounder
      • Wrinkle in Time
      • Yellow Bird and Me
    • Super Six for Online Learning (2020)
    • Ultimate Guide to Online Tools (2018)
    • Math Skills Supplement
    • Math Supplement Challenge
  • Norris Home
  • About Me