You have at line 9 declared an instance field for a Counter object. ![]() ![]() These non-static fields are also called instance fields because each instance of that class (each object created from that class) will have fields with those names. This is done for each object created from that class. In general terms (using your world class code as an example), when you create an object (like the world that is created when you reset (or re-compile) your project), all non-static fields declared in that class are created, initialized and given to that object. What exactly am i supposed to write in this code? i'm not sure that it means to save it in an instance field :) * set the sound to play in a loop with 50% volume Int x = Greenfoot.getRandomNumber(getWidth()) * The placement of the object is set by the initialized numbers. * then an object is generated with reference to counter in order for the object to refer codes to the codes written in counter. * initializes x as a random number from 0 to the width of the map abd y as 10. If a becomes equal to threshold, it will execute RandomPlacement and then set a as 0 again (loop) * Each time an act is happening, one is added to a. * Creates a world with the size of 1100x500 cells, where every cell is just 1 pixel This initializes (gives an initial value) the new object ![]() * The operator is followed by a call to a contructor. * It sets a java objerator keyword ( this creates the object) * it declares a variable (so it can be used later in the code) * Counter counter = new Counter() does three things: GreenfootSound backgroundMusic = new GreenfootSound("BACKGROUND.wav") Private int thresholdWave = 3 //increase to make the time until a random thing is added longer. Private int threshold = 100 //increase to make the time until a random thing is added longer.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |