Greenfoot Flashcards

1
Q

What is the code used to make an enemy turn randomly?

A

turn((Greenfoot.getRandomNumber(180)-90)

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

What is the code used to detect if the player is touching the collect?

A

if(isTouching(—–.class))

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

What is the code used to make the collect disappear when touched by the player?

A

removeTouching(—–.class)

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

What must be imported at the top of the counter code?

A

import java.awt.Color;

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

What variables must be created at the top of the counter code?

A

int score = 0;

int amount = 0;

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

What code is used to create the counter?

A

setImage(new GreenfootImage(“Score = “ + score, 20, Color:BLACK, Color:WHITE));

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

What code is used in the counter code to add to the score?

A

public void addToScore(int amount)
{
score += amount
}

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

What code is used in the counter code to allow the score to decrease?

A

public void loseLife()
{
score+=amount
}

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

What is used in the player code to access the counter?

A

counter counter = (counter) getWorld().getObjects(counter.class).get(0);

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

What is used in the player code to add 1 to the score?

A

counter.addToScore(1)

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