Npcs and Player collide now

master
GammelJAN 5 years ago
parent 9fe2c07a3f
commit 8937f9c91c

@ -2,6 +2,7 @@ package com.trs.main;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.GL20;
import com.trs.main.view.screens.GameScreen;
import com.trs.main.view.screens.InventoryScreen;
@ -45,6 +46,9 @@ public class Main extends Game{
@Override
public void render () {
if(Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)){
Gdx.app.exit();
}
Gdx.gl.glClearColor(0f, (0), (0), 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

@ -217,6 +217,16 @@ public class MovingNpc extends Actor{
return true;
}
}
else if(a instanceof MovingNpc && a != this){
if(Intersector.overlaps(collisionRect, ((MovingNpc)a).collisionRect)){
return true;
}
}
else if(a instanceof Player){
if(Intersector.overlaps(collisionRect, ((Player)a).collisionRect)){
return true;
}
}
}
return false;
}

@ -45,7 +45,7 @@ public class Player extends Actor{
int[] n = {1, 1};
int[] m = {1, 0};
quest = new InformationQuest(0, "Sprich mit Folgenden NPCs: (Id, mapId, schonGereded?) !Reihenfolge wichtig!", m, n, false);
quest = new InformationQuest(0, "Sprich mit Folgenden NPCs: (Id, mapId, schonGereded?) !Reihenfolge wichtig!", m, n, true);
}
@Override
@ -182,12 +182,16 @@ public class Player extends Actor{
public boolean collidingWithMapCollisionObject(){
for(Actor a : getStage().getActors()){
if(a instanceof MapCollisionObject){
//Rectangle p = new Rectangle(getX(), getY(), getWidth(), getHeight());
Rectangle o = new Rectangle(a.getX(), a.getY(), a.getWidth(), a.getHeight());
if(Intersector.overlaps(collisionRect, o)){
return true;
}
}
else if(a instanceof MovingNpc){
if(Intersector.overlaps(collisionRect, ((MovingNpc)a).collisionRect)){
return true;
}
}
}
return false;
}

@ -8,6 +8,7 @@ public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.resizable = true;
config.width=1280;
config.height=720;
config.fullscreen = false;

Loading…
Cancel
Save