summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-01-22 21:17:25 +0500
committerilotterytea <iltsu@alright.party>2025-01-22 21:17:25 +0500
commit80e7342650a9d71b73a838230733c54c50ffcc1b (patch)
treeb555c40ef4d15f493f2df7b6b7fe527087c4a58f /core/src
parentcbcb7b4bebeadd3f61e2f0c6071a000827188887 (diff)
upd: Vector2 instead of Vector3 for directions (because we don't actually need the y coordinate)
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/java/kz/ilotterytea/frogartha/entities/LocalPlayerEntity.java7
-rw-r--r--core/src/main/java/kz/ilotterytea/frogartha/entities/RenderableEntity.java5
-rw-r--r--core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionHandlers.java6
3 files changed, 12 insertions, 6 deletions
diff --git a/core/src/main/java/kz/ilotterytea/frogartha/entities/LocalPlayerEntity.java b/core/src/main/java/kz/ilotterytea/frogartha/entities/LocalPlayerEntity.java
index 4971635..f3d3ef1 100644
--- a/core/src/main/java/kz/ilotterytea/frogartha/entities/LocalPlayerEntity.java
+++ b/core/src/main/java/kz/ilotterytea/frogartha/entities/LocalPlayerEntity.java
@@ -3,6 +3,7 @@ package kz.ilotterytea.frogartha.entities;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Camera;
+import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.collision.Ray;
import kz.ilotterytea.frogartha.FrogarthaGame;
@@ -52,10 +53,10 @@ public class LocalPlayerEntity extends PlayerEntity {
Ray ray = camera.getPickRay(Gdx.input.getX(), Gdx.input.getY());
final float distance = -ray.origin.y / ray.direction.y;
Vector3 point = new Vector3(ray.direction).scl(distance).add(ray.origin);
- Vector3 direction = new Vector3(point.x, position.y, point.z);
+ Vector2 d = new Vector2(point.x, point.z);
- if (direction.x != this.direction.x || direction.z != this.direction.z) {
- FrogarthaGame.getInstance().getSessionClient().send(new ChangedDirectionAction(direction));
+ if (d.x != this.direction.x || d.y != this.direction.z) {
+ FrogarthaGame.getInstance().getSessionClient().send(new ChangedDirectionAction(d));
}
}
diff --git a/core/src/main/java/kz/ilotterytea/frogartha/entities/RenderableEntity.java b/core/src/main/java/kz/ilotterytea/frogartha/entities/RenderableEntity.java
index 181be14..4a6e547 100644
--- a/core/src/main/java/kz/ilotterytea/frogartha/entities/RenderableEntity.java
+++ b/core/src/main/java/kz/ilotterytea/frogartha/entities/RenderableEntity.java
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g3d.decals.Decal;
import com.badlogic.gdx.graphics.g3d.decals.DecalBatch;
+import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.collision.BoundingBox;
@@ -51,6 +52,10 @@ public abstract class RenderableEntity extends Entity {
setDirection(dir.x, dir.y, dir.z);
}
+ public void setDirection(Vector2 dir) {
+ setDirection(dir.x, position.y, dir.y);
+ }
+
public void setDirection(float x, float y, float z) {
direction.set(x, y, z);
decal.lookAt(direction, Vector3.Y);
diff --git a/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionHandlers.java b/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionHandlers.java
index 38e8578..35311ac 100644
--- a/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionHandlers.java
+++ b/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionHandlers.java
@@ -1,6 +1,6 @@
package kz.ilotterytea.frogartha.sessions;
-import com.badlogic.gdx.math.Vector3;
+import com.badlogic.gdx.math.Vector2;
import kz.ilotterytea.frogartha.FrogarthaGame;
import kz.ilotterytea.frogartha.domain.PlayerData;
import kz.ilotterytea.frogartha.domain.RoomTopic;
@@ -81,9 +81,9 @@ public class SessionHandlers {
return;
}
- Vector3 direction = event.getDirection();
+ Vector2 direction = event.getDirection();
- entity.setDirection(direction.x, entity.getPosition().y, direction.z);
+ entity.setDirection(direction.x, entity.getPosition().y, direction.y);
}
public static void handleSenderJoinedRoomEvent(SenderJoinedRoomEvent event) {