/*
 * BgSlider.java
 *
 * Created on 9 janvier 2005, 18:38
 */

package hyperion;
import java.applet.*;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Color;
/**
 *
 * @author CryoGen
 */
public class BgSlider {
    
    private int offset_y;
    private int speed;
    private Image image;
    
    private Applet applet;
    
    /** Creates a new instance of BgSlider */
    public BgSlider(Image img, Applet applet) {
        this.image = img;
        this.applet = applet;
    }
    
    public void slide_y(int speed)
    {
        this.speed = speed;
    }
    
    public void draw(Graphics g) {
                
        this.offset_y = (this.offset_y + speed) % 480;
        
        int dx1 = 0;
        int dy1 = this.offset_y;
        int dx2 = 640;
        int dy2 = 480;
        
        int sx1 = 0;
        int sy1 = 0;
        int sx2 = 640;
        int sy2 = 480 - this.offset_y;
        
        g.drawImage(image, dx1, 0, dx2, this.offset_y, sx1, sy2, sx2, 480, this.applet);
        g.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, this.applet);
    }
    
}
