|
|
|
@ -15,7 +15,11 @@ import com.badlogic.gdx.math.Intersector;
|
|
|
|
import com.badlogic.gdx.math.Rectangle;
|
|
|
|
import com.badlogic.gdx.math.Rectangle;
|
|
|
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
|
|
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
|
|
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
|
|
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.utils.Array;
|
|
|
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
|
|
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class MapContainer {
|
|
|
|
public class MapContainer {
|
|
|
|
|
|
|
|
|
|
|
|
@ -40,7 +44,7 @@ public class MapContainer {
|
|
|
|
p.setPosition(64, 64);
|
|
|
|
p.setPosition(64, 64);
|
|
|
|
|
|
|
|
|
|
|
|
stage.addActor(p);
|
|
|
|
stage.addActor(p);
|
|
|
|
stage.addActor(new MovingNpc(new Rectangle(20,20,400,400), 64, 64));
|
|
|
|
stage.addActor(new MovingNpc(new Rectangle(320,320,80,80), 340, 340));
|
|
|
|
|
|
|
|
|
|
|
|
//CREATION OF TILEDMAP
|
|
|
|
//CREATION OF TILEDMAP
|
|
|
|
maploader = new TmxMapLoader();
|
|
|
|
maploader = new TmxMapLoader();
|
|
|
|
@ -80,6 +84,12 @@ public class MapContainer {
|
|
|
|
renderer.setView((OrthographicCamera)stage.getCamera());
|
|
|
|
renderer.setView((OrthographicCamera)stage.getCamera());
|
|
|
|
renderer.render();
|
|
|
|
renderer.render();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Actor[] old = stage.getActors().toArray();
|
|
|
|
|
|
|
|
stage.clear();
|
|
|
|
|
|
|
|
for(Actor a : sort(old)){
|
|
|
|
|
|
|
|
stage.addActor(a);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stage.act(f);
|
|
|
|
stage.act(f);
|
|
|
|
stage.draw();
|
|
|
|
stage.draw();
|
|
|
|
if(Main.gamestate == 1) {
|
|
|
|
if(Main.gamestate == 1) {
|
|
|
|
@ -128,5 +138,21 @@ public class MapContainer {
|
|
|
|
System.out.println("OLD MAP DIDNT FIND PLAYER");
|
|
|
|
System.out.println("OLD MAP DIDNT FIND PLAYER");
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Actor[] sort(Actor[] unsorted){
|
|
|
|
|
|
|
|
// TODO: Textboxes to the end of the Array to draw them last
|
|
|
|
|
|
|
|
for(int j = 0; j < unsorted.length-1; j++){
|
|
|
|
|
|
|
|
for(int i = unsorted.length-1; i >= 0; i--){
|
|
|
|
|
|
|
|
if(i > 0 && unsorted[i].getY() > unsorted[i-1].getY()){
|
|
|
|
|
|
|
|
Actor temp = unsorted[i-1];
|
|
|
|
|
|
|
|
unsorted[i-1] = unsorted[i];
|
|
|
|
|
|
|
|
unsorted[i] = temp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return unsorted;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|