package edu.wisc.cs.games10.chrononaut;

import processing.core.PApplet;
import processing.core.PImage;

public class SplashLevel extends Level {
	public SplashLevel(PApplet canvas) {
		levelname = "splash";
		
		pasttiles = Level.loadEraFromImage(levelname, "solidmap", canvas);
		presenttiles = pasttiles;
		futuretiles = pasttiles;
		
		width = pasttiles.length;
		height = pasttiles[0].length;
		
		// get images
		foreground = canvas.loadImage("levels/" + levelname + "/splash.png");
		
		reloadLevel(canvas);
	}
	
	@Override
	public Vector2D getStartLocation() {
		return new Vector2D(1, 10);
	}
	
	@Override
	public PImage getBackground(Era era) {
		return foreground;
	}

	@Override
	public PImage getForeground(Era era) {
		return foreground;
	}
	
	@Override
	public int isLevelFinished(Player p) {
		// switch level only if mid-jump
		if (p.loc.y < 10 && p.vel.y >= 0) {
			if (p.loc.x < 5.5f) {
				return 0;
			} else if (p.loc.x < 10.7f) {
				return 1;
			} else if (p.loc.x < 15.7f){
				return 2;
			}
		}
		return -1;
	}
	
	PImage foreground;
}
