fertprofiles.blogg.se

Getworld greenfoot
Getworld greenfoot







getworld greenfoot

Ground topedge = new Ground('topedge1.png') If(isTouching(pionBlanc.class)||isTouching(roiBlanc.class)||isTouching(tourBlanc.class)||isTouching(fouBlanc.class)||isTouching(reineBlanc.class)||isTouching(chevalBlanc.class)) GreenfootImage image = new GreenfootImage('carreVert.jpg') * the 'Act' or 'Run' button gets pressed in the environment. * Act - do whatever the carreVert wants to do. * Write a description of class carreVert here. I'm trying to make it that the world will spawn spikes within itself at random coordinates every 6 seconds.Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) It is not the same 'counter' field that is declared near the top of the class.As I said, i'm very new to coding. Again the 'counter' variable is declared within the 'for' statement and its scope is limited to the 'for' loop. I did notice the somewhat strange use of the 'for' loop using a 'counter' variable. That is ambiguous, as it could be interpreted as being in context with time or with space (locations throughout the map). Your initial statement used the phrase 'at set intervals' when referring to the random spawning of spikes throughout your map. Still, assigning it after calling 'addSpikes', when the method needs it assigned first, is kind of pointless. If that be the case, you could just remove the 'int' at the beginning of the line thereby, not declaring a local field, but using the static field declared above. Maybe you intended that this line assign a value to your static field with the same name. It creates and assigns a variable that is local to the constructor (its scope is bound to the constructor itself) then, it is ignored that is, it is not ever referred to or utilized later within the constructor.

getworld greenfoot

Line 14 is what I call a 'hanger' line - it has no purpose. In fact, it is never assigned a different value EVER. The static field, 'randomNumber' has an initial value of '0' and it is never assigned a different value before the 'addSpikes' method is called in the world constructor. Line 19 compares the value of 'randomNumber' with '0' and will find it never to be greater than '0'.

GETWORLD GREENFOOT CODE

It is not the same 'counter' field that is declared near the top of the class.ĭanpost wrote.The code given will never add spikes into the world, as is.

getworld greenfoot

The code given will never add spikes into the world, as is.









Getworld greenfoot