lecture 2 Flashcards

(9 cards)

1
Q

why use a class function?

A

to reduce duplication of code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what does a constructor do?

A

enables you to provide any custom initialisation that must be done before any other methods can be called on an instantiated object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

do you use the function keyword within a class?

A

no

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how would you get a class called aliens to use the move and display functions?

A

aliens.move( ); & aliens.display( );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how would you create multiple instances of aliens?(written as code)

A

let aliens1;
let aliens2;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is used to store multiple instances of a class?

A

an array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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?

A

(random(20,40))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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?

A

new Raindrop(random(20,40),random(0,255));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what function would you use to detect a collision?

A

the intersects() function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly