1 of 8

Animation Cont’d. :D

Ft. Catherine, Nicole, Julia and Maria

2 of 8

Agenda for Today

  • Attendance
  • Summary of Last Week
  • Additional Tips and Tricks
  • Challenge Problem Takeup
  • Questions / MyCreation Extra Help :)

3 of 8

Summary of Simple Animation Lesson

  • use the setup() method to set up the window
  • use the draw() method to continuously draw a shape in a new position on the screen
  • declare a global variable to store the object’s position on screen
  • call background () at the start of draw() to erase the old object and create the illusion of it moving across the screen

4 of 8

Summary of Simple Animation Lesson

5 of 8

Additional Tips and Tricks

Overlapping Objects

  • When animating you may need to overlap two or more objects
  • They should be drawn in the order that you want them layered on the screen
    • Object at the very back should be drawn first, object at the very front should be drawn last
  • For example: pink rectangle is drawn first, then the orange rectangle

6 of 8

Example Code

7 of 8

Last Week’s Challenge Problem

> Now that you know how to make an object bounce �off of the side of the screen, can you make an object �bounce diagonally off a side of the screen?

In order to do this, we can assign a variable�to change the position of both the x and�y positions! Because we want the object to�move up after hitting the wall instead of�moving down, instead of adding values to�its position, we can increasingly subtract �from an initial position

8 of 8

Example Code