Functions
Geometry
Coding Challenges (x2 points)
Flow
Data Types
1

What function is run when any key on the keyboard is released?

keyReleased();

1

What is the function and parameters to draw a square?

square(x, y, width);

1

Using only the variables xPosition, yPosition, and width, describe the function to draw a point in the center of a square(xPosition, yPosition, width); 

point(xPosition+width, yPosition+height);

1

Convert this code to pseudocode:

if(xPosition<55) {

xSpeed = 0;

}

When ever the xPosition is less than 55 pixels from the left of the screen, the xSpeed of the object will stop.

1

1.09

double

2

What is the function is run whenever any key on the keyboard is pressed?

keyPressed();

2

What is the function and parameters to draw a circle?

circle(x,y,radius);

2

Explain how you would use pseudocode to make is so an object will teleport to the opposite side of the screen like paceman.

If the object's xPosition is greater than width, set the xPosition equal to zero, if the xPosition is less than zero, set the xPosition to width. If the object's yPosition is greater than height, set the yPosition equal to zero, if the yPosition is less than zero, set the yPosition to height.

2

What is the format for an if else statement?

if(question) {

// Then do this

} else {

// Otherwise do this

}

2

68

int

3

What is the function that is run at the start of every program? Make sure to say the whole line of the function!

void setup() {


}

3

What is the function and parameters to draw a line?

line(x1,y1, x2,y2);

// Line is drawn from Point 1 to Point 2

3

Explain how you would use pseudocode to make is so an object will stay within the bounds of the screen.

If the object's xPosition is greater than width, set the speed to zero and set its xPosition equal to width. If the object's yPosition is greater than height, set the speed to zero and set its yPosition equal to height.

3

What is variable bingBong set to? float bingBong = 8; bingBong++; bingBong-= 2;

bingBong is equal to 7.0!

3

"Hello!"

string

4

What is the function that runs 60 times every second? Make sure to say the whole line of the function!

void draw() {


}

4

What is the function and parameters to draw a rectangle?

rect(x, y, width, height);

4

Explain how you would determine if two rectangles are touching using code! Circles are rect(xPosition1, yPosition1, width1, height1); and rect(xPosition2, yPosition2, width2, height2);

if(xPosition1+width > xPosition2 && xPosition2 < xPosition2+width && xPosition2+height1 > yPosition2 && xPosition1 < yPosition2+height2){

// Then the rectangles are touching

4

Daily Double!

Free ramen, + 4 points!

4

true/false

boolean

5

What do you call the inputs inside of the parenthesis of a function?

Parameters

5

What is the function and parameters to draw a triangle?

triangle(x1,y1, x2,y2, x3,y3);

// takes in 3 different points and draws lines between them all to form a triangle.

5

Explain how you would determine if two circles are touching using the distance formula in code! Circles are circle(xPosition1, yPosition1, radius1); and circle(xPosition2, yPosition2, radius2);

float distanceX = xPositon1-xPosition2;

float distanceY = yPositon1-yPosition2;

float distance = sqrt(distanceX*distanceX + distanceY*distanceY);

if (distance < radius1+radius2) // circles are touching

5

What is the code to generate a random number from 1 to 100?

random(1,100);

5

'a'

char