Animation and Games CodeHS Part 5
A set of flashcards covering key concepts from CodeHS Part 5: Animation and Games, including circles, shapes, and event handling.
How many circles of radius 10 will fit vertically stacked in a window that has height 100? The circles should not overlap, the bottom of one circle should touch the top of the next circle.
5
Key Terms
How many circles of radius 10 will fit vertically stacked in a window that has height 100? The circles should not overlap, the bottom of one circle should touch the top of the next circle.
5
This is a circle on our canvas named ball. What are the coordinates of point A?
ball.getX() + ball.getRadius(), ball.getY()
What statement should we use to determine if ball is hitting the bottom edge of the window?
if(ball.getY() + ball.getRadius() > getHeight()){
//ball is hitting bottom edge
}
How can we determine if ball's left edge is hitting a different shape on our canvas named box?
var elem = getElementAt(ball.getX() - ball.getRadius() - 1, ball.getY());
if(elem == box){
//ball's left edge is hitting box
}
The following code moves a ball across the screen at a rate of dx in the x direction and dy in the y direction.
...
What do we need to add to line 19 to have the ball bounce off the top of the window like this:
dy = -dy;
Which of the following statements will call the function paint every time the mouse is moved?
mouseMoveMethod(paint);
Related Flashcard Decks
Study Tips
- Press F to enter focus mode for distraction-free studying
- Review cards regularly to improve retention
- Try to recall the answer before flipping the card
- Share this deck with friends to study together
| Term | Definition |
|---|---|
How many circles of radius 10 will fit vertically stacked in a window that has height 100? The circles should not overlap, the bottom of one circle should touch the top of the next circle. | 5 |
This is a circle on our canvas named ball. What are the coordinates of point A? | ball.getX() + ball.getRadius(), ball.getY() |
What statement should we use to determine if ball is hitting the bottom edge of the window? | if(ball.getY() + ball.getRadius() > getHeight()){ |
How can we determine if ball's left edge is hitting a different shape on our canvas named box? | var elem = getElementAt(ball.getX() - ball.getRadius() - 1, ball.getY()); |
The following code moves a ball across the screen at a rate of dx in the x direction and dy in the y direction. | dy = -dy; |
Which of the following statements will call the function paint every time the mouse is moved? | mouseMoveMethod(paint); |
What is a callback function? | A function passed to an event handler that is called every time a certain event happens |
In the following statement: | mouseMoveMethod |
In the following statement: | draw |
In the following code: | e is a parameter passed to the callback function paint that contains information about the Mouse Event, such as where on the window it occurred. |
The following program adds several shapes to the screen. | function removeShape(e){ |