From e0db7cc0e8ac6cb121496d37dd725adc76462f4e Mon Sep 17 00:00:00 2001 From: Jonathan Hager Date: Fri, 25 Sep 2020 20:41:57 +0200 Subject: [PATCH] Main model almost finished --- core/src/com/trs/game/Controller.java | 16 +++++++ core/src/com/trs/game/StaticMath.java | 4 ++ core/src/com/trs/game/model/Model.java | 14 +++++++ core/src/com/trs/game/model/PermWall.java | 35 ++++++++++++++++ core/src/com/trs/game/model/Projectile.java | 4 ++ core/src/com/trs/game/model/TempWall.java | 46 +++++++++++++++++++++ core/src/com/trs/game/model/Wall.java | 5 +++ core/src/com/trs/game/view/View.java | 2 +- 8 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 core/src/com/trs/game/StaticMath.java create mode 100644 core/src/com/trs/game/model/PermWall.java create mode 100644 core/src/com/trs/game/model/Projectile.java create mode 100644 core/src/com/trs/game/model/TempWall.java create mode 100644 core/src/com/trs/game/model/Wall.java diff --git a/core/src/com/trs/game/Controller.java b/core/src/com/trs/game/Controller.java index 7ee9b44..25588ac 100644 --- a/core/src/com/trs/game/Controller.java +++ b/core/src/com/trs/game/Controller.java @@ -7,15 +7,31 @@ import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.utils.Timer; +import com.trs.game.model.Model; +import com.trs.game.view.View; public class Controller extends ApplicationAdapter { SpriteBatch batch; ShapeRenderer renderer; + Timer wallTimer; + Model model; + View view; @Override public void create () { batch = new SpriteBatch(); renderer = new ShapeRenderer(); + model = new Model(); + view = new View(); + + wallTimer = new Timer(); + wallTimer.scheduleTask(new Timer.Task() { + @Override + public void run() { + // TODO: Implement timertask + } + }, 0, 1f); } @Override diff --git a/core/src/com/trs/game/StaticMath.java b/core/src/com/trs/game/StaticMath.java new file mode 100644 index 0000000..7f595f0 --- /dev/null +++ b/core/src/com/trs/game/StaticMath.java @@ -0,0 +1,4 @@ +package com.trs.game; + +public class StaticMath { +} diff --git a/core/src/com/trs/game/model/Model.java b/core/src/com/trs/game/model/Model.java index aa27233..c8d8175 100644 --- a/core/src/com/trs/game/model/Model.java +++ b/core/src/com/trs/game/model/Model.java @@ -1,4 +1,18 @@ package com.trs.game.model; + +import java.util.ArrayList; + public class Model { + private Monster monster; + private ArrayList walls; + + public Model(){ + monster = new Monster(); + walls = new ArrayList<>(); + } + + public void timerStep(){ + + } } diff --git a/core/src/com/trs/game/model/PermWall.java b/core/src/com/trs/game/model/PermWall.java new file mode 100644 index 0000000..8f64ce0 --- /dev/null +++ b/core/src/com/trs/game/model/PermWall.java @@ -0,0 +1,35 @@ +package com.trs.game.model; + +import com.badlogic.gdx.math.Rectangle; + +public class PermWall implements Wall { + + private double rotation; + private Rectangle rect; + + public PermWall(double rotation, Rectangle rect){ + this.rotation = rotation; + this.rect = rect; + } + + @Override + public Wall timerStep() { + return this; + } + + public double getRotation() { + return rotation; + } + + public void setRotation(double rotation) { + this.rotation = rotation; + } + + public Rectangle getRect() { + return rect; + } + + public void setRect(Rectangle rect) { + this.rect = rect; + } +} diff --git a/core/src/com/trs/game/model/Projectile.java b/core/src/com/trs/game/model/Projectile.java new file mode 100644 index 0000000..477d359 --- /dev/null +++ b/core/src/com/trs/game/model/Projectile.java @@ -0,0 +1,4 @@ +package com.trs.game.model; + +public class Projectile { +} diff --git a/core/src/com/trs/game/model/TempWall.java b/core/src/com/trs/game/model/TempWall.java new file mode 100644 index 0000000..ed171e5 --- /dev/null +++ b/core/src/com/trs/game/model/TempWall.java @@ -0,0 +1,46 @@ +package com.trs.game.model; + + +import com.badlogic.gdx.math.Rectangle; + +public class TempWall implements Wall { + + private double rotation; + private Rectangle rect; + private int lifetime; + + public TempWall(double rotation, Rectangle rect, int lifetime){ + this.rotation = rotation; + this.rect = rect; + this.lifetime = lifetime; + } + + @Override + public Wall timerStep() { + return null; + } + + public double getRotation() { + return rotation; + } + + public void setRotation(double rotation) { + this.rotation = rotation; + } + + public Rectangle getRect() { + return rect; + } + + public void setRect(Rectangle rect) { + this.rect = rect; + } + + public int getLifetime() { + return lifetime; + } + + public void setLifetime(int lifetime) { + this.lifetime = lifetime; + } +} diff --git a/core/src/com/trs/game/model/Wall.java b/core/src/com/trs/game/model/Wall.java new file mode 100644 index 0000000..f57bde8 --- /dev/null +++ b/core/src/com/trs/game/model/Wall.java @@ -0,0 +1,5 @@ +package com.trs.game.model; + +public interface Wall { + public Wall timerStep(); +} diff --git a/core/src/com/trs/game/view/View.java b/core/src/com/trs/game/view/View.java index 128e1e2..48ceacc 100644 --- a/core/src/com/trs/game/view/View.java +++ b/core/src/com/trs/game/view/View.java @@ -7,7 +7,7 @@ public class View { Rectangle r; Polygon p; - View(){ + public View(){ } }