All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.harium.etyl.cinematics.parallax.ImageParallax Maven / Gradle / Ivy

There is a newer version: 1.0.18
Show newest version
package com.harium.etyl.cinematics.parallax;

import com.harium.etyl.core.graphics.Graphics;
import com.harium.etyl.layer.ImageLayer;

public class ImageParallax extends Parallax {

	private ImageLayer layer;
	
	public ImageParallax(String imagePath) {
		super();
		
		layer = new ImageLayer(imagePath);
	}
	
	public ImageParallax(int y, String imagePath) {
		super();
		
		layer = new ImageLayer(0, y, imagePath);
	}

	@Override
	public void draw(Graphics g) {
		int mod = (offset / proximity) % layer.getW();
		
		if(mod == 0) {
			layer.simpleDraw(g, 0, layer.getY());
		} else {
			layer.simpleDraw(g, -mod, layer.getY());
			layer.simpleDraw(g, -mod + layer.getW(), layer.getY());
		}
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy