Hi,
I want ask you - how to redraw some lines?
My lines is created by "for", which it repeat randomly on map 50 times.
I want make "raining" in game. Could you help please?
private int thickness = 3;
private int rndmX, rndmY;
public Dead()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
showText("You are dead :(", 300, 240);
}
private void thicknessLine(int x, int y){
for(int j=0;j<thickness;j++){
this.getBackground().drawLine(x+j,y+j,x+100+j,y+200+j);
}
}
public void act(){
for(int i = 0; i < 50; i++){
rndmX = Greenfoot.getRandomNumber(600);
rndmY = Greenfoot.getRandomNumber(400);
thicknessLine(rndmX, rndmY);
}
Greenfoot.delay(1);
}// fields
private GreenfootImage bg;
private GreenfootImage rain = new GreenfootImage("rain.png"); // cannot be a jpeg image (needs transparency)
int rainOffset;
// in constructor
bg = getBackground();
// in act
GreenfootImage bgNew = new GreenfootImage(bg);
rainOffset = (rainOff+4)%getHeight();
bgNew.drawImage(rain, 0, rainOffset);
bgNew.drawImage(rain, 0, rainOffset-getHeight();