CannonShooter/core/src/de/samdev/cannonshooter/level/StandardLevel.java

45 lines
1.4 KiB
Java
Raw Normal View History

2015-08-29 12:18:10 +02:00
package de.samdev.cannonshooter.level;
2015-09-14 16:40:30 +02:00
import java.util.Random;
import com.badlogic.gdx.math.Vector2;
2015-08-29 12:18:10 +02:00
import de.samdev.absgdx.framework.AgdxGame;
import de.samdev.absgdx.framework.layer.GameLayer;
import de.samdev.absgdx.framework.map.TileMap;
2015-09-14 16:40:30 +02:00
import de.samdev.absgdx.framework.map.mapscaleresolver.ShowCompleteMapScaleResolver;
2015-08-29 12:18:10 +02:00
import de.samdev.cannonshooter.Textures;
2015-09-14 16:40:30 +02:00
import de.samdev.cannonshooter.entities.Cannon;
import de.samdev.cannonshooter.framework.TileAlignedBackground;
2015-08-29 12:18:10 +02:00
public class StandardLevel extends GameLayer {
public StandardLevel(AgdxGame owner) {
2015-09-14 16:40:30 +02:00
super(owner, TileMap.createEmptyMap(32, 32));
addBackground(new TileAlignedBackground(Textures.texbackground, 1));
setMapScaleResolver(new ShowCompleteMapScaleResolver());
setRawOffset(new Vector2(-(getVisibleMapBox().width - getMap().width)/2, -(getVisibleMapBox().height - getMap().height)/2));
2015-08-29 12:18:10 +02:00
2015-09-14 16:40:30 +02:00
Random R = new Random(80085);
for (int i = 0; i < 24; i++) {
addEntity(new Cannon(R.nextInt(15)*2+1, R.nextInt(15)*2+1));
}
}
@Override
public void onResize() {
super.onResize();
setRawOffset(new Vector2(-(getVisibleMapBox().width - getMap().width)/2, -(getVisibleMapBox().height - getMap().height)/2));
2015-08-29 12:18:10 +02:00
}
@Override
public void onUpdate(float arg0) {
2015-09-14 16:40:30 +02:00
//setRawOffset(new Vector2(-(getVisibleMapBox().width - getMap().width)/2, -(getVisibleMapBox().height - getMap().height)/2));
2015-08-29 12:18:10 +02:00
}
}