Greenfoot Flashcards

1
Q

Code to check if the right keyboard arrow has been pressed

A

if (Greenfoot.isKeyDown (“Right”))
{

}

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

Code to make an object point right

A

setRotation (0) ;

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

Code to make an object point down

A

setRotation (90) ;

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

Code to make an object point left

A

setRotation (180) ;

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

Code to make an object point up

A

setRotation (270) ;

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

Code to make an object move forward 1 space

A

move (1) ;

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

Code to play a sound file called “pop.wav”

A

Greenfoot.playSound (“pop.wav”) ;

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

Code to Generate a random number between 0-100

A

Greenfoot.getRandomNumber (100) ;

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

Code to check if an object is at the edge of the world

A

if (isAtEdge())
{

}

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

Code to make an object turn 45 degrees

A

turn (45) ;

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

Code to check if the object is touching another (e.g. touching an object with the class name Snake)

A

if(isTouching(Snake.class))
{

}

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

Code to remove an object from the game world that the object is touching (for example removing an object with the class name Heart)

A

removeTouching(Heart.class) ;

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

Code to stop the program

A

Greenfoot.stop() ;

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

Code to add 1 to the counter from another character

A

Counter counter = (Counter)getWorld().getObjects(Counter.class).get(0) ;
counter.add(1) ;

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

Code to make the character turn a random angle between -45 and 45

A

turn(Greenfoot.getRandomNumber (90) -45);

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

Code to carry out a part of the program a suitable amount (used for random turning)

A

if (Greenfoot.getRandomNumber (10) <1)
{

}

17
Q

How to set up the world subclass

A

Right click world and select new subclass
Choose image and name
Compile

18
Q

How to add a character

A

Right click actor and select new subclass
Choose image and name
Compile

19
Q

How to populate and save world

A

Right click on character and select “new …()”
Click where you want the character placed
Right click the background and click “save the world”

20
Q

How to code a character

A

Right click on the character and select open editor
Add code
Click compile in the characters editor window

21
Q

How to make an action constant

A

Add code outside of an if loop but still in the act loop. This section will be white

22
Q

To what character do you add the code for an item to be removed

A

The character that causes the removal by touching the character to be removed

23
Q

How to import a counter

A

Select edit, then import class, then counter
Compile
Add to world and save the world

24
Q

Where and to what character is the code to add one to the counter added to (if counter goes up for touching a collectable character)

A

Inside the isTouching if statement of the character that touched the collectable

25
Q

What is a superclass

A

A section heading e.g “World” or “Actor”

26
Q

What is a class

A

A subclass of a superclass e.g the character or map

27
Q

What method is run automatically

A

public void act()

28
Q

What is a private property

A

A method or attribute accessible in only its declared class

29
Q

What is a public property

A

A method or attribute accessible by any class