import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class WilderWesten here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class WilderWesten extends World
{
    private int imageCount;
private GreenfootImage bgImage = new GreenfootImage("weltraum2880x704.jpg");
    /**
     * Constructor for objects of class WilderWesten.
     * 
     */
    public WilderWesten()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(920, 690, 1); 
        this.addObject(new Darth(), 200, this.getHeight()/2);

    }
    public void act() {
    imageCount -= 5; //(or any other value; small -> slow moving, big -> fast movement)
    drawBackgroundImage();
    int z = Greenfoot.getRandomNumber(500);
    if(z > 400)
    {
        this.addObject(new Gegner(), 600, Greenfoot.getRandomNumber(this.getHeight()-30) + 30);
    }
}
 
public void drawBackgroundImage() {
    if (imageCount > bgImage.getWidth()) {
        imageCount += bgImage.getWidth();
    }
    int temp = imageCount;
    getBackground().drawImage(bgImage, temp, 0);
    getBackground().drawImage(bgImage, temp + bgImage.getWidth(), 0);
}
}
