Unit 1: Day 10

START DATE:DUE DATE:STATUS:Open

Tasks

10.1 Compression Review Using AP Classroom

  • If you have access to AP Classroom, take a few moments to go over the Topic Questions for 2.2 Data Compression. There were 10+ sample multiple choice questions available at the time this document was produced.

10.2 Colours and Pixels

10.3 Ex10_Bomb Dropping Example (More with keyPressed and mousePressed)

  • This example was been dubbed “Bomby” by a past class of mine
  • Show the example of what we are going to be doing today
  • Start with the basic box dropping and a keyPressed event
  • Complete as the code example below
  • Add a picture of an explosion if the bomb drops below a point
  • Add text to print the bomby variable

Unit 1 - Example 9 - Bomby Game

This example requires fonts and images to be uploaded separately.

let font1, font2

let pic1;

let bomby = 50;

let speed = 1;

let timer;

function preload(){

  font1 = loadFont("Lobster.ttf");

  pic1 = loadImage("explosion.jpg");

}//end preload

function setup() {

  let sketch = createCanvas(600, 600);

  sketch.parent("mycanvas");

  textSize(16)

  textFont(font1);

}//end setup

function draw() {

  background(220,0,0);

  square(115, bomby, 20);

  bomby += speed;

  if ( bomby > height ){

    image(pic1, 0, 300, 250, 100);

    text("Armeggedon is here!", 20,50);

    text("You survived: " + round(timer,3) + " seconds", 20,100);

    } else {

    fill(255);

    timer = millis() / 1000;

    text("Time elapsed: " + round(timer,3) , 20, 100);

  }

}//end draw

function keyPressed(){

  if ( keyCode === UP_ARROW ) {

    bomby -= 8;

  }

}//end keyPressed

10.4 Continue Processing Assign 2 – Collector Card

  • Give the remainder of class to work on the Collector Card


Continue to Unit 1: Day 11 »

Resources