This site requires JavaScript, please enable it in your browser!
Greenfoot back

What is happening right now?

danpost

reply to Auf Variable Beziehen

By danpost - 1 day ago
You need to add the Explosion objects created in the loop (Bombe: 20) into the world at line 21.
danpost

reply to Having trouble moving invaders left and right

By danpost - 1 day ago
ananyagarg wrote...
In your game, why do your invaders shoot their bullets so fast, and where is the code in your game that determines the speed in which the bullets move?
The demo was geared toward the movement -- not really anything else. However, the shooting code is in the Invader class. The last line in its act method partly controls when a shot is fired by having each invader shoot randomly, but on an average of once every 200 act cycles. In the shoot method, shooting is further limited to only if the invader is the lowest one in its column. For some unknown reason the speed of the scenario was bumped up. Add the following line to the world constructor after the super call: <Code Omitted>That should slow things down to a more suitable speed.
I modified your code a bit to fit my game, but now when my invaders move (since I only have 5 in a row), the first 4 columns move but the last column doesn't move, and the other 4 columns stop at the last column. I am not sure how to fix this This is my code in the invader class: << Code Omitted >> And this is my code in my Row class: << Code Omitted >>
If your world is a different width than mine, that might have something to do with it. The world also has control over the movement of the invaders.
danpost

reply to Having trouble about these pattern by using loop

By danpost - 1 day ago
rickykwl wrote...
may i know what means about % and / ?,
The / is just division. Actually, in this case, it is integer division where any fractional remainder is discarded (only because we are working with integer values). The % is the modulus operator. It returns the remainder after division So, as the iterator, i, progresses from 0 to 31, i/8 will be 0 until i=8, then 1 until i=16, etc., while i%8 will repeatedly go from 0 to 7. One complete cycle from 0 to 7 will occur for each "increment" of i/8 (which will go from 0 to 3).
how to impose the multiple conditions for the second and third pattern?
You will add or subtract using 'i/8' and 'i%8' and set the result greater than or less than some value for each of the two conditions needed for each pattern. The two conditions for each pattern will be either ORed (using '||') or ANDed (using '&&') together. Test one condition at a time before concatenating the two; then determine which operator should join them.