lecture 2 Flashcards
(9 cards)
why use a class function?
to reduce duplication of code
what does a constructor do?
enables you to provide any custom initialisation that must be done before any other methods can be called on an instantiated object.
do you use the function keyword within a class?
no
how would you get a class called aliens to use the move and display functions?
aliens.move( ); & aliens.display( );
how would you create multiple instances of aliens?(written as code)
let aliens1;
let aliens2;
what is used to store multiple instances of a class?
an array
function setup() { createCanvas(windowWidth, windowHeight); for (let i = 0; i < 100; i++) { raindrops[i] = new Raindrop(random(20, 40));
in this code what would you adjust to edit the size of the raindrops?
(random(20,40))
function setup() { createCanvas(windowWidth, windowHeight); for (let i = 0; i < 100; i++) { raindrops[i] = new Raindrop(random(20, 40)); }
what would you add to make this have greyscale?
new Raindrop(random(20,40),random(0,255));
what function would you use to detect a collision?
the intersects() function