Search Header Logo

p5play JavaScript Logic Drill: Physics & Interaction

Authored by Jonathan Smith

Computers

8th Grade

Used 1+ times

p5play JavaScript Logic Drill: Physics & Interaction
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You have a "Player" and a "Key" sprite. You want the key to follow the player's exact movement only AFTER the player has touched it once. What is the most logical way to track this state?

Check if (player.overlapping(key)) every frame.
Use a while loop to pause the game
Create a boolean variable like hasKey = false; and set it to true when they collide.
Use key.x = player.x at the very start of the setup() function.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You want to create a "Ghost" enemy that moves at a constant speed toward the player's current location. Which method is most effective for an intermediate designer to handle the math of moving toward a moving target?

ghost.x = player.x;
ghost.vel.x = player.x - ghost.x;
ghost.moveTowards(player, 0.02);
ghost.direction = player.rotation;

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You are designing a "Pinball" game. When the ball hits a "Bumper," you want the Bumper to grow in size slightly for just one second and then shrink back. What logic should be used to trigger the growth?

if (ball.colliding(bumper))
if (ball.collides(bumper))
if (ball.overlapping(bumper))
if (ball.vel.y > 0)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

A programmer wants to make a "Locked Door" that only opens if the player has the blueKey AND the redKey. Which JavaScript logic correctly checks for both?

if (hasBlueKey || hasRedKey)
if (hasBlueKey = true && hasRedKey = true)
if (hasBlueKey && hasRedKey)
if (hasBlueKey !! hasRedKey)

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You are building a "Pause" menu. When the variable isPaused is true, you want all sprites to stop moving, but you don't want to remove them. Which p5play property logic is most efficient for the "World"?

world.remove();
allSprites.visible = false;
world.step(); (Controlling the physics update manually)
sprites.vel = 0; (Looping through every sprite to reset velocity)

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?