This is my code:
public background() { super(8, 8, 60); setBackground("cell.jpg"); maakland(); maakdijk(); maakWater(); } public void maakland() { land[] land = new land[16]; int b = 0; for (int y = 6; y < 8;){ for (int x = 0; x < 8;){ land[b] = new land(); addObject(land[b], x, y); ++x; ++b; } ++y; } } public void maakdijk() { dijk[] dijk = new dijk[24]; int b = 0; for (int y = 3; y < 6;){ for (int x = 0; x < 8;){ dijk[b] = new dijk(); addObject(dijk[b], x, y); ++x; ++b; } ++y; } } public void maakWater() { Water[] Water = new Water[32]; int b = 0; for (int y = 0; y < 3;){ for (int x = 0; x < 8;){ Water[b] = new Water(); addObject(Water[b], x, y); ++x; ++b; } ++y; } } public void randomWater(int howMany) { for(int i=0; i<howMany; i++) { Water water = new Water(); int x = Greenfoot.getRandomNumber(8); int y = Greenfoot.getRandomNumber(8); } } }
As my backgrond i have the first 3 lines: Water second 3 lines: Dike (that needs to turn to water after playing the animation). third 2 lines: Land.
As you can see i made the background but like i said i want the dike (dijk) to turn into water using randomnumber.. or getoneobjectatoffset..
Any idea how i can do this?