greenfoot Flashcards
what does square brackets mean
they are used for arrays
what does move() mean
allows the classes/objects to move and the number inside the brackets dictates how far they move
what does turn() mean
allows the classes to turn and the number inside the bracket dictates how far it turns
what does if() mean
this works the same way an if statement does in python for example if the down key is pressed it will move down (if that’s how you have programmed it)
how do you make your actor move at random
move(1;
if (greenfoot.getrandomnumber(10)<1)
{
turn(greenfoot.getrandomnumber(90)-45);
}
how would you make it so that if your main character touches a specific actor, the specific actor will disappear
if(istouching(cherry.class))
{
removetouching(cherry.class);
}
how do you add a counter to this previous piece of code
if(isTouching(cherry.class))
{
removetouching(cherry.class);
counter counter = (counter)getworld().getobjects(counter.class).get(0);
counter.add(1);
what does round brackets mean
they are used in mathematical expressions, and to surround the parameter lists for method calls
what does curly brackets mean
these are used to surround blocks of code
what does compile mean?
compile combines the different classes and subclasses onto the world, we must compile the classes before we run the program otherwise it wouldn’t work, if we don’t compile the classes, they are unable to go on the world
how do you make your actor turn at random
move(1);
if (Greenfoot.getrandomnumber(10)<1)