From 54ac755456eebf789b7ac56d155e2426430b7daa Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Fri, 21 Apr 2023 14:49:09 +0200
Subject: [PATCH 01/23] render hero

---
 core/src/com/mygdx/game/Board.java            |  4 ----
 core/src/com/mygdx/game/states/PlayState.java | 21 +++++++++++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/core/src/com/mygdx/game/Board.java b/core/src/com/mygdx/game/Board.java
index ba45fd3..96983a8 100644
--- a/core/src/com/mygdx/game/Board.java
+++ b/core/src/com/mygdx/game/Board.java
@@ -314,10 +314,6 @@ public class Board extends Actor {
             Entity hero = HeroFactory.createHero(getChosenHeroType(), placementPosition);
             engine.addEntity(hero);
             System.out.println("Created new hero entity and added to game engine");
-            System.out.println("all heroes: :)");
-            for (Entity e : engine.getEntitiesFor(Family.all(HeroComponent.class).get())) {
-                System.out.println(e.getComponent(HeroComponent.class).getHeroType());
-            }
         }
     }
 
diff --git a/core/src/com/mygdx/game/states/PlayState.java b/core/src/com/mygdx/game/states/PlayState.java
index beb617e..31c8767 100644
--- a/core/src/com/mygdx/game/states/PlayState.java
+++ b/core/src/com/mygdx/game/states/PlayState.java
@@ -1,7 +1,9 @@
 package com.mygdx.game.states;
 
+import com.badlogic.ashley.core.ComponentMapper;
 import com.badlogic.ashley.core.Engine;
 import com.badlogic.ashley.core.Entity;
+import com.badlogic.ashley.core.Family;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 
 import com.badlogic.gdx.Gdx;
@@ -22,6 +24,10 @@ import com.badlogic.gdx.utils.viewport.ScreenViewport;
 import com.mygdx.game.Board;
 import com.mygdx.game.MoneySystem;
 import com.mygdx.game.SoundManager;
+import com.mygdx.game.components.AttackComponent;
+import com.mygdx.game.components.HeroComponent;
+import com.mygdx.game.components.PositionComponent;
+import com.mygdx.game.components.SpriteComponent;
 import com.mygdx.game.entities.DisplayHero;
 import com.mygdx.game.entities.HeroFactory;
 import com.mygdx.game.systems.HeroSystem;
@@ -43,6 +49,9 @@ public class PlayState extends State{
     private static Engine engine;
     private Board board;
     private TextButton counterText1;
+    private List<Image> heroImages = new ArrayList<>();
+    private List<Image> heroProjectiles = new ArrayList<>();
+    private List<Image> monsterImages = new ArrayList<>();
 
     public PlayState() {
         //super(gsm);
@@ -123,6 +132,18 @@ public class PlayState extends State{
         board.getRightTable().row();
     }
 
+    public void renderHeroes() {
+        for (Entity e : engine.getEntitiesFor(Family.all(HeroComponent.class, AttackComponent.class).get())) {
+            Texture sprite = e.getComponent(SpriteComponent.class).getSprite();
+            Vector2 position = e.getComponent(PositionComponent.class).getPosition();
+
+            Image heroImage = new Image(sprite);
+            batch.begin();
+            batch.draw(heroImage, e);
+            heroImages.add(heroImage);
+        }
+    }
+
     @Override
     public void render(SpriteBatch batch) {
 
-- 
GitLab


From 17c6080ac054e1b56f679c9a40c359c6ddcb61c4 Mon Sep 17 00:00:00 2001
From: sindrimt <sindrimt@gmail.com>
Date: Fri, 21 Apr 2023 14:59:59 +0200
Subject: [PATCH 02/23] merged money and dev

---
 core/src/com/mygdx/game/Board.java            | 73 ++++++++++++++++---
 .../mygdx/game/utils/DisplayHeroButton.java   | 13 ++++
 2 files changed, 75 insertions(+), 11 deletions(-)

diff --git a/core/src/com/mygdx/game/Board.java b/core/src/com/mygdx/game/Board.java
index ba45fd3..9d139a0 100644
--- a/core/src/com/mygdx/game/Board.java
+++ b/core/src/com/mygdx/game/Board.java
@@ -9,6 +9,7 @@ import com.badlogic.gdx.InputMultiplexer;
 import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.Pixmap;
 import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g2d.BitmapFont;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.graphics.g2d.TextureRegion;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
@@ -20,6 +21,7 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent;
 import com.badlogic.gdx.scenes.scene2d.Stage;
 import com.badlogic.gdx.scenes.scene2d.ui.Button;
 import com.badlogic.gdx.scenes.scene2d.ui.Image;
+import com.badlogic.gdx.scenes.scene2d.ui.Label;
 import com.badlogic.gdx.scenes.scene2d.ui.Table;
 import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
 import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
@@ -48,9 +50,9 @@ public class Board extends Actor {
     private int cellHeight;
     private SpriteBatch batch;
 
-    private int xOffset = 315; // Add xOffset for moving textures right
     private int yOffset = 0;  // Add yOffset for moving textures up or down
-    private int dashOffset = 315; // Add dashOffset for moving dashed lines right
+    private int xOffset = 225; // Add xOffset for moving textures right (previously 315)
+    private int dashOffset = 225; // Add dashOffset for moving dashed lines right (previously 315)
 
     private Texture[] buttonTextures;
     private Texture[] displayTextures;
@@ -77,6 +79,8 @@ public class Board extends Actor {
     private boolean gridDrawn;
     private boolean isInputProcessorAdded;
     private Engine engine;
+    private MoneySystem moneySystem = new MoneySystem(8000);
+
 
 
     public Board(int rows, int cols, Engine engine) {
@@ -111,6 +115,24 @@ public class Board extends Actor {
         Gdx.input.setInputProcessor(multiplexer);
     }
 
+    private void drawCounter() {
+        float iconSize = Gdx.graphics.getHeight() / 15;
+        float iconX = screenWidth - iconSize * 2 - 160; // Move 200 pixels to the left
+        float iconY = screenHeight - iconSize - 50;
+
+        BitmapFont font = new BitmapFont();
+        font.getData().setScale(3.5f);
+        font.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
+        Texture counterIcon = new Texture("coin.png");
+
+        this.batch.begin();
+        font.draw(batch, String.valueOf(moneySystem.getMoney()), iconX + iconSize * 1.5f, iconY + iconSize * 0.75f);
+
+        batch.draw(counterIcon, iconX, iconY, iconSize, iconSize);
+        this.batch.end();
+    }
+
+
     public int getRows() {
         return rows;
     }
@@ -161,6 +183,9 @@ public class Board extends Actor {
         drawDisplayHeroButtons();
         this.stage.act();
         this.stage.draw();
+        drawCounter();
+
+
 
     }
 
@@ -194,6 +219,10 @@ public class Board extends Actor {
         //Creates new hero entity and sets its position to the middle of the clicked cell
         getChosenHeroType();
         placeHero(heroPlacement);
+
+        System.out.println("Cell clicked: row " + row + ", col " + col);
+        moneySystem.removeMoney(450);
+
     }
 
 
@@ -261,24 +290,30 @@ public class Board extends Actor {
 
     public void drawDisplayHeroButtons() {
         float circleRadius = Gdx.graphics.getHeight() / 15;
-        int diameter = (int) (circleRadius * 2);
+        int diameter = (int) ((circleRadius * 2) + 5);
         Texture circleTexture = createWhiteCircle(circleRadius);
 
+        BitmapFont font = new BitmapFont(); // Create a BitmapFont instance
+        font.getData().setScale(2); // Increase the font size
+        Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE); // Set the font and color (white) for the label style
+
+
         for (final DisplayHeroButton button : displayHeroButtons) {
-            //Group for the DisplayHero-button
             Group buttonGroup = new Group();
-            //Button background
+            // Group for the DisplayHero-button
+
+            // Button background
             Image circle = new Image(circleTexture);
             circle.setPosition(button.getPosition().x - button.getPosition().x / 2, button.getPosition().y);
             circle.setSize(diameter, diameter);
             buttonGroup.addActor(circle);
 
-            //Button with hero-texture
+            // Button with hero-texture
             final Button buttonClickable = new Button(new TextureRegionDrawable(new TextureRegion(button.getTexture())));
             buttonClickable.setPosition(button.getPosition().x, button.getPosition().y);
-            buttonClickable.setSize(button.getWidth(), button.getHeight());
+            buttonClickable.setSize(button.getWidth() - 30, button.getHeight() - 40);
 
-            //Event listener
+            // Event listener
             buttonClickable.addListener(new ClickListener() {
                 @Override
                 public void clicked(InputEvent event, float x, float y) {
@@ -286,11 +321,24 @@ public class Board extends Actor {
                     setChosenHeroType(button.getHeroType());
                 }
             });
+
             buttonGroup.addActor(buttonClickable);
-            stage.addActor(buttonGroup);
+
+            // Create the label for the button number
+            Label buttonNumber = new Label(Integer.toString(button.getPrice()), labelStyle);
+
+            // Adjust the label's position to be centered horizontally and vertically below the button
+            float labelX = button.getPosition().x + (button.getWidth() / 2) - (buttonNumber.getWidth() / 2);
+            float labelY = button.getPosition().y - (buttonNumber.getHeight() * 1.5f);
+            buttonNumber.setPosition(labelX, labelY);
+
+            buttonGroup.addActor(buttonNumber); // Add the label to the buttonGroup
+            stage.addActor(buttonGroup); // Add the buttonGroup to the stage
+
         }
     }
 
+
     /* Tegner heroesene og den hvite sirkelen bak.
         for (DisplayHeroButton button : displayHeroButtons) {
             //draw circles
@@ -340,13 +388,16 @@ public class Board extends Actor {
         shapeRenderer.setColor(leftRightPaneColor);
         shapeRenderer.rect(0, 0, Gdx.graphics.getWidth() / 8, Gdx.graphics.getHeight());
 
-        // Draw right pane background
+        // Draw right pane background with increased padding
+        float padding = 80;
+        float rightPaneWidth = Gdx.graphics.getWidth() / 8;
         shapeRenderer.setColor(leftRightPaneColor);
-        shapeRenderer.rect(Gdx.graphics.getWidth() * 7 / 8, 0, Gdx.graphics.getWidth() / 8, Gdx.graphics.getHeight());
+        shapeRenderer.rect(Gdx.graphics.getWidth() - rightPaneWidth - padding, 0, rightPaneWidth + padding, Gdx.graphics.getHeight());
 
         shapeRenderer.end();
     }
 
+
     public Table getRightTable() {
         return rightTable;
     }
diff --git a/core/src/com/mygdx/game/utils/DisplayHeroButton.java b/core/src/com/mygdx/game/utils/DisplayHeroButton.java
index 9aeaeeb..1132c8a 100644
--- a/core/src/com/mygdx/game/utils/DisplayHeroButton.java
+++ b/core/src/com/mygdx/game/utils/DisplayHeroButton.java
@@ -12,6 +12,17 @@ public class DisplayHeroButton {
     float height;
     Texture texture;
     HeroType heroType;
+    int price;
+
+
+    public int getPrice() {
+        return price;
+    }
+
+    public void setPrice(int price) {
+        this.price = price;
+    }
+
 
     public float getWidth() {
         return width;
@@ -43,6 +54,7 @@ public class DisplayHeroButton {
         this.heroType = displayHero.getHeroComponent().getHeroType();
         this.height = displayHero.getSpriteComponent().getSprite().getHeight() * 4;
         this.width = displayHero.getSpriteComponent().getSprite().getWidth() * 4;
+        this.price = displayHero.getPriceComponent().getPrice();
     }
 
     public Vector2 getPosition() {
@@ -61,3 +73,4 @@ public class DisplayHeroButton {
         this.texture = texture;
     }
 }
+
-- 
GitLab


From d00ea56e03fa0879bf8adff67188bf89a03712ec Mon Sep 17 00:00:00 2001
From: Johannes Finne Reinseth <johannes.reinseth@aboveit.no>
Date: Fri, 21 Apr 2023 15:14:21 +0200
Subject: [PATCH 03/23] feat: leave game from settings in singleplayer

---
 .../{sprites => ds/buttons}/CircleButton.java |  3 +-
 .../game/ds/buttons/RectangleButton.java      | 51 +++++++++++
 .../src/com/mygdx/game/states/DummyState.java |  3 +-
 .../com/mygdx/game/states/GameMenuState.java  |  3 +-
 .../mygdx/game/states/GameStateManager.java   |  3 +
 core/src/com/mygdx/game/states/PlayState.java | 21 ++++-
 .../com/mygdx/game/states/SettingsState.java  | 91 ++++++++++++-------
 .../src/com/mygdx/game/states/StartState.java |  5 +-
 core/src/com/mygdx/game/utils/Enums.java      | 19 ++++
 core/src/com/mygdx/game/utils/Slider.java     | 26 ++----
 10 files changed, 163 insertions(+), 62 deletions(-)
 rename core/src/com/mygdx/game/{sprites => ds/buttons}/CircleButton.java (96%)
 create mode 100644 core/src/com/mygdx/game/ds/buttons/RectangleButton.java
 create mode 100644 core/src/com/mygdx/game/utils/Enums.java

diff --git a/core/src/com/mygdx/game/sprites/CircleButton.java b/core/src/com/mygdx/game/ds/buttons/CircleButton.java
similarity index 96%
rename from core/src/com/mygdx/game/sprites/CircleButton.java
rename to core/src/com/mygdx/game/ds/buttons/CircleButton.java
index 4ea6a44..edb8196 100644
--- a/core/src/com/mygdx/game/sprites/CircleButton.java
+++ b/core/src/com/mygdx/game/ds/buttons/CircleButton.java
@@ -1,4 +1,4 @@
-package com.mygdx.game.sprites;
+package com.mygdx.game.ds.buttons;
 
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
@@ -13,7 +13,6 @@ public class CircleButton {
     private int radius;
     private Texture img;
 
-
     public CircleButton(int radius, int xStart, int yStart, String internalPath) {
         this.radius = radius;
         this.position = new Vector2(xStart, yStart);
diff --git a/core/src/com/mygdx/game/ds/buttons/RectangleButton.java b/core/src/com/mygdx/game/ds/buttons/RectangleButton.java
new file mode 100644
index 0000000..7e692d7
--- /dev/null
+++ b/core/src/com/mygdx/game/ds/buttons/RectangleButton.java
@@ -0,0 +1,51 @@
+package com.mygdx.game.ds.buttons;
+
+import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
+import com.badlogic.gdx.math.Rectangle;
+import com.badlogic.gdx.math.Vector2;
+
+public class RectangleButton {
+
+    private final Vector2 position;
+    private final Rectangle bounds;
+    private final ShapeRenderer shape;
+    private final Texture img;
+    private final int width;
+    private final int height;
+    private final float scale;
+
+    public RectangleButton(float scale, int xStart, int yStart, String internalPath) {
+        this.scale = scale;
+        this.img = new Texture(internalPath);
+        this.width = (int) (img.getWidth() * scale);
+        this.height = (int ) (img.getHeight() * scale);
+        this.position = new Vector2(xStart, yStart);
+        this.bounds = new Rectangle(xStart, yStart, width, height);
+        this.shape = new ShapeRenderer();
+    }
+
+    public Vector2 getPosition() {
+        return position;
+    }
+
+    public Rectangle getBounds() {
+        return bounds;
+    }
+
+    public ShapeRenderer getShape() {
+        return shape;
+    }
+
+    public int getWidth() {return this.width;}
+
+    public int getHeight() {return this.height;}
+
+    public Texture getImg() {
+        return img;
+    }
+
+    public float getScale() {
+        return scale;
+    }
+}
diff --git a/core/src/com/mygdx/game/states/DummyState.java b/core/src/com/mygdx/game/states/DummyState.java
index 5f861d2..323f8b0 100644
--- a/core/src/com/mygdx/game/states/DummyState.java
+++ b/core/src/com/mygdx/game/states/DummyState.java
@@ -5,6 +5,7 @@ import com.badlogic.gdx.Input;
 import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.utils.ScreenUtils;
+import com.mygdx.game.utils.Enums;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -34,7 +35,7 @@ public class DummyState extends State {
         if (Gdx.input.isKeyPressed(Input.Keys.ENTER)) {
             bg.set(2, 0f);
             bg.set(1, 1f);
-            gsm.push(new SettingsState(SettingsState.SettingsBackground.CITY));
+            gsm.push(new SettingsState(Enums.SettingsBackground.CITY, Enums.GameType.MENU));
         }
     }
 
diff --git a/core/src/com/mygdx/game/states/GameMenuState.java b/core/src/com/mygdx/game/states/GameMenuState.java
index db97537..c40bc54 100644
--- a/core/src/com/mygdx/game/states/GameMenuState.java
+++ b/core/src/com/mygdx/game/states/GameMenuState.java
@@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.utils.ScreenUtils;
 import com.mygdx.game.FireBaseInterface;
 import com.mygdx.game.SoundManager;
+import com.mygdx.game.utils.Enums;
 
 public class GameMenuState extends State {
     private GameStateManager gsm;
@@ -137,7 +138,7 @@ public class GameMenuState extends State {
                 gsm.push(new IntroCutsceneState());
             }
             if (isLobbyButtonClicked(x, y)) {
-                gsm.push(new SettingsState(SettingsState.SettingsBackground.CITY));
+                gsm.push(new SettingsState(Enums.SettingsBackground.CITY, Enums.GameType.MENU));
             }
             if (isMenuButtonClicked(x, y)) {
                 gsm.push(new StartState());
diff --git a/core/src/com/mygdx/game/states/GameStateManager.java b/core/src/com/mygdx/game/states/GameStateManager.java
index f72bcc6..319c9e5 100644
--- a/core/src/com/mygdx/game/states/GameStateManager.java
+++ b/core/src/com/mygdx/game/states/GameStateManager.java
@@ -19,6 +19,9 @@ public class GameStateManager {
     public void push(State state) {
         states.push(state);
     }
+    public Stack<State> getStates() {
+        return states;
+    }
 
     public void pop() {
         states.pop();
diff --git a/core/src/com/mygdx/game/states/PlayState.java b/core/src/com/mygdx/game/states/PlayState.java
index 26337b3..9fa7d87 100644
--- a/core/src/com/mygdx/game/states/PlayState.java
+++ b/core/src/com/mygdx/game/states/PlayState.java
@@ -24,7 +24,9 @@ import com.mygdx.game.MoneySystem;
 import com.mygdx.game.SoundManager;
 import com.mygdx.game.entities.DisplayHero;
 import com.mygdx.game.entities.HeroFactory;
+import com.mygdx.game.ds.buttons.RectangleButton;
 import com.mygdx.game.types.HeroType;
+import com.mygdx.game.utils.Enums;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -44,9 +46,13 @@ public class PlayState extends State{
 
     private MoneySystem moneySystem;
     private boolean isPlacementAllowed = false;
+    private final RectangleButton menuButton;
+    private final GameStateManager gsm;
 
     public PlayState() {
         //super(gsm);
+        menuButton = new RectangleButton(0.5f, Gdx.graphics.getWidth() - 137, Gdx.graphics.getHeight() - 100, "Lobby-button.png");
+        gsm = GameStateManager.getGsm();
         init();
     }
 
@@ -247,6 +253,7 @@ public class PlayState extends State{
     @Override
     public void update(float dt) {
         stage.draw();
+        handleInput();
     }
 
     @Override
@@ -257,13 +264,25 @@ public class PlayState extends State{
 
         drawPaneBackgrounds();
         drawLaneDividers();
+        sb.begin();
+        sb.draw(menuButton.getImg(), menuButton.getPosition().x - menuButton.getWidth() / 2f, menuButton.getPosition().y, menuButton.getWidth(), menuButton.getHeight());
+        sb.end();
 
         stage.act(Gdx.graphics.getDeltaTime());
         stage.draw();
     }
 
     @Override
-    public void handleInput() {}
+    public void handleInput() {
+        if (Gdx.input.isTouched()) {
+            float touchX = Gdx.input.getX();
+            float touchY = Gdx.graphics.getHeight() - Gdx.input.getY();
+            if (menuButton.getBounds().contains(touchX, touchY)) {
+                //Implement Game.pause();
+                gsm.push(new SettingsState(Enums.SettingsBackground.CITY, Enums.GameType.SINGLEPLAYER));
+            }
+        }
+    }
 
     private void drawPaneBackgrounds() {
         shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
diff --git a/core/src/com/mygdx/game/states/SettingsState.java b/core/src/com/mygdx/game/states/SettingsState.java
index 726f414..9f008f7 100644
--- a/core/src/com/mygdx/game/states/SettingsState.java
+++ b/core/src/com/mygdx/game/states/SettingsState.java
@@ -1,40 +1,37 @@
 package com.mygdx.game.states;
 
 import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.files.FileHandle;
 import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.graphics.g2d.BitmapFont;
 import com.badlogic.gdx.graphics.g2d.GlyphLayout;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
-import com.badlogic.gdx.scenes.scene2d.ui.Skin;
-import com.badlogic.gdx.utils.Json;
 import com.badlogic.gdx.utils.ScreenUtils;
-import com.mygdx.game.sprites.CircleButton;
+import com.mygdx.game.ds.buttons.CircleButton;
+import com.mygdx.game.ds.buttons.RectangleButton;
+import com.mygdx.game.utils.Enums;
 import com.mygdx.game.utils.SettingsData;
 import com.mygdx.game.utils.Slider;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 
 public class SettingsState extends State {
-    private GameStateManager gsm;
-    private BitmapFont font;
-    public enum SettingsBackground {
-        MENU,
-        CITY,
-    }
+    private final GameStateManager gsm;
+    private final BitmapFont font;
     private ArrayList<Float> bgColor;
     private Boolean isBlack;
     private final CircleButton exitButton;
+    private final RectangleButton leaveGameButton;
     private final Slider audioBar;
     private final Slider sfxBar;
     private Texture bgImage;
+    private final Enums.GameType gameType;
 
-    public SettingsState(SettingsBackground bg) {
+    public SettingsState(Enums.SettingsBackground bg, Enums.GameType type) {
         gsm = GameStateManager.getGsm();
         font = new BitmapFont();
+        gameType = type;
 
         switch (bg) {
             case MENU:
@@ -49,9 +46,22 @@ public class SettingsState extends State {
                 break;
         }
 
+        switch (type) {
+            //Replace with leave game button when implemented
+            case SINGLEPLAYER:
+                leaveGameButton = new RectangleButton(0.7f, Gdx.graphics.getWidth() / 2, 30, "Lobby-button.png");
+                break;
+            case MULTIPLAYER:
+                leaveGameButton = new RectangleButton(0.7f, Gdx.graphics.getWidth() / 2, 30, "Lobby-button.png");
+                break;
+            default:
+                //For testing
+                leaveGameButton = new RectangleButton(0.7f, Gdx.graphics.getWidth() / 2, 30, "Lobby-button.png");
+        }
+
         exitButton = new CircleButton(70, Gdx.graphics.getWidth() - 200, Gdx.graphics.getHeight() - 140, "redExitCross.png");
-        audioBar = new Slider(Slider.SliderType.AUDIO, 800, 30, 100);
-        sfxBar = new Slider(Slider.SliderType.SFX, 800, 30, -100);
+        audioBar = new Slider(Enums.SliderType.AUDIO, 800, 30, 100);
+        sfxBar = new Slider(Enums.SliderType.SFX, 800, 30, -100);
         if (isBlack) {
             font.setColor(Color.BLACK);
         } else {
@@ -59,6 +69,36 @@ public class SettingsState extends State {
         }
     }
 
+    private void renderText(SpriteBatch sb) {
+        font.getData().setScale(8f);
+        GlyphLayout glyphLayout = new GlyphLayout();
+        glyphLayout.setText(font, "Settings");
+        font.draw(sb, "Settings", Gdx.graphics.getWidth() / 2f - glyphLayout.width / 2, Gdx.graphics.getHeight() - 80);
+        font.getData().setScale(3f);
+        font.draw(sb, "Audio", Gdx.graphics.getWidth() / 2f - 400, Gdx.graphics.getHeight() / 2f + 170);
+        font.draw(sb, "SFX", Gdx.graphics.getWidth() / 2f - 400, Gdx.graphics.getHeight() / 2f -30);
+    }
+
+    private void renderExitButton(SpriteBatch sb) {
+        sb.draw(exitButton.getImg(), exitButton.getPosition().x - 40, exitButton.getPosition().y - 40, 80, 80);
+    }
+    private void renderAudioBar() {
+        audioBar.render();
+    }
+    private void renderSfxBar() {
+        sfxBar.render();
+    }
+    private void renderLeaveGame(SpriteBatch sb) {
+        switch (gameType) {
+            case SINGLEPLAYER:
+            case MULTIPLAYER:
+                sb.draw(leaveGameButton.getImg(), leaveGameButton.getPosition().x - leaveGameButton.getWidth() / 2f, leaveGameButton.getPosition().y, leaveGameButton.getWidth(), leaveGameButton.getHeight());
+                break;
+            default:
+                break;
+        }
+    }
+
     @Override
     public void update(float dt) {
         handleInput();
@@ -69,8 +109,9 @@ public class SettingsState extends State {
         ScreenUtils.clear(bgColor.get(0), bgColor.get(1), bgColor.get(2), bgColor.get(3));
         sb.begin();
         sb.draw(bgImage, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
-        renderHeader(sb);
+        renderText(sb);
         renderExitButton(sb);
+        renderLeaveGame(sb);
         sb.end();
         renderAudioBar();
         renderSfxBar();
@@ -84,6 +125,8 @@ public class SettingsState extends State {
             if (exitButton.getBounds().contains(touchX, touchY)) {
                 //dispose();
                 gsm.pop();
+            } else if(leaveGameButton.getBounds().contains(touchX, touchY)) {
+                gsm.set(new GameMenuState());
             } else {
                 SettingsData settingsData = SettingsData.loadSettings();
                 settingsData.saveSettings();
@@ -98,23 +141,5 @@ public class SettingsState extends State {
         font.dispose();
     }
 
-    private void renderHeader(SpriteBatch sb) {
-        font.getData().setScale(8f);
-        GlyphLayout glyphLayout = new GlyphLayout();
-        glyphLayout.setText(font, "Settings");
-        font.draw(sb, "Settings", Gdx.graphics.getWidth() / 2 - glyphLayout.width / 2, Gdx.graphics.getHeight() - 80);
-    }
-
-    private void renderExitButton(SpriteBatch sb) {
-        sb.draw(exitButton.getImg(), exitButton.getPosition().x - 40, exitButton.getPosition().y - 40, 80, 80);
-    }
-
-    private void renderAudioBar() {
-        audioBar.render();
-    }
-
-    private void renderSfxBar() {
-        sfxBar.render();
-    }
 
 }
diff --git a/core/src/com/mygdx/game/states/StartState.java b/core/src/com/mygdx/game/states/StartState.java
index 8d6fa75..8e29ed9 100644
--- a/core/src/com/mygdx/game/states/StartState.java
+++ b/core/src/com/mygdx/game/states/StartState.java
@@ -51,12 +51,9 @@ public class StartState extends State implements InputProcessor {
         board.setTexture(4, 3, texture1);
         board.setTexture(5, 3, texture1);
 
-
         board.setTexture(4, 5, texture1);
-
-
-
     }
+
     @Override
     public void update(float dt) {
 
diff --git a/core/src/com/mygdx/game/utils/Enums.java b/core/src/com/mygdx/game/utils/Enums.java
new file mode 100644
index 0000000..573fc69
--- /dev/null
+++ b/core/src/com/mygdx/game/utils/Enums.java
@@ -0,0 +1,19 @@
+package com.mygdx.game.utils;
+
+public class Enums {
+    public enum GameType {
+        SINGLEPLAYER,
+        MULTIPLAYER,
+        MENU
+    }
+
+    public enum SettingsBackground {
+        MENU,
+        CITY,
+    }
+
+    public enum SliderType {
+        AUDIO,
+        SFX
+    }
+}
diff --git a/core/src/com/mygdx/game/utils/Slider.java b/core/src/com/mygdx/game/utils/Slider.java
index 25c40ad..867a25a 100644
--- a/core/src/com/mygdx/game/utils/Slider.java
+++ b/core/src/com/mygdx/game/utils/Slider.java
@@ -1,29 +1,15 @@
 package com.mygdx.game.utils;
 
 import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.files.FileHandle;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
 import com.badlogic.gdx.math.MathUtils;
-import com.badlogic.gdx.utils.Json;
-import com.badlogic.gdx.utils.JsonReader;
-import com.badlogic.gdx.utils.JsonValue;
 import com.mygdx.game.HeroesVsMonsters;
 
-import java.awt.SystemTray;
-import java.io.File;
-
 public class Slider {
-    public enum SliderType {
-        AUDIO,
-        SFX
-    }
     private final ShapeRenderer shapeRenderer;
     private final SpriteBatch sb;
-    private final float SCREEN_WIDTH;
-    private final float SCREEN_HEIGHT;
-
-    private final SliderType type;
+    private final Enums.SliderType sliderType;
     private final float width;
     private final float height;
     private float sliderValue;
@@ -35,12 +21,12 @@ public class Slider {
     private float isTouched;
     private final SettingsData settingsData;
 
-    public Slider(SliderType type, float barWidth, float barHeight, float yPos) {
+    public Slider(Enums.SliderType type, float barWidth, float barHeight, float yPos) {
         //General variables
         sb = HeroesVsMonsters.getSb();
         shapeRenderer = new ShapeRenderer();
-        SCREEN_WIDTH = Gdx.graphics.getWidth();
-        SCREEN_HEIGHT = Gdx.graphics.getHeight();
+        float SCREEN_WIDTH = Gdx.graphics.getWidth();
+        float SCREEN_HEIGHT = Gdx.graphics.getHeight();
 
         settingsData = SettingsData.loadSettings();
 
@@ -56,7 +42,7 @@ public class Slider {
         }
 
         //Local variables
-        this.type = type;
+        this.sliderType = type;
         this.width = barWidth;
         this.height = barHeight;
         this.yPos = yPos;
@@ -116,7 +102,7 @@ public class Slider {
         if (isTouched < 0.1f && isTouched >= 0) {
             isTouched += Gdx.graphics.getDeltaTime();
         } else if (isTouched >= 0){
-            switch (type) {
+            switch (sliderType) {
                 case AUDIO:
                     settingsData.AUDIO = ((int) (sliderValue * 100));
                     break;
-- 
GitLab


From a6a06dadc4c3dd8a87efa8914c9c254e7b6cd666 Mon Sep 17 00:00:00 2001
From: Anh <qapham@stud.ntnu.no>
Date: Fri, 21 Apr 2023 15:36:48 +0200
Subject: [PATCH 04/23] Add back button to board and change start button to
 play button. And some styling

---
 assets/backButton.png                         | Bin 0 -> 3337 bytes
 assets/playButton.png                         | Bin 0 -> 4704 bytes
 core/src/com/mygdx/game/Board.java            |  25 ++++++++++++++++++
 .../com/mygdx/game/states/GameMenuState.java  |  10 ++++---
 4 files changed, 31 insertions(+), 4 deletions(-)
 create mode 100644 assets/backButton.png
 create mode 100644 assets/playButton.png

diff --git a/assets/backButton.png b/assets/backButton.png
new file mode 100644
index 0000000000000000000000000000000000000000..ff020072d4122e935bc2644734bb3b320e540782
GIT binary patch
literal 3337
zcmd5<YdDna8Xm@|h%#YJvO+VZ9Y$oOP?OL|yKJk*m`O7vgNcNk%3(s1mIf=6wj6fT
z)h<4%d?a#83x!d8%{b+-oTe!nnTVX$`_<ZAS9|Xt`^Ua^>(9(w?|Z%P`#ksaJokN1
zvdjKGYAUN$P$-m|6UE*Yg;EfJ-$_fA!KXXg1P{IxLR|OQp^949NKvTekDcsy9gH|K
z*0Z_w@Dp*OCvRUr%0MGy9RW+QuhU$UX6>out$mbbXnzr9XSl{($t%gKn3zGc8(&uG
zRxM(mnv7h0-zS2F_X}Dl%Bvp6EIv|Ol)bx7>O0<1YO*OWPLZ*+^343)yyNxDf0o9t
zrW|aWR58k{iB;91)Jn~GipI`bE@ZAt4OyjTxd8Rd6{G2*uL;)8&>L&+9aO+*F2#WL
zX0l4L@gcGT#!dmf5oPg>j`fFf?d^tzZq<pE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m;0}L(i{c-+E7ce#BXMu*69(h|kIFmSp!)`N`!$aoH;qDA4)1A@;
z+BFEsyU#Cl=MiT_qi>7uGeMAZb|4RFr>Q~Sglcj>259v0M=#?W<f=_1Lh#`cPSdd~
zvU{cJhhttWyStqstiRCwcQ~_|kBA}|`D%dEOrj=>`{KTb9eEhA%om^}xO66E=s|OP
z`ZKe>V*$kSIl-#W#mo8&$0UpNNpz{8=P*CWRsUIwrzFBzTp^KtZ!&nrcS4dtjKktz
z4DMl8m516cyYKuV^qQiIQINL6!~qK8S_fhs1_lyC&6KfPp^uOqJzzhBCc$-oG;8{`
zh5On+@5fQ{g*%@%ExKBDw!?@o#Va-LG}v{<e{oL9uZwILRfJgU1tz#;|9P$^%l&qo
zqDq3IvMb6*A4ALh6L9hQaa_$f(6N~}z<II}OCQ5hc8xoB3xKjxMTeqr<y#$t$RAas
YDI05ca{^qze;bsO!+!fBJJ#9X08P@#I{*Lx

literal 0
HcmV?d00001

diff --git a/assets/playButton.png b/assets/playButton.png
new file mode 100644
index 0000000000000000000000000000000000000000..addcff5a203d9c1ec00756d28e86bb48660d87e3
GIT binary patch
literal 4704
zcmeHLX;hO}8YU5hV54kG4FQowQxvp{W7tZJKoT|qk)<NwfQNwA1P~O9KosKwrVw_k
zKv+bUBDhdNHi<PwQ9@-^QBoMNY=WQ$5t#S;!Vi1S%%3@@b7tv}8}jkp`@YY8-sdh)
z&bc_#@X7>bIXO8zgKpy{Cx<1%_d=zm@Tpl~@CyE5!rf?8x$?)v-{j=f2n?GY?#Fz`
zE?1TtdaBx9GgPc1nrDjjR(s!@SJcmnUlXShix)5?T8@3<FV*#J<lZQ%G<p5iARm{M
zs6%jmJKQzv-WBE(Q5rH<)3JBXuKu+ZckaDpHfL`0p+HeuoV<Z92al_bnHsLcKRaHP
zZik;u&*S#@L^iKTM_*zwcpAn-<btQsI!3**YDtZAN=)*2(QmO%1(Ms<jlA_396c8Y
zz0?J~s$vP*{;?&FPQj{?Q{uS&ju*9J(zyX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XuW<WGX8#N09Jdk|mR7eKSW-D(UV@*D<QTTj
KHsw_RlYa;KL;)NC

literal 0
HcmV?d00001

diff --git a/core/src/com/mygdx/game/Board.java b/core/src/com/mygdx/game/Board.java
index ba45fd3..95898ad 100644
--- a/core/src/com/mygdx/game/Board.java
+++ b/core/src/com/mygdx/game/Board.java
@@ -28,6 +28,9 @@ import com.badlogic.gdx.utils.Array;
 import com.mygdx.game.components.HeroComponent;
 import com.mygdx.game.entities.DisplayHero;
 import com.mygdx.game.entities.HeroFactory;
+import com.mygdx.game.states.GameMenuState;
+import com.mygdx.game.states.GameStateManager;
+import com.mygdx.game.states.PlayState;
 import com.mygdx.game.types.HeroType;
 import com.mygdx.game.utils.DisplayHeroButton;
 
@@ -46,6 +49,7 @@ public class Board extends Actor {
     private int textureHeight;
     private int cellWidth;
     private int cellHeight;
+    private GameStateManager gsm;
     private SpriteBatch batch;
 
     private int xOffset = 315; // Add xOffset for moving textures right
@@ -80,6 +84,7 @@ public class Board extends Actor {
 
 
     public Board(int rows, int cols, Engine engine) {
+        gsm = GameStateManager.getGsm();
         this.engine = engine;
         this.rows = rows;
         this.cols = cols;
@@ -155,6 +160,7 @@ public class Board extends Actor {
         //drawDisplayPanel(batch);
 
         this.batch.begin();
+        drawBackButton();
         drawHeroes();
         this.batch.end();
 
@@ -164,6 +170,25 @@ public class Board extends Actor {
 
     }
 
+    private void drawBackButton() {
+        Texture backButton = new Texture("backButton.png");
+        float buttonWidth = screenWidth / 10;
+        float buttonHeight = buttonWidth * ((float) backButton.getHeight() / backButton.getWidth());
+        float buttonX = 10;
+        float buttonY = 10;
+        batch.draw(backButton, buttonX, buttonY, buttonWidth, buttonHeight);
+
+        if (Gdx.input.isTouched()) {
+            int x = Gdx.input.getX();
+            int y = Gdx.input.getY();
+            if (Gdx.input.justTouched() && buttonX <= x && x <= buttonX + buttonWidth &&
+                    buttonY <= Gdx.graphics.getHeight() - y && Gdx.graphics.getHeight() - y <= buttonY + buttonHeight) {
+                gsm.push(new GameMenuState());
+            }
+        }
+
+    }
+
     private void setupInputProcessor() {
         multiplexer.addProcessor(new InputAdapter() {
             @Override
diff --git a/core/src/com/mygdx/game/states/GameMenuState.java b/core/src/com/mygdx/game/states/GameMenuState.java
index db97537..4c0a03e 100644
--- a/core/src/com/mygdx/game/states/GameMenuState.java
+++ b/core/src/com/mygdx/game/states/GameMenuState.java
@@ -31,7 +31,7 @@ public class GameMenuState extends State {
         sb = new SpriteBatch();
         width = Gdx.graphics.getWidth();
         height = Gdx.graphics.getHeight();
-        startButton = new Texture("Start-button.png");
+        startButton = new Texture("playButton.png");
         lobbyButton = new Texture("Lobby-button.png");
         menuButton = new Texture("Menu-button.png");
         logo = new Texture("HvsMstor.png");
@@ -69,12 +69,14 @@ public class GameMenuState extends State {
 
         // Calculate the button positions and sizes
         float buttonWidth = width / 7f;
-        float startButtonHeight = buttonWidth * ((float) startButton.getHeight() / startButton.getWidth());
+        float playButtonWidth = width / 5f;
+        float startButtonHeight = playButtonWidth * ((float) startButton.getHeight() / startButton.getWidth());
         float lobbyButtonHeight = buttonWidth * ((float) lobbyButton.getHeight() / lobbyButton.getWidth());
         float menuButtonHeight = buttonWidth * ((float) menuButton.getHeight() / menuButton.getWidth());
 
 
         float buttonX = (width - buttonWidth) / 2f;
+        float playButtonX = (width - playButtonWidth) /2f;
         float startButtonY = height * 0.3f - startButtonHeight / 2f;
         float lobbyButtonY = height * 0.12f - lobbyButtonHeight / 2f;
         float menuButtonY = height * 0.21f - menuButtonHeight / 2f;
@@ -85,7 +87,7 @@ public class GameMenuState extends State {
         batch.draw(menuBackground, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
 
         batch.draw(logo, logoX, logoY, logoWidth, logoHeight);
-        batch.draw(startButton, buttonX, startButtonY, buttonWidth, startButtonHeight);
+        batch.draw(startButton, playButtonX, startButtonY, playButtonWidth, startButtonHeight);
         batch.draw(lobbyButton, buttonX, lobbyButtonY, buttonWidth, lobbyButtonHeight);
         batch.draw(menuButton, buttonX, menuButtonY, buttonWidth, menuButtonHeight);
 
@@ -98,7 +100,7 @@ public class GameMenuState extends State {
     }
 
     private boolean isStartButtonClicked(int x, int y) {
-        float buttonWidth = width / 7f;
+        float buttonWidth = width / 5f;
         float startButtonHeight = buttonWidth * ((float) startButton.getHeight() / startButton.getWidth());
         float buttonX = (width - buttonWidth) / 2f;
         float startButtonY = height * 0.3f - startButtonHeight / 2f;
-- 
GitLab


From 0ca357d8baea387bf5e821e7a9e2bb176d5e6fbf Mon Sep 17 00:00:00 2001
From: Anh <qapham@stud.ntnu.no>
Date: Fri, 21 Apr 2023 16:42:09 +0200
Subject: [PATCH 05/23] Add 8 bit coin

---
 assets/coin2.png                              | Bin 0 -> 3031 bytes
 core/src/com/mygdx/game/Board.java            |   3 ++-
 core/src/com/mygdx/game/states/PlayState.java |   4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)
 create mode 100644 assets/coin2.png

diff --git a/assets/coin2.png b/assets/coin2.png
new file mode 100644
index 0000000000000000000000000000000000000000..261107351c3fa03167a58d8fd13c472e8aeebbff
GIT binary patch
literal 3031
zcmd5;Yfuwc7-hFRNK}+0Drlr=AjHZ;ut*UC%9|JrZ4r!sBwAWPXbDiBMF~_$QG^P`
zP>mpUD&r7jMaA%5ibB&^h?as?Ov1|tDUU?nDE3lpXZoY#I8(JhcJJPAzw_;Wch0%@
zWWCSy)Lp!0v6hyWF5S!RLokklt4Bv0+$R)vA}~O)A9}iIU1(eTNK0$Uak`uHuEgM>
zdyYAV?gkk>Z(DnKkhi-X?$=vi<>Ka&uHOW+5Ihba=<H@nHF0UneqwAKYCshFhT0WJ
z3{vJ!4$kgs^sO40sIQ)?AaiGxmv$Fq$d9`R)1D38H>@uB;vi|Api01F$oLkn*!Q|r
zC1GrzRF50pj1waVZ*N9|?r>pCXQQg6kib^>O4HWrkM8pFG1|6u@aBy2aju8cNO*-c
zf&0kXSh>swN)WdC_aMWvSU5qrHO-+-pUPcyk|^$@RV}7+`9<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e6~D>qe#
z5m7Bre1SIsE%C(cR{>c|OdwJ+BKipb{|M8umd#Pe8fM1Z2c&GL<f@dR9K2=f?VX#v
z;fCqnzT-ai1FFMWD<Ep}<ZJ+JJ0T#lT6Z*{40Z+`wk-mi)<v+`J4|u6WyT!CqrAAX
zkUXBQ<7*CU#5|(t?xN!Qfcm-1Q@c+GvlH$_WS6>6^-f2<SJvLD$*9mbQToM?*u$Om
z@hPPO-uTn{b8?F9XX^6jeCb7A4|iV7%d(3+cFHtAS`d{ZpVLS*S0qREx+b?-RMhs>
zUUO(5i0hoY;wTEM#O}LZh>&*RbOer-0FH@4&;ptc+EKq^`oFk^zlGQWcSfm)B!-O!
z7D-DsCY>QZI3H0em+o{L=`c%^IC?6Wh34K^mb^CA0!o<pil-aOd~+=N7vjd4EBnvo
zzxQpC)1k_`&o%Wsq(@^)C}^KqTIZrCT~_mIp5NOEqk46h%&F+vxK48@3RNI=O{Ti{
z$k6g82PxrAL=}&pGJAc(z+Polol+Z-|8?H-Qz?F-mBSrZ0vnix96a~CQZ@st@!L$t
zvWlWDsA$^C>=<}aqC?P6xbEL5&#lsQFEYG+-c0?|g8lcl3V1SL<AP#<jdL!py3rxo
zHjonF<=Y01Jzp6@qog)=QIxml2wdC@`mv7qat{)e?i9Hiw*1r%5}a8cn8{<1m>A_@
j^NID!TbaaHkT$11q8%Q^P~mccQ`e%qGu<w@aMJ$(?PfmP

literal 0
HcmV?d00001

diff --git a/core/src/com/mygdx/game/Board.java b/core/src/com/mygdx/game/Board.java
index 9a39cfe..9f48457 100644
--- a/core/src/com/mygdx/game/Board.java
+++ b/core/src/com/mygdx/game/Board.java
@@ -128,7 +128,7 @@ public class Board extends Actor {
         BitmapFont font = new BitmapFont();
         font.getData().setScale(3.5f);
         font.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
-        Texture counterIcon = new Texture("coin.png");
+        Texture counterIcon = new Texture("coin2.png");
 
         this.batch.begin();
         font.draw(batch, String.valueOf(moneySystem.getMoney()), iconX + iconSize * 1.5f, iconY + iconSize * 0.75f);
@@ -491,6 +491,7 @@ public class Board extends Actor {
         for (Texture buttonTexture : buttonTextures) {
             buttonTexture.dispose();
         }
+        batch.dispose();
 
     }
 }
diff --git a/core/src/com/mygdx/game/states/PlayState.java b/core/src/com/mygdx/game/states/PlayState.java
index 453de02..2737908 100644
--- a/core/src/com/mygdx/game/states/PlayState.java
+++ b/core/src/com/mygdx/game/states/PlayState.java
@@ -110,7 +110,7 @@ public class PlayState extends State{
         counterText1.setHeight(iconSize / 2);
         board.getRightTable().add(counterText1);
 
-        Texture counterIconTexture1 = new Texture("coin.png");
+        Texture counterIconTexture1 = new Texture("coin2.png");
         Image counterIcon1 = new Image(counterIconTexture1);
         board.getRightTable().add(counterIcon1).size(iconSize, iconSize).pad(5);
         board.getRightTable().row();
@@ -122,7 +122,7 @@ public class PlayState extends State{
         counterText2.setHeight(iconSize / 2);
         board.getRightTable().add(counterText2);
 
-        Texture counterIconTexture2 = new Texture("coin.png");
+        Texture counterIconTexture2 = new Texture("coin2.png");
         Image counterIcon2 = new Image(counterIconTexture2);
         board.getRightTable().add(counterIcon2).size(iconSize, iconSize).pad(5);
         board.getRightTable().row();
-- 
GitLab


From a37bdff9469923d24cab34e09c45e90f7954cf8c Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Fri, 21 Apr 2023 16:59:32 +0200
Subject: [PATCH 06/23] #54 display heroes and projectiles on screen

---
 core/src/com/mygdx/game/Board.java            | 15 ++++++++----
 .../game/entities/ProjectileFactory.java      | 22 ++++++++----------
 core/src/com/mygdx/game/states/PlayState.java | 23 ++++++++++++-------
 .../com/mygdx/game/systems/HeroSystem.java    |  4 ++--
 .../systems/ProjectileMovementSystem.java     |  2 +-
 5 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/core/src/com/mygdx/game/Board.java b/core/src/com/mygdx/game/Board.java
index 96983a8..376a73f 100644
--- a/core/src/com/mygdx/game/Board.java
+++ b/core/src/com/mygdx/game/Board.java
@@ -48,9 +48,9 @@ public class Board extends Actor {
     private int cellHeight;
     private SpriteBatch batch;
 
-    private int xOffset = 315; // Add xOffset for moving textures right
+    private int xOffset = Gdx.graphics.getWidth()/8; // Add xOffset for moving textures right
     private int yOffset = 0;  // Add yOffset for moving textures up or down
-    private int dashOffset = 315; // Add dashOffset for moving dashed lines right
+    private int dashOffset = Gdx.graphics.getWidth()/8; // Add dashOffset for moving dashed lines right
 
     private Texture[] buttonTextures;
     private Texture[] displayTextures;
@@ -186,8 +186,8 @@ public class Board extends Actor {
         // Add your logic here for when a cell is clicked
         System.out.println("Cell clicked: row " + row + ", col " + col);
         int displayPanelWidth = Gdx.graphics.getWidth() / 8;
-        int middleOfCellX = (int) (((col + 0.5) * cellWidth)) + displayPanelWidth ;
-        int middleOfCellY = (int) ((row + 0.5) * cellHeight);
+        int middleOfCellX = (int) (((col) * cellWidth)) + displayPanelWidth ;
+        int middleOfCellY = (int) ((row) * cellHeight);
 
         System.out.print(" x: " + middleOfCellX + " y: " + middleOfCellY);
         Vector2 heroPlacement = new Vector2(middleOfCellX, middleOfCellY);
@@ -355,6 +355,13 @@ public class Board extends Actor {
         }
     }
 
+    public int getTextureWidth() {
+        return textureWidth;
+    }
+
+    public int getTextureHeight() {
+        return textureHeight;
+    }
 
     public void drawLaneDividers() {
         int dashLength = 10;
diff --git a/core/src/com/mygdx/game/entities/ProjectileFactory.java b/core/src/com/mygdx/game/entities/ProjectileFactory.java
index d0c32e3..981bc94 100644
--- a/core/src/com/mygdx/game/entities/ProjectileFactory.java
+++ b/core/src/com/mygdx/game/entities/ProjectileFactory.java
@@ -28,15 +28,15 @@ public class ProjectileFactory {
         Texture texture = null;
         switch (heroType) {
             case IRONMAN:
-                return new Texture(Gdx.files.internal("characterIcon3.png"));
+                return new Texture(Gdx.files.internal("ironManShoots.png"));
             case HULK:
-                return new Texture(Gdx.files.internal("characterIcon3.png"));
+                return new Texture(Gdx.files.internal("rock.png"));
             case SPIDERMAN:
-                return new Texture(Gdx.files.internal("characterIcon3.png"));
+                return new Texture(Gdx.files.internal("web.png"));
             case THOR:
-                return new Texture(Gdx.files.internal("characterIcon3.png"));
+                return new Texture(Gdx.files.internal("lightning.png"));
             case CAPTAIN_AMERICA:
-                return new Texture(Gdx.files.internal("characterIcon3.png"));
+                return new Texture(Gdx.files.internal("shield.png"));
             default:
                 return null;
         }
@@ -45,19 +45,17 @@ public class ProjectileFactory {
     private static float getProjectileSpeed(HeroType heroType) {
         switch (heroType) {
             case IRONMAN:
-                return 5f;
+                return 30f;
             case HULK:
-                return 2f;
+                return 15f;
             case SPIDERMAN:
-                return 4f;
+                return 40f;
             case THOR:
-                return 3f;
+                return 20;
             case CAPTAIN_AMERICA:
-                return 8f;
+                return 25f;
             default:
                 return 7f;
         }
     }
-
-
 }
diff --git a/core/src/com/mygdx/game/states/PlayState.java b/core/src/com/mygdx/game/states/PlayState.java
index 31c8767..d989288 100644
--- a/core/src/com/mygdx/game/states/PlayState.java
+++ b/core/src/com/mygdx/game/states/PlayState.java
@@ -27,6 +27,7 @@ import com.mygdx.game.SoundManager;
 import com.mygdx.game.components.AttackComponent;
 import com.mygdx.game.components.HeroComponent;
 import com.mygdx.game.components.PositionComponent;
+import com.mygdx.game.components.ProjectileComponent;
 import com.mygdx.game.components.SpriteComponent;
 import com.mygdx.game.entities.DisplayHero;
 import com.mygdx.game.entities.HeroFactory;
@@ -49,9 +50,6 @@ public class PlayState extends State{
     private static Engine engine;
     private Board board;
     private TextButton counterText1;
-    private List<Image> heroImages = new ArrayList<>();
-    private List<Image> heroProjectiles = new ArrayList<>();
-    private List<Image> monsterImages = new ArrayList<>();
 
     public PlayState() {
         //super(gsm);
@@ -132,15 +130,21 @@ public class PlayState extends State{
         board.getRightTable().row();
     }
 
-    public void renderHeroes() {
+    public void renderHeroes(SpriteBatch batch) {
         for (Entity e : engine.getEntitiesFor(Family.all(HeroComponent.class, AttackComponent.class).get())) {
             Texture sprite = e.getComponent(SpriteComponent.class).getSprite();
             Vector2 position = e.getComponent(PositionComponent.class).getPosition();
 
-            Image heroImage = new Image(sprite);
-            batch.begin();
-            batch.draw(heroImage, e);
-            heroImages.add(heroImage);
+            batch.draw(sprite, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
+        }
+    }
+
+    public void renderProjectiles(SpriteBatch batch) {
+        for (Entity e : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
+            Texture sprite = e.getComponent(SpriteComponent.class).getSprite();
+            Vector2 position = e.getComponent(PositionComponent.class).getPosition();
+
+            batch.draw(sprite, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
         }
     }
 
@@ -153,8 +157,11 @@ public class PlayState extends State{
 
         batch.begin();
         board.render(batch);
+        renderHeroes(batch);
+        renderProjectiles(batch);
         batch.end();
 
+
         stage.act(Gdx.graphics.getDeltaTime());
         stage.draw();
     }
diff --git a/core/src/com/mygdx/game/systems/HeroSystem.java b/core/src/com/mygdx/game/systems/HeroSystem.java
index e1bf98f..3970489 100644
--- a/core/src/com/mygdx/game/systems/HeroSystem.java
+++ b/core/src/com/mygdx/game/systems/HeroSystem.java
@@ -50,7 +50,7 @@ public class HeroSystem extends IteratingSystem {
         boolean projectileExists = false;
         for (Entity e : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
             if (e.getComponent(ProjectileComponent.class).getSourceEntity() == entity) {
-                System.out.println(e.getComponent(PositionComponent.class).getPosition());
+                //System.out.println(e.getComponent(PositionComponent.class).getPosition());
                 projectileExists = true;
                 break;
             }
@@ -71,7 +71,7 @@ public class HeroSystem extends IteratingSystem {
 
         for (Entity e : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
             if (e.getComponent(ProjectileComponent.class).getSourceEntity() == entity) {
-                System.out.println(e.getComponent(PositionComponent.class).getPosition());
+                //System.out.println(e.getComponent(PositionComponent.class).getPosition());
             }
         }
     }
diff --git a/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java b/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
index 72116a9..ea6c298 100644
--- a/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
+++ b/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
@@ -34,7 +34,7 @@ public class ProjectileMovementSystem extends IteratingSystem {
         PositionComponent positionComponent = positionMapper.get(entity);
 
         //If a projectile is out of bounds, remove it from the engine
-        if (positionComponent.getPosition().x > Gdx.graphics.getWidth()) {
+        if (positionComponent.getPosition().x > Gdx.graphics.getWidth() - Gdx.graphics.getWidth()/8f) {
             engine.removeEntity(entity);
             System.out.println("Projectile out of bounds. Removed projectile.");
         }
-- 
GitLab


From c0bf578ed3c596427a3d8afcbd76967179421b93 Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Fri, 21 Apr 2023 17:33:55 +0200
Subject: [PATCH 07/23] componentmapper

---
 core/src/com/mygdx/game/systems/HeroSystem.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/core/src/com/mygdx/game/systems/HeroSystem.java b/core/src/com/mygdx/game/systems/HeroSystem.java
index 3970489..e389c8b 100644
--- a/core/src/com/mygdx/game/systems/HeroSystem.java
+++ b/core/src/com/mygdx/game/systems/HeroSystem.java
@@ -21,6 +21,7 @@ public class HeroSystem extends IteratingSystem {
     private ComponentMapper<PositionComponent> positionMapper;
     private ComponentMapper<SpriteComponent> spriteMapper;
     private ComponentMapper<HeroComponent> heroTypeMapper;
+    private ComponentMapper<ProjectileComponent> projectileMapper;
     private Engine engine;
 
     //This system is only responsible for handling the creation of projectiles for all the heroes
@@ -32,6 +33,7 @@ public class HeroSystem extends IteratingSystem {
         positionMapper = ComponentMapper.getFor(PositionComponent.class);
         spriteMapper = ComponentMapper.getFor(SpriteComponent.class);
         heroTypeMapper = ComponentMapper.getFor(HeroComponent.class);
+        projectileMapper = ComponentMapper.getFor(ProjectileComponent.class);
         this.engine = engine;
     }
 
@@ -48,8 +50,9 @@ public class HeroSystem extends IteratingSystem {
 
         //Check if a hero has an active projectile
         boolean projectileExists = false;
-        for (Entity e : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
-            if (e.getComponent(ProjectileComponent.class).getSourceEntity() == entity) {
+        for (Entity projectile : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
+            ProjectileComponent projectileComponent = projectileMapper.get(projectile);
+            if (projectileComponent.getSourceEntity() == entity) {
                 //System.out.println(e.getComponent(PositionComponent.class).getPosition());
                 projectileExists = true;
                 break;
-- 
GitLab


From d662f6be6d8183f5dede827d54d81c1768dbcc3a Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Fri, 21 Apr 2023 18:09:30 +0200
Subject: [PATCH 08/23] check if hero exists in cell

---
 core/src/com/mygdx/game/Board.java | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/core/src/com/mygdx/game/Board.java b/core/src/com/mygdx/game/Board.java
index 376a73f..59f660b 100644
--- a/core/src/com/mygdx/game/Board.java
+++ b/core/src/com/mygdx/game/Board.java
@@ -1,5 +1,6 @@
 package com.mygdx.game;
 
+import com.badlogic.ashley.core.ComponentMapper;
 import com.badlogic.ashley.core.Engine;
 import com.badlogic.ashley.core.Entity;
 import com.badlogic.ashley.core.Family;
@@ -25,7 +26,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
 import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
 import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
 import com.badlogic.gdx.utils.Array;
+import com.mygdx.game.components.AttackComponent;
 import com.mygdx.game.components.HeroComponent;
+import com.mygdx.game.components.PositionComponent;
 import com.mygdx.game.entities.DisplayHero;
 import com.mygdx.game.entities.HeroFactory;
 import com.mygdx.game.types.HeroType;
@@ -311,9 +314,26 @@ public class Board extends Actor {
 
     private void placeHero(Vector2 placementPosition) {
         if (chosenHeroType != null) {
-            Entity hero = HeroFactory.createHero(getChosenHeroType(), placementPosition);
-            engine.addEntity(hero);
-            System.out.println("Created new hero entity and added to game engine");
+            //Check if hero is already placed in the cell
+            boolean cellHasHero = false;
+            float epsilon = 0.0001f;
+            ComponentMapper<PositionComponent> positionMapper;
+            positionMapper = ComponentMapper.getFor(PositionComponent.class);
+            for (Entity e : engine.getEntitiesFor(Family.all(HeroComponent.class, AttackComponent.class).get())) {
+                PositionComponent position = positionMapper.get(e);
+                Vector2 heroPos = position.getPosition();
+                if (heroPos.epsilonEquals(placementPosition, epsilon)) {
+                    System.out.println("There is already a hero in this cell");
+                    cellHasHero = true;
+                    break;
+                }
+            }
+            //Place a new hero entity at the given position if the cell is empty
+            if (!cellHasHero) {
+                Entity hero = HeroFactory.createHero(getChosenHeroType(), placementPosition);
+                engine.addEntity(hero);
+                System.out.println("Created new hero entity and added to game engine");
+            }
         }
     }
 
-- 
GitLab


From 67c0e32ffbcbfda5bb799401f03f995c0b55c080 Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Fri, 21 Apr 2023 18:39:18 +0200
Subject: [PATCH 09/23] heroes attack based on timer

---
 .../mygdx/game/components/HeroComponent.java  | 11 +++++++
 .../com/mygdx/game/entities/HeroFactory.java  | 19 ++++++++++--
 .../com/mygdx/game/systems/HeroSystem.java    | 31 +++++++++----------
 .../systems/ProjectileMovementSystem.java     |  1 -
 4 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/core/src/com/mygdx/game/components/HeroComponent.java b/core/src/com/mygdx/game/components/HeroComponent.java
index ab4fa24..7642550 100644
--- a/core/src/com/mygdx/game/components/HeroComponent.java
+++ b/core/src/com/mygdx/game/components/HeroComponent.java
@@ -5,9 +5,20 @@ import com.mygdx.game.types.HeroType;
 
 public class HeroComponent implements Component {
     private HeroType heroType;
+    private boolean projectileActive;
+
+    public boolean isProjectileActive() {
+        return projectileActive;
+    }
+
+    public void setProjectileActive(boolean projectileActive) {
+        this.projectileActive = projectileActive;
+    }
+
 
     public HeroComponent(HeroType heroType) {
         this.heroType = heroType;
+        this.projectileActive = false;
     }
 
     public HeroType getHeroType() {
diff --git a/core/src/com/mygdx/game/entities/HeroFactory.java b/core/src/com/mygdx/game/entities/HeroFactory.java
index 0c34988..8bc6f01 100644
--- a/core/src/com/mygdx/game/entities/HeroFactory.java
+++ b/core/src/com/mygdx/game/entities/HeroFactory.java
@@ -18,7 +18,7 @@ public class HeroFactory {
         Entity hero = new Entity();
         hero.add(new SpriteComponent(getHeroSprite(heroType)));
         hero.add(new PositionComponent(boardPosition));
-        hero.add(new AttackComponent(getHeroAttackDamage(heroType), getHeroAttackTimer(), getHeroAttackTimeElapsed()));
+        hero.add(new AttackComponent(getHeroAttackDamage(heroType), getHeroAttackTimer(heroType), getHeroAttackTimeElapsed()));
         hero.add(new HealthComponent(getHeroHealth()));
         hero.add(new HeroComponent(heroType));
         return hero;
@@ -111,8 +111,21 @@ public class HeroFactory {
         }
     }
 
-    private static float getHeroAttackTimer() {
-        return 10.0f;
+    private static float getHeroAttackTimer(HeroType heroType) {
+        switch (heroType) {
+            case IRONMAN:
+                return 6f;
+            case HULK:
+                return 8f;
+            case SPIDERMAN:
+                return 5.5f;
+            case THOR:
+                return 6.5f;
+            case CAPTAIN_AMERICA:
+                return 7f;
+            default:
+                return 0;
+        }
     }
 
     private static float getHeroAttackTimeElapsed() {
diff --git a/core/src/com/mygdx/game/systems/HeroSystem.java b/core/src/com/mygdx/game/systems/HeroSystem.java
index e389c8b..f3633bd 100644
--- a/core/src/com/mygdx/game/systems/HeroSystem.java
+++ b/core/src/com/mygdx/game/systems/HeroSystem.java
@@ -45,11 +45,20 @@ public class HeroSystem extends IteratingSystem {
         SpriteComponent sprite = spriteMapper.get(entity);
         HeroComponent heroComponent = heroTypeMapper.get(entity);
 
-        //Increase the time elapsed field in the attack component on every update
-        attack.setAttackTimeElapsed(attack.getAttackTimeElapsed() + deltaTime);
+        //If the time elapsed is greater than the given interval, create a new projectile
+        if (attack.getAttackTimeElapsed() >= attack.getAttackInterval() || !heroComponent.isProjectileActive()) {
+            attack.setAttackTimeElapsed(0);
+            float posX = position.getPosition().x;
+            float posY = position.getPosition().y;
+            Entity projectile = ProjectileFactory.createProjectile(heroComponent.getHeroType(), new Vector2(posX, posY), entity);
+            engine.addEntity(projectile);
+            heroComponent.setProjectileActive(true);
+        }
 
+        //Increase the time elapsed field in the attack component on every update
+        attack.setAttackTimeElapsed(attack.getAttackTimeElapsed() + deltaTime*10);
         //Check if a hero has an active projectile
-        boolean projectileExists = false;
+        /*boolean projectileExists = false;
         for (Entity projectile : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
             ProjectileComponent projectileComponent = projectileMapper.get(projectile);
             if (projectileComponent.getSourceEntity() == entity) {
@@ -57,25 +66,15 @@ public class HeroSystem extends IteratingSystem {
                 projectileExists = true;
                 break;
             }
-        }
+        }*/
 
         //If a hero does not have an active projectile, it is created and added to the engine
-        if (!projectileExists) {
+        /*if (!projectileExists) {
             float posX = position.getPosition().x;
             float posY = position.getPosition().y;
             Entity projectile = ProjectileFactory.createProjectile(heroComponent.getHeroType(), new Vector2(posX, posY), entity);
             engine.addEntity(projectile);
-        }
+        }*/
 
-        //If the time elapsed is greater than the given interval, create a new projectile
-        if (attack.getAttackTimeElapsed() > attack.getAttackInterval()) {
-            attack.setAttackTimeElapsed(0);
-        }
-
-        for (Entity e : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
-            if (e.getComponent(ProjectileComponent.class).getSourceEntity() == entity) {
-                //System.out.println(e.getComponent(PositionComponent.class).getPosition());
-            }
-        }
     }
 }
\ No newline at end of file
diff --git a/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java b/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
index ea6c298..643a4e3 100644
--- a/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
+++ b/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
@@ -36,7 +36,6 @@ public class ProjectileMovementSystem extends IteratingSystem {
         //If a projectile is out of bounds, remove it from the engine
         if (positionComponent.getPosition().x > Gdx.graphics.getWidth() - Gdx.graphics.getWidth()/8f) {
             engine.removeEntity(entity);
-            System.out.println("Projectile out of bounds. Removed projectile.");
         }
 
         //Increment the horizontal position of the projectile based on its velocity
-- 
GitLab


From 400758e219da9e44fe6445ab3fea9e33af064a1b Mon Sep 17 00:00:00 2001
From: Johannes Finne Reinseth <johannes.reinseth@aboveit.no>
Date: Sat, 22 Apr 2023 11:02:47 +0200
Subject: [PATCH 10/23] fix: merge with dev

---
 core/src/com/mygdx/game/{ => ds}/Board.java   | 74 ++++---------------
 .../mygdx/game/ds/buttons/CircleButton.java   | 35 +++++++--
 core/src/com/mygdx/game/states/PlayState.java | 46 +-----------
 .../src/com/mygdx/game/states/StartState.java |  2 +-
 4 files changed, 47 insertions(+), 110 deletions(-)
 rename core/src/com/mygdx/game/{ => ds}/Board.java (85%)

diff --git a/core/src/com/mygdx/game/Board.java b/core/src/com/mygdx/game/ds/Board.java
similarity index 85%
rename from core/src/com/mygdx/game/Board.java
rename to core/src/com/mygdx/game/ds/Board.java
index ee1b043..1939911 100644
--- a/core/src/com/mygdx/game/Board.java
+++ b/core/src/com/mygdx/game/ds/Board.java
@@ -1,6 +1,5 @@
-package com.mygdx.game;
+package com.mygdx.game.ds;
 
-import com.badlogic.ashley.core.ComponentMapper;
 import com.badlogic.ashley.core.Engine;
 import com.badlogic.ashley.core.Entity;
 import com.badlogic.ashley.core.Family;
@@ -28,14 +27,10 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
 import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
 import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
 import com.badlogic.gdx.utils.Array;
-import com.mygdx.game.components.AttackComponent;
+import com.mygdx.game.MoneySystem;
 import com.mygdx.game.components.HeroComponent;
-import com.mygdx.game.components.PositionComponent;
 import com.mygdx.game.entities.DisplayHero;
 import com.mygdx.game.entities.HeroFactory;
-import com.mygdx.game.states.GameMenuState;
-import com.mygdx.game.states.GameStateManager;
-import com.mygdx.game.states.PlayState;
 import com.mygdx.game.types.HeroType;
 import com.mygdx.game.utils.DisplayHeroButton;
 
@@ -54,12 +49,11 @@ public class Board extends Actor {
     private int textureHeight;
     private int cellWidth;
     private int cellHeight;
-    private GameStateManager gsm;
     private SpriteBatch batch;
 
-    private int xOffset = Gdx.graphics.getWidth()/8; // Add xOffset for moving textures right
     private int yOffset = 0;  // Add yOffset for moving textures up or down
-    private int dashOffset = Gdx.graphics.getWidth()/8; // Add dashOffset for moving dashed lines right
+    private int xOffset = 225; // Add xOffset for moving textures right (previously 315)
+    private int dashOffset = 225; // Add dashOffset for moving dashed lines right (previously 315)
 
     private Texture[] buttonTextures;
     private Texture[] displayTextures;
@@ -91,7 +85,6 @@ public class Board extends Actor {
 
 
     public Board(int rows, int cols, Engine engine) {
-        gsm = GameStateManager.getGsm();
         this.engine = engine;
         this.rows = rows;
         this.cols = cols;
@@ -131,7 +124,7 @@ public class Board extends Actor {
         BitmapFont font = new BitmapFont();
         font.getData().setScale(3.5f);
         font.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
-        Texture counterIcon = new Texture("coin2.png");
+        Texture counterIcon = new Texture("coin.png");
 
         this.batch.begin();
         font.draw(batch, String.valueOf(moneySystem.getMoney()), iconX + iconSize * 1.5f, iconY + iconSize * 0.75f);
@@ -185,7 +178,6 @@ public class Board extends Actor {
         //drawDisplayPanel(batch);
 
         this.batch.begin();
-        drawBackButton();
         drawHeroes();
         this.batch.end();
 
@@ -196,25 +188,6 @@ public class Board extends Actor {
 
 
 
-    }
-
-    private void drawBackButton() {
-        Texture backButton = new Texture("backButton.png");
-        float buttonWidth = screenWidth / 10;
-        float buttonHeight = buttonWidth * ((float) backButton.getHeight() / backButton.getWidth());
-        float buttonX = 10;
-        float buttonY = 10;
-        batch.draw(backButton, buttonX, buttonY, buttonWidth, buttonHeight);
-
-        if (Gdx.input.isTouched()) {
-            int x = Gdx.input.getX();
-            int y = Gdx.input.getY();
-            if (Gdx.input.justTouched() && buttonX <= x && x <= buttonX + buttonWidth &&
-                    buttonY <= Gdx.graphics.getHeight() - y && Gdx.graphics.getHeight() - y <= buttonY + buttonHeight) {
-                gsm.push(new GameMenuState());
-            }
-        }
-
     }
 
     private void setupInputProcessor() {
@@ -239,8 +212,8 @@ public class Board extends Actor {
         // Add your logic here for when a cell is clicked
         System.out.println("Cell clicked: row " + row + ", col " + col);
         int displayPanelWidth = Gdx.graphics.getWidth() / 8;
-        int middleOfCellX = (int) (((col) * cellWidth)) + displayPanelWidth ;
-        int middleOfCellY = (int) ((row) * cellHeight);
+        int middleOfCellX = (int) (((col + 0.5) * cellWidth)) + displayPanelWidth ;
+        int middleOfCellY = (int) ((row + 0.5) * cellHeight);
 
         System.out.print(" x: " + middleOfCellX + " y: " + middleOfCellY);
         Vector2 heroPlacement = new Vector2(middleOfCellX, middleOfCellY);
@@ -387,25 +360,12 @@ public class Board extends Actor {
 
     private void placeHero(Vector2 placementPosition) {
         if (chosenHeroType != null) {
-            //Check if hero is already placed in the cell
-            boolean cellHasHero = false;
-            float epsilon = 0.0001f;
-            ComponentMapper<PositionComponent> positionMapper;
-            positionMapper = ComponentMapper.getFor(PositionComponent.class);
-            for (Entity e : engine.getEntitiesFor(Family.all(HeroComponent.class, AttackComponent.class).get())) {
-                PositionComponent position = positionMapper.get(e);
-                Vector2 heroPos = position.getPosition();
-                if (heroPos.epsilonEquals(placementPosition, epsilon)) {
-                    System.out.println("There is already a hero in this cell");
-                    cellHasHero = true;
-                    break;
-                }
-            }
-            //Place a new hero entity at the given position if the cell is empty
-            if (!cellHasHero) {
-                Entity hero = HeroFactory.createHero(getChosenHeroType(), placementPosition);
-                engine.addEntity(hero);
-                System.out.println("Created new hero entity and added to game engine");
+            Entity hero = HeroFactory.createHero(getChosenHeroType(), placementPosition);
+            engine.addEntity(hero);
+            System.out.println("Created new hero entity and added to game engine");
+            System.out.println("all heroes: :)");
+            for (Entity e : engine.getEntitiesFor(Family.all(HeroComponent.class).get())) {
+                System.out.println(e.getComponent(HeroComponent.class).getHeroType());
             }
         }
     }
@@ -451,13 +411,6 @@ public class Board extends Actor {
         }
     }
 
-    public int getTextureWidth() {
-        return textureWidth;
-    }
-
-    public int getTextureHeight() {
-        return textureHeight;
-    }
 
     public void drawLaneDividers() {
         int dashLength = 10;
@@ -514,7 +467,6 @@ public class Board extends Actor {
         for (Texture buttonTexture : buttonTextures) {
             buttonTexture.dispose();
         }
-        batch.dispose();
 
     }
 }
diff --git a/core/src/com/mygdx/game/ds/buttons/CircleButton.java b/core/src/com/mygdx/game/ds/buttons/CircleButton.java
index edb8196..d713d3f 100644
--- a/core/src/com/mygdx/game/ds/buttons/CircleButton.java
+++ b/core/src/com/mygdx/game/ds/buttons/CircleButton.java
@@ -1,5 +1,6 @@
 package com.mygdx.game.ds.buttons;
 
+import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
 import com.badlogic.gdx.math.Circle;
@@ -7,11 +8,35 @@ import com.badlogic.gdx.math.Vector2;
 
 public class CircleButton {
 
-    private Vector2 position;
-    private Circle bounds;
-    private ShapeRenderer shape;
-    private int radius;
-    private Texture img;
+    private final Vector2 position;
+    private final Circle bounds;
+    private final ShapeRenderer shape;
+    private final int radius;
+    private final Texture img;
+
+    public CircleButton(float scale, String internalpath) {
+        this.img = new Texture(internalpath);
+        this.radius = (int) ((this.img.getWidth() / 2) / scale);
+        this.position = new Vector2(Gdx.graphics.getWidth() / 2f - this.img.getWidth() / 2f, Gdx.graphics.getHeight() / 2f - this.img.getHeight() / 2f);
+        this.bounds = new Circle(this.position.x, this.position.y, this.radius);
+        this.shape = new ShapeRenderer();
+    }
+
+    public CircleButton(float scale, boolean middle, int ystart, String internalpath) {
+        this.img = new Texture(internalpath);
+        this.radius = (int) ((this.img.getWidth() / 2) / scale);
+        this.position = new Vector2(Gdx.graphics.getWidth() / 2f - this.img.getWidth() / 2f, ystart);
+        this.bounds = new Circle(this.position.x, this.position.y, this.radius);
+        this.shape = new ShapeRenderer();
+    }
+
+    public CircleButton(float scale, int xStart, boolean middle, String internalpath) {
+        this.img = new Texture(internalpath);
+        this.radius = (int) ((this.img.getWidth() / 2) / scale);
+        this.position = new Vector2(xStart, Gdx.graphics.getHeight() / 2f - this.img.getHeight() / 2f);
+        this.bounds = new Circle(this.position.x, this.position.y, this.radius);
+        this.shape = new ShapeRenderer();
+    }
 
     public CircleButton(int radius, int xStart, int yStart, String internalPath) {
         this.radius = radius;
diff --git a/core/src/com/mygdx/game/states/PlayState.java b/core/src/com/mygdx/game/states/PlayState.java
index 75d030f..d2769cf 100644
--- a/core/src/com/mygdx/game/states/PlayState.java
+++ b/core/src/com/mygdx/game/states/PlayState.java
@@ -1,45 +1,26 @@
 package com.mygdx.game.states;
 
-import com.badlogic.ashley.core.ComponentMapper;
 import com.badlogic.ashley.core.Engine;
-import com.badlogic.ashley.core.Entity;
-import com.badlogic.ashley.core.Family;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 
 import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.GL20;
-import com.badlogic.gdx.graphics.Pixmap;
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.graphics.g2d.BitmapFont;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
-import com.badlogic.gdx.math.Vector2;
-import com.badlogic.gdx.scenes.scene2d.InputEvent;
 import com.badlogic.gdx.scenes.scene2d.Stage;
 
 import com.badlogic.gdx.scenes.scene2d.ui.Image;
-import com.badlogic.gdx.scenes.scene2d.ui.Table;
 import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
 import com.badlogic.gdx.utils.viewport.ScreenViewport;
-import com.mygdx.game.Board;
+import com.mygdx.game.ds.Board;
 import com.mygdx.game.MoneySystem;
 import com.mygdx.game.SoundManager;
-import com.mygdx.game.components.AttackComponent;
-import com.mygdx.game.components.HeroComponent;
-import com.mygdx.game.components.PositionComponent;
-import com.mygdx.game.components.ProjectileComponent;
-import com.mygdx.game.components.SpriteComponent;
-import com.mygdx.game.entities.DisplayHero;
-import com.mygdx.game.entities.HeroFactory;
 import com.mygdx.game.ds.buttons.RectangleButton;
 import com.mygdx.game.systems.HeroSystem;
 import com.mygdx.game.systems.ProjectileMovementSystem;
-import com.mygdx.game.types.HeroType;
 import com.mygdx.game.utils.Enums;
 
-import java.util.ArrayList;
-import java.util.List;
-
 public class PlayState extends State{
     private SpriteBatch batch;
     private BitmapFont font;
@@ -117,7 +98,7 @@ public class PlayState extends State{
         counterText1.setHeight(iconSize / 2);
         board.getRightTable().add(counterText1);
 
-        Texture counterIconTexture1 = new Texture("coin2.png");
+        Texture counterIconTexture1 = new Texture("coin.png");
         Image counterIcon1 = new Image(counterIconTexture1);
         board.getRightTable().add(counterIcon1).size(iconSize, iconSize).pad(5);
         board.getRightTable().row();
@@ -129,30 +110,12 @@ public class PlayState extends State{
         counterText2.setHeight(iconSize / 2);
         board.getRightTable().add(counterText2);
 
-        Texture counterIconTexture2 = new Texture("coin2.png");
+        Texture counterIconTexture2 = new Texture("coin.png");
         Image counterIcon2 = new Image(counterIconTexture2);
         board.getRightTable().add(counterIcon2).size(iconSize, iconSize).pad(5);
         board.getRightTable().row();
     }
 
-    public void renderHeroes(SpriteBatch batch) {
-        for (Entity e : engine.getEntitiesFor(Family.all(HeroComponent.class, AttackComponent.class).get())) {
-            Texture sprite = e.getComponent(SpriteComponent.class).getSprite();
-            Vector2 position = e.getComponent(PositionComponent.class).getPosition();
-
-            batch.draw(sprite, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
-        }
-    }
-
-    public void renderProjectiles(SpriteBatch batch) {
-        for (Entity e : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
-            Texture sprite = e.getComponent(SpriteComponent.class).getSprite();
-            Vector2 position = e.getComponent(PositionComponent.class).getPosition();
-
-            batch.draw(sprite, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
-        }
-    }
-
     @Override
     public void render(SpriteBatch batch) {
         Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
@@ -161,12 +124,9 @@ public class PlayState extends State{
 
         batch.begin();
         board.render(batch);
-        renderHeroes(batch);
-        renderProjectiles(batch);
         batch.draw(menuButton.getImg(), menuButton.getPosition().x - menuButton.getWidth() / 2f, menuButton.getPosition().y, menuButton.getWidth(), menuButton.getHeight());
         batch.end();
 
-
         stage.act(Gdx.graphics.getDeltaTime());
         stage.draw();
     }
diff --git a/core/src/com/mygdx/game/states/StartState.java b/core/src/com/mygdx/game/states/StartState.java
index d4c0be5..cc0b0ef 100644
--- a/core/src/com/mygdx/game/states/StartState.java
+++ b/core/src/com/mygdx/game/states/StartState.java
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.utils.ScreenUtils;
-import com.mygdx.game.Board;
+import com.mygdx.game.ds.Board;
 
 public class StartState extends State implements InputProcessor {
     SpriteBatch batch;
-- 
GitLab


From 0b63b86850c830f5a8f28ad91c1f535c6c4a5974 Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Sat, 22 Apr 2023 11:43:41 +0200
Subject: [PATCH 11/23] minor changes

---
 .../com/mygdx/game/systems/HeroSystem.java    | 21 +------------------
 .../systems/ProjectileMovementSystem.java     |  1 +
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/core/src/com/mygdx/game/systems/HeroSystem.java b/core/src/com/mygdx/game/systems/HeroSystem.java
index f3633bd..4600df1 100644
--- a/core/src/com/mygdx/game/systems/HeroSystem.java
+++ b/core/src/com/mygdx/game/systems/HeroSystem.java
@@ -56,25 +56,6 @@ public class HeroSystem extends IteratingSystem {
         }
 
         //Increase the time elapsed field in the attack component on every update
-        attack.setAttackTimeElapsed(attack.getAttackTimeElapsed() + deltaTime*10);
-        //Check if a hero has an active projectile
-        /*boolean projectileExists = false;
-        for (Entity projectile : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
-            ProjectileComponent projectileComponent = projectileMapper.get(projectile);
-            if (projectileComponent.getSourceEntity() == entity) {
-                //System.out.println(e.getComponent(PositionComponent.class).getPosition());
-                projectileExists = true;
-                break;
-            }
-        }*/
-
-        //If a hero does not have an active projectile, it is created and added to the engine
-        /*if (!projectileExists) {
-            float posX = position.getPosition().x;
-            float posY = position.getPosition().y;
-            Entity projectile = ProjectileFactory.createProjectile(heroComponent.getHeroType(), new Vector2(posX, posY), entity);
-            engine.addEntity(projectile);
-        }*/
-
+        attack.setAttackTimeElapsed(attack.getAttackTimeElapsed() + deltaTime * 5);
     }
 }
\ No newline at end of file
diff --git a/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java b/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
index 643a4e3..ed54ac1 100644
--- a/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
+++ b/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
@@ -35,6 +35,7 @@ public class ProjectileMovementSystem extends IteratingSystem {
 
         //If a projectile is out of bounds, remove it from the engine
         if (positionComponent.getPosition().x > Gdx.graphics.getWidth() - Gdx.graphics.getWidth()/8f) {
+            entity.removeAll();
             engine.removeEntity(entity);
         }
 
-- 
GitLab


From 77bb4fb05275dfcf409e97bbe4b4eb8c6ccc5524 Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Sat, 22 Apr 2023 11:45:11 +0200
Subject: [PATCH 12/23] minor change

---
 core/src/com/mygdx/game/entities/HeroFactory.java       | 2 --
 core/src/com/mygdx/game/entities/ProjectileFactory.java | 2 --
 2 files changed, 4 deletions(-)

diff --git a/core/src/com/mygdx/game/entities/HeroFactory.java b/core/src/com/mygdx/game/entities/HeroFactory.java
index 8bc6f01..e370840 100644
--- a/core/src/com/mygdx/game/entities/HeroFactory.java
+++ b/core/src/com/mygdx/game/entities/HeroFactory.java
@@ -35,8 +35,6 @@ public class HeroFactory {
     }
     
     private static Texture getHeroSprite(HeroType heroType) {
-        //TODO endre path her
-        Texture texture = null;
         switch (heroType) {
             case IRONMAN:
                 return new Texture(Gdx.files.internal("characterIcon3.png"));
diff --git a/core/src/com/mygdx/game/entities/ProjectileFactory.java b/core/src/com/mygdx/game/entities/ProjectileFactory.java
index 981bc94..c38918f 100644
--- a/core/src/com/mygdx/game/entities/ProjectileFactory.java
+++ b/core/src/com/mygdx/game/entities/ProjectileFactory.java
@@ -24,8 +24,6 @@ public class ProjectileFactory {
     }
 
     private static Texture getProjectileSprite(HeroType heroType) {
-        //TODO endre path til en projectile
-        Texture texture = null;
         switch (heroType) {
             case IRONMAN:
                 return new Texture(Gdx.files.internal("ironManShoots.png"));
-- 
GitLab


From 0dfe40f4bcf0a8b4fc38d1fc995531d54e5c4c04 Mon Sep 17 00:00:00 2001
From: Johannes Finne Reinseth <johannes.reinseth@aboveit.no>
Date: Sat, 22 Apr 2023 14:00:40 +0200
Subject: [PATCH 13/23] feat: rework GameMenuState

---
 assets/settings-button.png                    | Bin 0 -> 6667 bytes
 core/src/com/mygdx/game/HeroesVsMonsters.java |   7 --
 core/src/com/mygdx/game/ds/Board.java         |  48 ++++----
 .../com/mygdx/game/{utils => ds}/Slider.java  |   4 +-
 .../mygdx/game/ds/buttons/CircleButton.java   |  47 ++++----
 .../game/ds/buttons/RectangleButton.java      |  44 +++++--
 .../src/com/mygdx/game/states/DummyState.java |  46 -------
 .../com/mygdx/game/states/GameMenuState.java  | 113 +++---------------
 core/src/com/mygdx/game/states/PlayState.java |  24 ++--
 .../com/mygdx/game/states/SettingsState.java  |   2 +-
 10 files changed, 107 insertions(+), 228 deletions(-)
 create mode 100644 assets/settings-button.png
 rename core/src/com/mygdx/game/{utils => ds}/Slider.java (97%)
 delete mode 100644 core/src/com/mygdx/game/states/DummyState.java

diff --git a/assets/settings-button.png b/assets/settings-button.png
new file mode 100644
index 0000000000000000000000000000000000000000..ca952b499edaaf516dadaf3d552d0869b67fc6c3
GIT binary patch
literal 6667
zcmV+m8uaCfP)<h;3K|Lk000e1NJLTq00Arj00Arr0{{R3PNRND00009a7bBm000XU
z000XU0RWnu7ytkOOHfQyMMrQ<baZrdbaZrdbaZrdbaZrdbaZrdbai!gbaZreb#=YH
zy>xVRyu7??Yiq~H$Gf|`adC0O!^5GWp_Z1GjEszcfPkl`r?a!OB(5i!0000AbW%=J
z0EMpA5?eg}1Nen+=}-Uw8Bj??K~#9!?4666qbdx5x7rp3ykOP({!e-cU<Jf_0Xj4G
zaL#_;ba!UJ-z0<(!oPn%*D~H-AFlV??UE#En&x?q5Xy7@Ws+QOxBJ!o6JOJ&r_QdN
zQJPcUFvX4r|B|Pi+CBS9V%aE691};R80EQ?DXodW8kr%=k&R-OeGw|oNl4QONwRTB
z7M-vuW_c=!eG9HjE>%uq!pNz9GiX>LLqP2EC31D;s4x=J#2<WD17JwV7|O3-AzL|@
zsNI-!856{C{tbe4!CbNqqZ%cQ=J@gjqUDcD@%jeQde4e3ewYi_`339hM6fa+y1muw
z`C(a-rE#E)l~!YnE+M1%3t-JbQN@VizVEuORgHhy_gMYg=;qUJldOpqm7HkbwU6ge
zlcuSR)-<FTo{zTc=_qIPJ7H1KJC5l&kVb%M2q}tMYehkb1lW+_3CMI>UnW_s1rh=h
zC&Sr5BS45Z{)PAi{0hmeY1;Bz)ex7@s!)tbp%~4ZBnHTe>iNa69*sanHZ(w1H;-?I
zRn=ritE>NEeH|>Z^w<*a{VXgwqU_h9x^4?!eiYV@aeX-WNojKbZIX3Q=<f=v^0#)+
zB?5Z;Rj{&~><s1i-y>WJ#bV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!v^XFvmTw*U?W>l@<@~vYge87py!)Q8nwrQ4g(W`3m7-c8
zverEQVSNnidU35`7G0oz8P@a6${pVnw#foErUN=Ze;C%CHLBoED`W!(rM*Dgbbx(L
zw6tK?e?JNfD3s-+x<6k+5+yo)T$CaDS@17rujjpbK&jk4{8nVuzc}wfRL~mP?fJS0
zFv_U;U0%-{!z4QLXhnO!H4ULF%M}fY9*?T3?sC-sd_3B(fzcD|H((hxL+WoYyErMM
z9PGGW@7;eZvSyC$!y>MY<KH(~C!2?*TXTKR3a4+?mjxEL=9<fk7cA^|KM`631-Z_o
z_~GaF14~rH0lPs+)xz~joKjxi5&uG9?L@gZ@H-dLhTNswZ_~V7l;D5c;U{8j)d|FD
zA2DLU``Zg-iM=W(Q7{2JB#!o{6(4?ngi8=RMC|vMw+bD#cBC?v1gGfGa{3ii92aR$
z?MZyBk)<G@Swx*8nhyKpi5HNn-@E%cVr`fmYifrmig<k0f7Smy)Qpa&*ur>`@dxC<
V5@A^}^-cf)002ovPDHLkV1h0n0&)NV

literal 0
HcmV?d00001

diff --git a/core/src/com/mygdx/game/HeroesVsMonsters.java b/core/src/com/mygdx/game/HeroesVsMonsters.java
index af8f2ed..7e210c2 100644
--- a/core/src/com/mygdx/game/HeroesVsMonsters.java
+++ b/core/src/com/mygdx/game/HeroesVsMonsters.java
@@ -3,17 +3,10 @@ package com.mygdx.game;
 import com.badlogic.gdx.ApplicationAdapter;
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.Color;
-import com.badlogic.gdx.graphics.GL20;
-import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.utils.ScreenUtils;
-import com.mygdx.game.states.DummyState;
 import com.mygdx.game.states.GameMenuState;
 import com.mygdx.game.states.GameStateManager;
-import com.mygdx.game.states.GameStateManager;
-import com.mygdx.game.states.PlayState;
-import com.mygdx.game.states.SettingsState;
 
 public class HeroesVsMonsters extends ApplicationAdapter {
 	private GameStateManager gsm;
diff --git a/core/src/com/mygdx/game/ds/Board.java b/core/src/com/mygdx/game/ds/Board.java
index 1939911..933a1f4 100644
--- a/core/src/com/mygdx/game/ds/Board.java
+++ b/core/src/com/mygdx/game/ds/Board.java
@@ -38,49 +38,41 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class Board extends Actor {
-    private int screenHeight = Gdx.graphics.getHeight();
-    private int screenWidth = Gdx.graphics.getWidth();
-    private int rows;
-    private int cols;
-    private int[][] cells;
+    private final int screenHeight = Gdx.graphics.getHeight();
+    private final int screenWidth = Gdx.graphics.getWidth();
+    private final int rows;
+    private final int cols;
+    private final int[][] cells;
     private Texture[][] textures;
-    private ShapeRenderer shapeRenderer;
-    private int textureWidth;
-    private int textureHeight;
+    private final ShapeRenderer shapeRenderer;
+    private final int textureWidth;
+    private final int textureHeight;
     private int cellWidth;
     private int cellHeight;
-    private SpriteBatch batch;
+    private final SpriteBatch batch;
 
-    private int yOffset = 0;  // Add yOffset for moving textures up or down
-    private int xOffset = 225; // Add xOffset for moving textures right (previously 315)
-    private int dashOffset = 225; // Add dashOffset for moving dashed lines right (previously 315)
+    private final int yOffset = 0;  // Add yOffset for moving textures up or down
+    private final int xOffset = 225; // Add xOffset for moving textures right (previously 315)
+    private final int dashOffset = 225; // Add dashOffset for moving dashed lines right (previously 315)
 
     private Texture[] buttonTextures;
     private Texture[] displayTextures;
     private int displayTexturesCount = 5;
     private Vector2[] displayTexturePositions;
-    private int draggingTextureIndex = -1;
-    private Vector2 draggingTextureOffset = new Vector2();
-    private Stage stage;
-
-    private Table leftTable;
-    private Table rightTable;
-    private Table boardTable;
-    private TextButton counterText1;
-    private boolean isGridTableVisible = true;
-    private boolean isPlacementAllowed = false;
+    private final Stage stage;
+
     private Array<DisplayHero> displayHeroes;
     private Array<DisplayHeroButton> displayHeroButtons;
 
     private boolean placeHero = false;
 
     private HeroType chosenHeroType;
-    private InputMultiplexer multiplexer;
-    private int gridWidth, gridHeight, startX, startY;
+    private final InputMultiplexer multiplexer;
+    private final int gridWidth, gridHeight, startX, startY;
     private boolean gridDrawn;
     private boolean isInputProcessorAdded;
-    private Engine engine;
-    private MoneySystem moneySystem = new MoneySystem(8000);
+    private final Engine engine;
+    private final MoneySystem moneySystem = new MoneySystem(8000);
 
 
 
@@ -107,7 +99,6 @@ public class Board extends Actor {
         loadDisplayTextures();
         setDisplayHeroes();
         initButtonTextures();
-        //setupInputProcessor();
         displayHeroButtons = new Array<>();
         createDisplayHeroButtons(displayHeroes);
         multiplexer = new InputMultiplexer();
@@ -117,7 +108,7 @@ public class Board extends Actor {
     }
 
     private void drawCounter() {
-        float iconSize = Gdx.graphics.getHeight() / 15;
+        float iconSize = Gdx.graphics.getHeight() / 15f;
         float iconX = screenWidth - iconSize * 2 - 160; // Move 200 pixels to the left
         float iconY = screenHeight - iconSize - 50;
 
@@ -400,6 +391,7 @@ public class Board extends Actor {
 
 
     public Table getRightTable() {
+        Table rightTable = new Table();
         return rightTable;
     }
 
diff --git a/core/src/com/mygdx/game/utils/Slider.java b/core/src/com/mygdx/game/ds/Slider.java
similarity index 97%
rename from core/src/com/mygdx/game/utils/Slider.java
rename to core/src/com/mygdx/game/ds/Slider.java
index 867a25a..aa56b3b 100644
--- a/core/src/com/mygdx/game/utils/Slider.java
+++ b/core/src/com/mygdx/game/ds/Slider.java
@@ -1,10 +1,12 @@
-package com.mygdx.game.utils;
+package com.mygdx.game.ds;
 
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
 import com.badlogic.gdx.math.MathUtils;
 import com.mygdx.game.HeroesVsMonsters;
+import com.mygdx.game.utils.Enums;
+import com.mygdx.game.utils.SettingsData;
 
 public class Slider {
     private final ShapeRenderer shapeRenderer;
diff --git a/core/src/com/mygdx/game/ds/buttons/CircleButton.java b/core/src/com/mygdx/game/ds/buttons/CircleButton.java
index d713d3f..eb33322 100644
--- a/core/src/com/mygdx/game/ds/buttons/CircleButton.java
+++ b/core/src/com/mygdx/game/ds/buttons/CircleButton.java
@@ -2,9 +2,11 @@ package com.mygdx.game.ds.buttons;
 
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
 import com.badlogic.gdx.math.Circle;
 import com.badlogic.gdx.math.Vector2;
+import com.badlogic.gdx.utils.Null;
 
 public class CircleButton {
 
@@ -14,33 +16,22 @@ public class CircleButton {
     private final int radius;
     private final Texture img;
 
-    public CircleButton(float scale, String internalpath) {
-        this.img = new Texture(internalpath);
-        this.radius = (int) ((this.img.getWidth() / 2) / scale);
-        this.position = new Vector2(Gdx.graphics.getWidth() / 2f - this.img.getWidth() / 2f, Gdx.graphics.getHeight() / 2f - this.img.getHeight() / 2f);
-        this.bounds = new Circle(this.position.x, this.position.y, this.radius);
-        this.shape = new ShapeRenderer();
-    }
-
-    public CircleButton(float scale, boolean middle, int ystart, String internalpath) {
-        this.img = new Texture(internalpath);
-        this.radius = (int) ((this.img.getWidth() / 2) / scale);
-        this.position = new Vector2(Gdx.graphics.getWidth() / 2f - this.img.getWidth() / 2f, ystart);
-        this.bounds = new Circle(this.position.x, this.position.y, this.radius);
-        this.shape = new ShapeRenderer();
-    }
-
-    public CircleButton(float scale, int xStart, boolean middle, String internalpath) {
-        this.img = new Texture(internalpath);
-        this.radius = (int) ((this.img.getWidth() / 2) / scale);
-        this.position = new Vector2(xStart, Gdx.graphics.getHeight() / 2f - this.img.getHeight() / 2f);
-        this.bounds = new Circle(this.position.x, this.position.y, this.radius);
-        this.shape = new ShapeRenderer();
-    }
-
-    public CircleButton(int radius, int xStart, int yStart, String internalPath) {
+    public CircleButton(int radius, @Null Integer xStart, @Null Integer yStart, String internalPath) {
+        float startPosX;
+        float startPosY;
         this.radius = radius;
-        this.position = new Vector2(xStart, yStart);
+        if (xStart == null) {
+            startPosX = Gdx.graphics.getWidth() / 2f - radius;
+        } else {
+            startPosX = xStart;
+        }
+
+        if (yStart == null) {
+            startPosY = Gdx.graphics.getHeight() / 2f - radius;
+        } else {
+            startPosY = yStart;
+        }
+        this.position = new Vector2(startPosX, startPosY);
         this.bounds = new Circle(this.position.x, this.position.y, this.radius);
         this.shape = new ShapeRenderer();
         this.img = new Texture(internalPath);
@@ -65,4 +56,8 @@ public class CircleButton {
     public Texture getImg() {
         return img;
     }
+
+    public void render(SpriteBatch sb) {
+        sb.draw(img, position.x, position.y, radius * 2, radius * 2);
+    }
 }
diff --git a/core/src/com/mygdx/game/ds/buttons/RectangleButton.java b/core/src/com/mygdx/game/ds/buttons/RectangleButton.java
index 7e692d7..79eea37 100644
--- a/core/src/com/mygdx/game/ds/buttons/RectangleButton.java
+++ b/core/src/com/mygdx/game/ds/buttons/RectangleButton.java
@@ -1,9 +1,12 @@
 package com.mygdx.game.ds.buttons;
 
+import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
 import com.badlogic.gdx.math.Rectangle;
 import com.badlogic.gdx.math.Vector2;
+import com.badlogic.gdx.utils.Null;
 
 public class RectangleButton {
 
@@ -11,17 +14,32 @@ public class RectangleButton {
     private final Rectangle bounds;
     private final ShapeRenderer shape;
     private final Texture img;
-    private final int width;
-    private final int height;
+    private final float width;
+    private final float height;
     private final float scale;
 
-    public RectangleButton(float scale, int xStart, int yStart, String internalPath) {
+    public RectangleButton(float scale, @Null Integer xStart,@Null Integer yStart, String internalPath) {
+        float startPosX;
+        float startPosY;
         this.scale = scale;
         this.img = new Texture(internalPath);
-        this.width = (int) (img.getWidth() * scale);
-        this.height = (int ) (img.getHeight() * scale);
-        this.position = new Vector2(xStart, yStart);
-        this.bounds = new Rectangle(xStart, yStart, width, height);
+        this.width = img.getWidth() * scale;
+        this.height = img.getHeight() * scale;
+
+        if (xStart == null) {
+            startPosX = Gdx.graphics.getWidth() / 2f - width / 2f;
+        } else {
+            startPosX = xStart;
+        }
+
+        if (yStart == null) {
+            startPosY = Gdx.graphics.getHeight() / 2f - height / 2f;
+        } else {
+            startPosY = yStart;
+        }
+
+        this.position = new Vector2(startPosX, startPosY);
+        this.bounds = new Rectangle(startPosX, startPosY, this.width, this.height);
         this.shape = new ShapeRenderer();
     }
 
@@ -37,9 +55,9 @@ public class RectangleButton {
         return shape;
     }
 
-    public int getWidth() {return this.width;}
+    public float getWidth() {return this.width;}
 
-    public int getHeight() {return this.height;}
+    public float getHeight() {return this.height;}
 
     public Texture getImg() {
         return img;
@@ -48,4 +66,12 @@ public class RectangleButton {
     public float getScale() {
         return scale;
     }
+
+    public void render(SpriteBatch sb) {
+        sb.draw(img, position.x, position.y, width, height);
+    }
+
+    public void dispose() {
+
+    }
 }
diff --git a/core/src/com/mygdx/game/states/DummyState.java b/core/src/com/mygdx/game/states/DummyState.java
deleted file mode 100644
index 323f8b0..0000000
--- a/core/src/com/mygdx/game/states/DummyState.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.mygdx.game.states;
-
-import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.Input;
-import com.badlogic.gdx.graphics.Color;
-import com.badlogic.gdx.graphics.g2d.SpriteBatch;
-import com.badlogic.gdx.utils.ScreenUtils;
-import com.mygdx.game.utils.Enums;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Set;
-
-public class DummyState extends State {
-    //Dummy class for GSM
-
-    private GameStateManager gsm = GameStateManager.getGsm();
-
-    private ArrayList<Float> bg = new ArrayList<>(Arrays.asList(0f,0f,1f,1f));
-
-    @Override
-    public void update(float dt) {
-        handleInput();
-    }
-
-    @Override
-    public void render(SpriteBatch sb) {
-        ScreenUtils.clear(Color.CORAL);
-        sb.begin();
-        sb.end();
-    }
-
-    @Override
-    public void handleInput() {
-        if (Gdx.input.isKeyPressed(Input.Keys.ENTER)) {
-            bg.set(2, 0f);
-            bg.set(1, 1f);
-            gsm.push(new SettingsState(Enums.SettingsBackground.CITY, Enums.GameType.MENU));
-        }
-    }
-
-    @Override
-    public void dispose() {
-
-    }
-}
diff --git a/core/src/com/mygdx/game/states/GameMenuState.java b/core/src/com/mygdx/game/states/GameMenuState.java
index 6486e59..0705436 100644
--- a/core/src/com/mygdx/game/states/GameMenuState.java
+++ b/core/src/com/mygdx/game/states/GameMenuState.java
@@ -1,26 +1,23 @@
 package com.mygdx.game.states;
 
 import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.Input;
 import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.utils.ScreenUtils;
 import com.mygdx.game.FireBaseInterface;
 import com.mygdx.game.SoundManager;
+import com.mygdx.game.ds.buttons.RectangleButton;
 import com.mygdx.game.utils.Enums;
 
 public class GameMenuState extends State {
-    private GameStateManager gsm;
+    private final GameStateManager gsm;
     SoundManager soundManager = SoundManager.getInstance();
     SpriteBatch sb;
-    Texture startButton;
-    Texture lobbyButton;
-    Texture menuButton;
-    private Texture menuBackground;
-
-    Texture logo;
-    Texture img;
+    private final RectangleButton playButton;
+    private final Texture menuBackground;
+    private final RectangleButton logo;
+    private final RectangleButton settingsButton;
     int width;
     int height;
 
@@ -32,12 +29,10 @@ public class GameMenuState extends State {
         sb = new SpriteBatch();
         width = Gdx.graphics.getWidth();
         height = Gdx.graphics.getHeight();
-        startButton = new Texture("playButton.png");
-        lobbyButton = new Texture("Lobby-button.png");
-        menuButton = new Texture("Menu-button.png");
-        logo = new Texture("HvsMstor.png");
+        logo = new RectangleButton(0.3f, null, (int) (Gdx.graphics.getHeight() / 2.5), "HvsMstor.png");
+        playButton = new RectangleButton(1f, null, 200, "playButton.png");
+        settingsButton = new RectangleButton(0.4f, Gdx.graphics.getWidth() - 200, Gdx.graphics.getHeight() - 200, "settings-button.png");
         menuBackground = new Texture("menuBackground.png");
-
     }
 
     public void create() {
@@ -50,101 +45,29 @@ public class GameMenuState extends State {
     @Override
     public void update(float dt) {
         handleInput();
-
     }
 
     @Override
     public void render(SpriteBatch batch) {
         ScreenUtils.clear(Color.BLACK);
-        float centerX = Gdx.graphics.getWidth() / 2f;
-        float centerY = Gdx.graphics.getHeight() / 2f;
-
-
-
-        // Calculate the logo position and size
-        float logoWidth = width / 2.5f;
-        float logoHeight = logoWidth * ((float) logo.getHeight() / logo.getWidth());
-        float logoX = (width - logoWidth) / 2f;
-        float logoY = ((height - logoHeight) / 2f) + height / 5f;
-
-
-        // Calculate the button positions and sizes
-        float buttonWidth = width / 7f;
-        float playButtonWidth = width / 5f;
-        float startButtonHeight = playButtonWidth * ((float) startButton.getHeight() / startButton.getWidth());
-        float lobbyButtonHeight = buttonWidth * ((float) lobbyButton.getHeight() / lobbyButton.getWidth());
-        float menuButtonHeight = buttonWidth * ((float) menuButton.getHeight() / menuButton.getWidth());
-
-
-        float buttonX = (width - buttonWidth) / 2f;
-        float playButtonX = (width - playButtonWidth) /2f;
-        float startButtonY = height * 0.3f - startButtonHeight / 2f;
-        float lobbyButtonY = height * 0.12f - lobbyButtonHeight / 2f;
-        float menuButtonY = height * 0.21f - menuButtonHeight / 2f;
-
-
-
         batch.begin();
         batch.draw(menuBackground, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
-
-        batch.draw(logo, logoX, logoY, logoWidth, logoHeight);
-        batch.draw(startButton, playButtonX, startButtonY, playButtonWidth, startButtonHeight);
-        batch.draw(lobbyButton, buttonX, lobbyButtonY, buttonWidth, lobbyButtonHeight);
-        batch.draw(menuButton, buttonX, menuButtonY, buttonWidth, menuButtonHeight);
-
-
+        logo.render(batch);
+        playButton.render(batch);
+        settingsButton.render(batch);
         batch.end();
-
-
-
-
-    }
-
-    private boolean isStartButtonClicked(int x, int y) {
-        float buttonWidth = width / 5f;
-        float startButtonHeight = buttonWidth * ((float) startButton.getHeight() / startButton.getWidth());
-        float buttonX = (width - buttonWidth) / 2f;
-        float startButtonY = height * 0.3f - startButtonHeight / 2f;
-
-        return Gdx.input.justTouched() && buttonX <= x && x <= buttonX + buttonWidth &&
-                startButtonY <= Gdx.graphics.getHeight() - y && Gdx.graphics.getHeight() - y <= startButtonY + startButtonHeight;
-    }
-
-    private boolean isLobbyButtonClicked(int x, int y) {
-        float buttonWidth = width / 7f;
-        float lobbyButtonHeight = buttonWidth * ((float) lobbyButton.getHeight() / lobbyButton.getWidth());
-        float buttonX = (width - buttonWidth) / 2f;
-        float lobbyButtonY = height * 0.12f - lobbyButtonHeight / 2f;
-
-        return Gdx.input.justTouched() && buttonX <= x && x <= buttonX + buttonWidth &&
-                lobbyButtonY <= Gdx.graphics.getHeight() - y && Gdx.graphics.getHeight() - y <= lobbyButtonY + lobbyButtonHeight;
-    }
-
-    private boolean isMenuButtonClicked(int x, int y) {
-        float buttonWidth = width / 7f;
-        float menuButtonHeight = buttonWidth * ((float) menuButton.getHeight() / menuButton.getWidth());
-        float buttonX = (width - buttonWidth) / 2f;
-        float menuButtonY = height * 0.21f - menuButtonHeight / 2f;
-
-        return Gdx.input.justTouched() && buttonX <= x && x <= buttonX + buttonWidth &&
-                menuButtonY <= Gdx.graphics.getHeight() - y && Gdx.graphics.getHeight() - y <= menuButtonY + menuButtonHeight;
     }
 
     @Override
     public void handleInput() {
         if (Gdx.input.isTouched()) {
             int x = Gdx.input.getX();
-            int y = Gdx.input.getY();
-            if (isStartButtonClicked(x, y)) {
-                soundManager.playSound("menuNavigate");
-                gsm.push(new IntroCutsceneState());
-            }
-            if (isLobbyButtonClicked(x, y)) {
+            int y = Gdx.graphics.getHeight() - Gdx.input.getY();
+            if (playButton.getBounds().contains(x, y)) {
+                gsm.push(new PlayState());
+            } else if (settingsButton.getBounds().contains(x,y)) {
                 gsm.push(new SettingsState(Enums.SettingsBackground.CITY, Enums.GameType.MENU));
             }
-            if (isMenuButtonClicked(x, y)) {
-                gsm.push(new StartState());
-            }
         }
     }
 
@@ -152,9 +75,7 @@ public class GameMenuState extends State {
 
     @Override
     public void dispose() {
-        startButton.dispose();
-        lobbyButton.dispose();
-        menuButton.dispose();
+        playButton.dispose();
         System.out.print("Menu State Disposed");
     }
 }
diff --git a/core/src/com/mygdx/game/states/PlayState.java b/core/src/com/mygdx/game/states/PlayState.java
index d2769cf..84dd611 100644
--- a/core/src/com/mygdx/game/states/PlayState.java
+++ b/core/src/com/mygdx/game/states/PlayState.java
@@ -21,14 +21,15 @@ import com.mygdx.game.systems.HeroSystem;
 import com.mygdx.game.systems.ProjectileMovementSystem;
 import com.mygdx.game.utils.Enums;
 
-public class PlayState extends State{
+public class PlayState extends State {
     private SpriteBatch batch;
     private BitmapFont font;
     private Stage stage;
     private ShapeRenderer shapeRenderer;
-    private SoundManager soundManager = SoundManager.getInstance();
-    private MoneySystem moneySystem;
-    private boolean isPlacementAllowed = false;
+    private final MoneySystem moneySystem;
+    private final boolean isPlacementAllowed = false;
+    private final SoundManager soundManager = SoundManager.getInstance();
+
     private static Engine engine;
     private Board board;
     private TextButton counterText1;
@@ -36,20 +37,15 @@ public class PlayState extends State{
     private final GameStateManager gsm;
 
     public PlayState() {
-        //super(gsm);
         menuButton = new RectangleButton(0.5f, Gdx.graphics.getWidth() - 137, Gdx.graphics.getHeight() - 100, "Lobby-button.png");
         gsm = GameStateManager.getGsm();
-        initialize();
-    }
-
-    private void initialize() {
-        initializeGameEngine();
         batch = new SpriteBatch();
         moneySystem = new MoneySystem(4000);
+        soundManager.playSequence();
+
+        initializeGameEngine();
         initFontStageAndRenderer();
         createBoard();
-        soundManager.playSequence();
-        //Game engine & systems
     }
 
     private void initializeGameEngine() {
@@ -83,12 +79,12 @@ public class PlayState extends State{
 
     @Override
     public void update(float dt) {
-        stage.draw();
         engine.update(dt);
+        handleInput();
     }
 
     public void calculateMoney() {
-        float iconSize = Gdx.graphics.getWidth() / 30;
+        float iconSize = Gdx.graphics.getWidth() / 30f;
         BitmapFont counterFont = new BitmapFont();
         counterFont.getData().setScale(4);
         // First counter
diff --git a/core/src/com/mygdx/game/states/SettingsState.java b/core/src/com/mygdx/game/states/SettingsState.java
index 9f008f7..7fd5a67 100644
--- a/core/src/com/mygdx/game/states/SettingsState.java
+++ b/core/src/com/mygdx/game/states/SettingsState.java
@@ -11,7 +11,7 @@ import com.mygdx.game.ds.buttons.CircleButton;
 import com.mygdx.game.ds.buttons.RectangleButton;
 import com.mygdx.game.utils.Enums;
 import com.mygdx.game.utils.SettingsData;
-import com.mygdx.game.utils.Slider;
+import com.mygdx.game.ds.Slider;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-- 
GitLab


From 4b144d8caa14495ca9c4c826b8ffd76ebc325c75 Mon Sep 17 00:00:00 2001
From: Johannes Finne Reinseth <johannes.reinseth@aboveit.no>
Date: Sat, 22 Apr 2023 14:04:49 +0200
Subject: [PATCH 14/23] fix: music to introcutscene

---
 core/src/com/mygdx/game/states/GameMenuState.java | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/core/src/com/mygdx/game/states/GameMenuState.java b/core/src/com/mygdx/game/states/GameMenuState.java
index 0705436..a840039 100644
--- a/core/src/com/mygdx/game/states/GameMenuState.java
+++ b/core/src/com/mygdx/game/states/GameMenuState.java
@@ -12,8 +12,7 @@ import com.mygdx.game.utils.Enums;
 
 public class GameMenuState extends State {
     private final GameStateManager gsm;
-    SoundManager soundManager = SoundManager.getInstance();
-    SpriteBatch sb;
+    private SoundManager soundManager = SoundManager.getInstance();
     private final RectangleButton playButton;
     private final Texture menuBackground;
     private final RectangleButton logo;
@@ -26,7 +25,6 @@ public class GameMenuState extends State {
     public GameMenuState() {
         super();
         gsm = GameStateManager.getGsm();
-        sb = new SpriteBatch();
         width = Gdx.graphics.getWidth();
         height = Gdx.graphics.getHeight();
         logo = new RectangleButton(0.3f, null, (int) (Gdx.graphics.getHeight() / 2.5), "HvsMstor.png");
@@ -64,7 +62,8 @@ public class GameMenuState extends State {
             int x = Gdx.input.getX();
             int y = Gdx.graphics.getHeight() - Gdx.input.getY();
             if (playButton.getBounds().contains(x, y)) {
-                gsm.push(new PlayState());
+                soundManager.playSound("menuNavigate");
+                gsm.push(new IntroCutsceneState());
             } else if (settingsButton.getBounds().contains(x,y)) {
                 gsm.push(new SettingsState(Enums.SettingsBackground.CITY, Enums.GameType.MENU));
             }
-- 
GitLab


From 600cf882943fa677aac4c59178d7d3450a98f329 Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Sat, 22 Apr 2023 14:59:12 +0200
Subject: [PATCH 15/23] projectile movement handling

---
 .../mygdx/game/components/WaveComponent.java  |  2 ++
 .../game/systems/MonsterMovementSystem.java   | 28 +++++++++++++++++++
 .../com/mygdx/game/systems/MonsterSystem.java |  4 ---
 .../systems/ProjectileMovementSystem.java     |  5 +---
 4 files changed, 31 insertions(+), 8 deletions(-)
 create mode 100644 core/src/com/mygdx/game/components/WaveComponent.java
 create mode 100644 core/src/com/mygdx/game/systems/MonsterMovementSystem.java
 delete mode 100644 core/src/com/mygdx/game/systems/MonsterSystem.java

diff --git a/core/src/com/mygdx/game/components/WaveComponent.java b/core/src/com/mygdx/game/components/WaveComponent.java
new file mode 100644
index 0000000..516c607
--- /dev/null
+++ b/core/src/com/mygdx/game/components/WaveComponent.java
@@ -0,0 +1,2 @@
+package com.mygdx.game.components;public class WaveComponent {
+}
diff --git a/core/src/com/mygdx/game/systems/MonsterMovementSystem.java b/core/src/com/mygdx/game/systems/MonsterMovementSystem.java
new file mode 100644
index 0000000..1112e6e
--- /dev/null
+++ b/core/src/com/mygdx/game/systems/MonsterMovementSystem.java
@@ -0,0 +1,28 @@
+package com.mygdx.game.systems;
+
+import com.badlogic.ashley.core.ComponentMapper;
+import com.badlogic.ashley.core.Engine;
+import com.badlogic.ashley.core.Entity;
+import com.badlogic.ashley.core.Family;
+import com.badlogic.ashley.systems.IteratingSystem;
+import com.mygdx.game.components.AttackComponent;
+import com.mygdx.game.components.MonsterComponent;
+
+public class MonsterSystem extends IteratingSystem {
+    private ComponentMapper<MonsterComponent> monsterMapper;
+    private ComponentMapper<AttackComponent> attackMapper;
+    private Engine engine;
+    public MonsterSystem(Engine engine) {
+        super(Family.all(MonsterComponent.class, AttackComponent.class).get());
+        monsterMapper = ComponentMapper.getFor(MonsterComponent.class);
+        attackMapper = ComponentMapper.getFor(AttackComponent.class);
+        this.engine = engine;
+
+    }
+
+    @Override
+    protected void processEntity(Entity entity, float deltaTime) {
+        MonsterComponent monster = monsterMapper.get(entity);
+        AttackComponent attack = attackMapper.get
+    }
+}
diff --git a/core/src/com/mygdx/game/systems/MonsterSystem.java b/core/src/com/mygdx/game/systems/MonsterSystem.java
deleted file mode 100644
index 8746a39..0000000
--- a/core/src/com/mygdx/game/systems/MonsterSystem.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package com.mygdx.game.systems;
-
-public class MonsterSystem {
-}
diff --git a/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java b/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
index ed54ac1..5a4f779 100644
--- a/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
+++ b/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
@@ -40,10 +40,7 @@ public class ProjectileMovementSystem extends IteratingSystem {
         }
 
         //Increment the horizontal position of the projectile based on its velocity
-        float posY = positionComponent.getPosition().y;
-        float posX = positionComponent.getPosition().x;
         float speed = projectileComponent.getVelocity();
-        float newPosX = posX + speed;
-        positionComponent.setPosition(new Vector2(newPosX, posY));
+        positionComponent.setPosition(positionComponent.getPosition().add(speed, 0));
     }
 }
-- 
GitLab


From 8e076a35dcb2f22d996bba42538dff571a4a34ea Mon Sep 17 00:00:00 2001
From: Anh <qapham@stud.ntnu.no>
Date: Sat, 22 Apr 2023 14:59:32 +0200
Subject: [PATCH 16/23] Add 8 bit trophy image

---
 assets/trophy.png | Bin 0 -> 4612 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 assets/trophy.png

diff --git a/assets/trophy.png b/assets/trophy.png
new file mode 100644
index 0000000000000000000000000000000000000000..fee237700cfd8571ea0bcae06d9fb8dff46342b8
GIT binary patch
literal 4612
zcmeHLX;f2Z8V<-N973&D5JB9)0766s;-q1d#UP6;i7X<q7zGrpGQFU(Q_CQWEhHj@
zvZ_E5Ful-Hd&@S~rX&Tdiu4L75()@c*<^>%@5*83&-`qi={fTwhm*^F-|v0i<$2yO
zX-7O<G}U$02?T;B{g9(KfuKMIAEKHHcrtxPgn~Z`QQj^Ngz7fEmjuGP2D+oYZ_M#m
z1r~P<?{88b)&0C+M;^h^HPO+dFC(~BYipgO-PLVdx7I1?Xe4Vc`c<~kCT|b&%*EyB
zqB~!j&%k@mZINrOk6BJ>PY|C-d7qNhbf+<PVc^rSNQ*1Q$-3Mif^^7OiK8zTViZ9t
ztijquyOIdYZgBNa-@+7`&h6WZG0JJS*xwjQ<o*(+MxwU)qvx3ta~AuJo}wfxiU}2P
zVGX}cv{YbL@NUg=TO#`se3y$7mU45J8v8F7#ZA8XwMRuh-II$%%)MNaFQqrqXi!HJ
zBbf==%OvKB3`eehYB@$R1&C;zAcEi@CRCy)4k)X}8&VJ$@i7VwM@wyUMU{p56|n3L
z2TujC&=!T4O0pjL;DBX9PEZp+&4lXl-!<l9`R)5Hm%V7upGi+fQJ7VC(K{id?ySCx
zkx#l~w*U;$_NcNbqtKyvotQt_E%Zl~#e9YO;g6NN_I<Z0DQ)nse+{fbj9C+aDi>!K
zI=r<MV#y&LiA+c#w5<HS8!?4EOH-uR&$1YF%Tv%TMumf?S|#Qbre-KxJJITr`l_2O
z#{Z0)C_{u%6c%n3D>0r=r|Y8iGpMyExoZ@mWxk$X6OFjE#y=-f;|)M@*%Nw-t-slx
zzCu17_S&l^n61748K+-rPKemBKGfW{u)miTbuE9%1S$UM_D&q|)wTO`4LmP=EV>K4
zaD$GV^vQ-b>^9$5%9mc-b%63~ciE{%i8%>2rsFyN2sjt#=;@tZ@x1}%+{6?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WW7I1slM
zW5mRm&Y~kwbOh8MXN=G;yC6(REvICg5~t_$Qs!<Sw5s@Z!5t?%w0<MHd9fNs?9(D&
zn1Lux{6ChzR9?J!nG}zJzVxv8#rcKua`{-9XW^EGNl)7kY16AKQ=@#MYGzDn*1<+$
z!oY__B?kQIgZ_@#rQz7aSaV~)zLH-C_PM8;@0|V0nbW*K)tT4sJ$I3G{L0F;Go0az
zR&7sMy2uTB;5F&u6$~j1ZRca^G1dlrEIAp--@BpqKUh^NzX;ls>9v-n7~i+H>=I7m
z^FR2kJdqH~ydk}ggQ%hC=Ryat6aL(=av|S)i3rxa1Ewpt^^C%U;D2o^S9#O2!T0bz
rawTVyp#wl*2Eks1-{aqr*`n>|l2Cz4o~|7HtV5tXc{o-(u#$fVTb<a$

literal 0
HcmV?d00001

-- 
GitLab


From 4f14ca6c7161b579555c20229dd3893b53762417 Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Sat, 22 Apr 2023 15:01:33 +0200
Subject: [PATCH 17/23] wave system

---
 .../mygdx/game/components/WaveComponent.java  | 71 ++++++++++++++++++-
 core/src/com/mygdx/game/states/PlayState.java |  3 +
 .../com/mygdx/game/systems/WaveSystem.java    | 49 ++++++++++++-
 3 files changed, 120 insertions(+), 3 deletions(-)

diff --git a/core/src/com/mygdx/game/components/WaveComponent.java b/core/src/com/mygdx/game/components/WaveComponent.java
index 516c607..2cfeb27 100644
--- a/core/src/com/mygdx/game/components/WaveComponent.java
+++ b/core/src/com/mygdx/game/components/WaveComponent.java
@@ -1,2 +1,71 @@
-package com.mygdx.game.components;public class WaveComponent {
+package com.mygdx.game.components;
+
+import com.badlogic.ashley.core.Component;
+import com.badlogic.gdx.utils.Array;
+import com.mygdx.game.types.MonsterType;
+
+public class WaveComponent implements Component {
+    private float timeSinceLastSpawn;
+    private int numberOfMonsters;
+    private boolean isActive;
+    private int waveNumber;
+    private float spawnTimer;
+    private float waveTimeElapsed;
+
+    public WaveComponent(int numberOfMonsters, int waveNumber) {
+        this.numberOfMonsters = numberOfMonsters;
+        this.waveNumber = waveNumber;
+        this.timeSinceLastSpawn = 0f;
+        this.isActive = false;
+        this.spawnTimer = 5f;
+        this.waveTimeElapsed = 0f;
+    }
+
+    public float getSpawnTimer() {
+        return spawnTimer;
+    }
+
+    public void setSpawnTimer(float spawnTimer) {
+        this.spawnTimer = spawnTimer;
+    }
+
+    public int getNumberOfMonsters() {
+        return numberOfMonsters;
+    }
+
+    public void setNumberOfMonsters(int numberOfMonsters) {
+        this.numberOfMonsters = numberOfMonsters;
+    }
+
+    public boolean isActive() {
+        return isActive;
+    }
+
+    public void setActive(boolean active) {
+        isActive = active;
+    }
+
+    public int getWaveNumber() {
+        return waveNumber;
+    }
+
+    public void setWaveNumber(int waveNumber) {
+        this.waveNumber = waveNumber;
+    }
+
+    public float getTimeSinceLastSpawn() {
+        return timeSinceLastSpawn;
+    }
+
+    public void setTimeSinceLastSpawn(float timeSinceLastSpawn) {
+        this.timeSinceLastSpawn = timeSinceLastSpawn;
+    }
+
+    public float getWaveTimeElapsed() {
+        return waveTimeElapsed;
+    }
+
+    public void setWaveTimeElapsed(float waveTimeElapsed) {
+        this.waveTimeElapsed = waveTimeElapsed;
+    }
 }
diff --git a/core/src/com/mygdx/game/states/PlayState.java b/core/src/com/mygdx/game/states/PlayState.java
index 75d030f..55d574d 100644
--- a/core/src/com/mygdx/game/states/PlayState.java
+++ b/core/src/com/mygdx/game/states/PlayState.java
@@ -34,6 +34,7 @@ import com.mygdx.game.entities.HeroFactory;
 import com.mygdx.game.ds.buttons.RectangleButton;
 import com.mygdx.game.systems.HeroSystem;
 import com.mygdx.game.systems.ProjectileMovementSystem;
+import com.mygdx.game.systems.WaveSystem;
 import com.mygdx.game.types.HeroType;
 import com.mygdx.game.utils.Enums;
 
@@ -78,9 +79,11 @@ public class PlayState extends State{
         //Systems for game logic
         HeroSystem heroSystem = new HeroSystem(engine);
         ProjectileMovementSystem projectileMovementSystem = new ProjectileMovementSystem(engine);
+        WaveSystem waveSystem = new WaveSystem(engine);
 
         engine.addSystem(heroSystem);
         engine.addSystem(projectileMovementSystem);
+        engine.addSystem(waveSystem);
 
         /*Entity spiderman = HeroFactory.createHero(HeroType.SPIDERMAN, new Vector2(50, 50));
         Entity captain = HeroFactory.createHero(HeroType.CAPTAIN_AMERICA, new Vector2(50, 50));
diff --git a/core/src/com/mygdx/game/systems/WaveSystem.java b/core/src/com/mygdx/game/systems/WaveSystem.java
index ac9271b..ee1ce37 100644
--- a/core/src/com/mygdx/game/systems/WaveSystem.java
+++ b/core/src/com/mygdx/game/systems/WaveSystem.java
@@ -1,9 +1,54 @@
 package com.mygdx.game.systems;
 
+import com.badlogic.ashley.core.ComponentMapper;
 import com.badlogic.ashley.core.Engine;
+import com.badlogic.ashley.core.Entity;
+import com.badlogic.ashley.core.Family;
+import com.badlogic.ashley.systems.IteratingSystem;
+import com.badlogic.gdx.utils.Array;
+import com.mygdx.game.components.WaveComponent;
+import com.mygdx.game.entities.MonsterFactory;
 
-public class WaveSystem {
+public class WaveSystem extends IteratingSystem {
+    private ComponentMapper<WaveComponent> waveMapper;
+    private Engine engine;
 
-    public WaveSystem(Engine engine, float dt) {
+    public WaveSystem(Engine engine) {
+        super(Family.all(WaveComponent.class).get());
+        waveMapper = ComponentMapper.getFor(WaveComponent.class);
+        this.engine = engine;
+        initializeWaveSystem();
+        System.out.println("Wave 1 is starting in 5 seconds");
+    }
+
+    private void initializeWaveSystem() {
+        //Initializes the first wave
+        Entity waveEntity = new Entity();
+        WaveComponent waveComponent = new WaveComponent(1, 1);
+        waveEntity.add(waveComponent);
+        engine.addEntity(waveEntity);
+    }
+
+    @Override
+    protected void processEntity(Entity entity, float deltaTime) {
+        WaveComponent wave = waveMapper.get(entity);
+
+        //Wave duration is incremented
+        wave.setWaveTimeElapsed(wave.getWaveTimeElapsed() + deltaTime);
+
+        //Activate the current wave
+        if (wave.getWaveTimeElapsed() >= 5f && !wave.isActive()) {
+            wave.setActive(true);
+            System.out.println("Beginning wave " + wave.getWaveNumber());
+        }
+
+        //Begin a new wave after the given time
+        if (wave.getWaveTimeElapsed() >= 10f) {
+            System.out.println("Ending wave " + wave.getWaveNumber());
+            wave.setActive(false);
+            wave.setWaveNumber(wave.getWaveNumber() + 1);
+            wave.setWaveTimeElapsed(0f);
+            wave.setNumberOfMonsters(wave.getWaveNumber() + 2);
+        }
     }
 }
-- 
GitLab


From fc5e99bb855f1f24bf4c0c1b3e5103af022d8d58 Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Sat, 22 Apr 2023 15:02:35 +0200
Subject: [PATCH 18/23] monster movement system

---
 .../game/components/MonsterComponent.java     | 12 +++++++--
 .../mygdx/game/entities/MonsterFactory.java   |  4 +--
 .../game/systems/MonsterMovementSystem.java   | 27 ++++++++++++++-----
 .../com/mygdx/game/systems/WaveSystem.java    |  4 +--
 4 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/core/src/com/mygdx/game/components/MonsterComponent.java b/core/src/com/mygdx/game/components/MonsterComponent.java
index 5e0c3d6..dee19a1 100644
--- a/core/src/com/mygdx/game/components/MonsterComponent.java
+++ b/core/src/com/mygdx/game/components/MonsterComponent.java
@@ -4,7 +4,9 @@ import com.badlogic.ashley.core.Component;
 import com.mygdx.game.types.MonsterType;
 
 public class MonsterComponent implements Component {
-    public MonsterComponent(MonsterType monsterType) {
+    private MonsterType monsterType;
+    private float movementSpeed;
+    public MonsterComponent(MonsterType monsterType, float movementSpeed) {
         this.monsterType = monsterType;
     }
 
@@ -16,5 +18,11 @@ public class MonsterComponent implements Component {
         this.monsterType = monsterType;
     }
 
-    private MonsterType monsterType;
+    public float getMovementSpeed() {
+        return movementSpeed;
+    }
+
+    public void setMovementSpeed(float movementSpeed) {
+        this.movementSpeed = movementSpeed;
+    }
 }
diff --git a/core/src/com/mygdx/game/entities/MonsterFactory.java b/core/src/com/mygdx/game/entities/MonsterFactory.java
index 6f15b12..f6ba04d 100644
--- a/core/src/com/mygdx/game/entities/MonsterFactory.java
+++ b/core/src/com/mygdx/game/entities/MonsterFactory.java
@@ -4,6 +4,7 @@ import com.badlogic.ashley.core.Entity;
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.math.Vector2;
+import com.mygdx.game.components.AttackComponent;
 import com.mygdx.game.components.MonsterComponent;
 import com.mygdx.game.components.MovementSpeedComponent;
 import com.mygdx.game.components.PositionComponent;
@@ -16,8 +17,7 @@ public class MonsterFactory {
         Entity monster = new Entity();
         monster.add(new SpriteComponent(getMonsterSprite(monsterType)));
         monster.add(new PositionComponent(boardPosition));
-        monster.add(new MovementSpeedComponent(getMonsterMovementSpeed(monsterType)));
-        monster.add(new MonsterComponent(monsterType));
+        monster.add(new MonsterComponent(monsterType, getMonsterMovementSpeed(monsterType)));
         return monster;
     }
 
diff --git a/core/src/com/mygdx/game/systems/MonsterMovementSystem.java b/core/src/com/mygdx/game/systems/MonsterMovementSystem.java
index 1112e6e..b454734 100644
--- a/core/src/com/mygdx/game/systems/MonsterMovementSystem.java
+++ b/core/src/com/mygdx/game/systems/MonsterMovementSystem.java
@@ -5,17 +5,19 @@ import com.badlogic.ashley.core.Engine;
 import com.badlogic.ashley.core.Entity;
 import com.badlogic.ashley.core.Family;
 import com.badlogic.ashley.systems.IteratingSystem;
-import com.mygdx.game.components.AttackComponent;
+import com.badlogic.gdx.Gdx;
 import com.mygdx.game.components.MonsterComponent;
+import com.mygdx.game.components.PositionComponent;
 
-public class MonsterSystem extends IteratingSystem {
+public class MonsterMovementSystem extends IteratingSystem {
     private ComponentMapper<MonsterComponent> monsterMapper;
-    private ComponentMapper<AttackComponent> attackMapper;
+    private ComponentMapper<PositionComponent> positionMapper;
     private Engine engine;
-    public MonsterSystem(Engine engine) {
-        super(Family.all(MonsterComponent.class, AttackComponent.class).get());
+
+    public MonsterMovementSystem(Engine engine) {
+        super(Family.all(MonsterComponent.class, PositionComponent.class).get());
         monsterMapper = ComponentMapper.getFor(MonsterComponent.class);
-        attackMapper = ComponentMapper.getFor(AttackComponent.class);
+        positionMapper = ComponentMapper.getFor(PositionComponent.class);
         this.engine = engine;
 
     }
@@ -23,6 +25,17 @@ public class MonsterSystem extends IteratingSystem {
     @Override
     protected void processEntity(Entity entity, float deltaTime) {
         MonsterComponent monster = monsterMapper.get(entity);
-        AttackComponent attack = attackMapper.get
+        PositionComponent monsterPos = positionMapper.get(entity);
+
+        //Make the monster move to the left
+        monsterPos.setPosition(monsterPos.getPosition().add(monster.getMovementSpeed() * -1, 0));
+
+        //Remove monsters that are out of bounds
+        if (monsterPos.getPosition().x <= 0 + Gdx.graphics.getWidth() / 8) {
+            entity.removeAll();
+            engine.removeEntity(entity);
+        }
+
+
     }
 }
diff --git a/core/src/com/mygdx/game/systems/WaveSystem.java b/core/src/com/mygdx/game/systems/WaveSystem.java
index ee1ce37..d90174d 100644
--- a/core/src/com/mygdx/game/systems/WaveSystem.java
+++ b/core/src/com/mygdx/game/systems/WaveSystem.java
@@ -39,12 +39,12 @@ public class WaveSystem extends IteratingSystem {
         //Activate the current wave
         if (wave.getWaveTimeElapsed() >= 5f && !wave.isActive()) {
             wave.setActive(true);
-            System.out.println("Beginning wave " + wave.getWaveNumber());
+            //System.out.println("Beginning wave " + wave.getWaveNumber());
         }
 
         //Begin a new wave after the given time
         if (wave.getWaveTimeElapsed() >= 10f) {
-            System.out.println("Ending wave " + wave.getWaveNumber());
+            //System.out.println("Ending wave " + wave.getWaveNumber());
             wave.setActive(false);
             wave.setWaveNumber(wave.getWaveNumber() + 1);
             wave.setWaveTimeElapsed(0f);
-- 
GitLab


From 16e272fd25f57e4de0d785e9ff0e8b2bfb8b1ace Mon Sep 17 00:00:00 2001
From: Johannes Finne Reinseth <johannes.reinseth@aboveit.no>
Date: Sat, 22 Apr 2023 15:38:15 +0200
Subject: [PATCH 19/23] feat: rework codebase

---
 assets/highscore.png                          | Bin 0 -> 7295 bytes
 core/src/com/mygdx/game/SoundManager.java     |  10 +-
 core/src/com/mygdx/game/ds/Board.java         |   6 +-
 .../buttons}/DisplayHeroButton.java           |   2 +-
 .../com/mygdx/game/states/GameMenuState.java  |   9 +-
 core/src/com/mygdx/game/states/GridState.java |  38 ------
 .../mygdx/game/states/IntroCutsceneState.java |  45 +++---
 .../mygdx/game/states/LeaderBoardState.java   |  25 ++++
 .../src/com/mygdx/game/states/StartState.java | 128 ------------------
 9 files changed, 58 insertions(+), 205 deletions(-)
 create mode 100644 assets/highscore.png
 rename core/src/com/mygdx/game/{utils => ds/buttons}/DisplayHeroButton.java (98%)
 delete mode 100644 core/src/com/mygdx/game/states/GridState.java
 create mode 100644 core/src/com/mygdx/game/states/LeaderBoardState.java
 delete mode 100644 core/src/com/mygdx/game/states/StartState.java

diff --git a/assets/highscore.png b/assets/highscore.png
new file mode 100644
index 0000000000000000000000000000000000000000..4d199bbfa7c2ad59fd7ac19d447704698dffb4c7
GIT binary patch
literal 7295
zcmeHMYgm)lmIg$FTCW^&Y`{220v1GCY6yscT90WEP#K9Kp~9dj4VQqiVvr;tV_Rw?
zH32LER0<uHB-|lT0>M+j223=JT$GS-xFjG#ln4Pr!t5`g?VNe$Jo97voas#e5T5V*
z*4po0mv^nbcKXpk%$im2t}-(-TZ8@hV33)a#RT~ON2?X!Z(mvFYVc!D3BnvOE0Nlc
znwi;pVh`>=e(~hE{GUq-J>!-?K5=!d`gA~Lwpih0wP&B(UCZ0aq7lxtm@F$=`<`#M
zj2-6dwV=^SD}n=3%*-t;t=4aQX>K8UH}S4Lt^Ye49c(?#a`ExLl%~TLS$03LUL$WZ
z)>PE`ri^R{U+*)Co!of$#pA3Z*H?HsB3!!xQe%3t&g%Gu5x)*t+5CXf?7NJmudUW!
z#NMv>=me{=d2q81)|34663Z5sFyATqFBX_-F_^m}_P+(2vM=(B5__6iyX(ZdZF5$p
z9e|}%Z&*5cokxxy-b+tlq)0GtfLiU{cJyh1GZxV_c~!scOP|Y2o8H%tOl@2H33hH{
zM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PNiZL>eC%zAP9XNKFZncQFjt5Pk@^*fFe5H2)|TSu3}QMpo2U~vVvQ;4{*D&
z25>ku32|f_LH9fL!Irk7`{F66iGgYXRM~W(mtmsFdE6pZmo7Nk9WPnVdKxta+AUV1
z;=0Z==XE!z&l%#Q4r>BSx}nw!&=}PJ)N5L|#`36xp-7aVv6N7GpS0^6K!YO45ZY_P
zN8%z82wj^0=Wd_IpKE}20B93*8nj*-8X7ym)lT>7rf8j<H8@Htpj|^OFhqXh5G~Nb
z0LseqQ*N2qH1=4vsR{*v@;}lGxEBMDR(PDiO86RXS4<gawSA@RIcO^E!NBNuSN^K5
z)QuMUy&2$J`h;!^X|(2u=*A?^`R?}X449FQ@|is$<$AVkcstLZIRa+H_ie!-w(QNE
z7YzB2gAsKTI5aoCnaFP2*MAIrXnqHp$sT(<tH&${v#vZa_T9NOjt0Zkt((ArHXa<}
ze`5;!;hS}qFLm7e3-hyTZo$A?Ls}iQU>N4JnirB#Gs8_Mtc@8Se{};<0uAST!2}!s
zX25P~wbu#Eu=~NlC;ZJQ99+=c1s|sT8<=SiFAc51-Ao}gZw~~v&0e|(0M`T=tAIm1
zz;XRIrtl^6>LrUAua!23-(2(T+qQmYQ*)y&0XuiDdciI#fng^5`A$b@Z@SY78<_3h
r_E$E2d#m$XzczAx^{d`|84wLWwVL^J?_`4;MKkQ50uPoP2*3RAd>u_f

literal 0
HcmV?d00001

diff --git a/core/src/com/mygdx/game/SoundManager.java b/core/src/com/mygdx/game/SoundManager.java
index 09563a9..9eff5ad 100644
--- a/core/src/com/mygdx/game/SoundManager.java
+++ b/core/src/com/mygdx/game/SoundManager.java
@@ -4,15 +4,17 @@ import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.audio.Music;
 import com.badlogic.gdx.audio.Sound;
 import com.badlogic.gdx.utils.Disposable;
+import com.mygdx.game.utils.SettingsData;
 
 import java.util.HashMap;
 import java.util.Map;
 
 public class SoundManager implements Disposable {
     private static SoundManager instance;
-    private Map<String, Sound> soundMap;
-    private Map<String, Music> musicMap;
+    private final Map<String, Sound> soundMap;
+    private final Map<String, Music> musicMap;
     private Music currentMusic;
+    private final SettingsData settingsData = SettingsData.loadSettings();
 
     public SoundManager() {
         soundMap = new HashMap<>();
@@ -52,7 +54,7 @@ public class SoundManager implements Disposable {
 
     public void playSound(String soundName) {
         if (soundMap.containsKey(soundName)) {
-            soundMap.get(soundName).play(1.0f);
+            soundMap.get(soundName).play(settingsData.SFX / 100f);
         }
     }
 
@@ -115,7 +117,7 @@ public class SoundManager implements Disposable {
             }
             currentMusic = musicMap.get(musicName);
             currentMusic.setLooping(loop);
-            currentMusic.setVolume(0.6f);
+            currentMusic.setVolume(settingsData.AUDIO / 100f);
             currentMusic.play();
         }
     }
diff --git a/core/src/com/mygdx/game/ds/Board.java b/core/src/com/mygdx/game/ds/Board.java
index 933a1f4..733fd13 100644
--- a/core/src/com/mygdx/game/ds/Board.java
+++ b/core/src/com/mygdx/game/ds/Board.java
@@ -23,7 +23,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Button;
 import com.badlogic.gdx.scenes.scene2d.ui.Image;
 import com.badlogic.gdx.scenes.scene2d.ui.Label;
 import com.badlogic.gdx.scenes.scene2d.ui.Table;
-import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
 import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
 import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
 import com.badlogic.gdx.utils.Array;
@@ -32,10 +31,7 @@ import com.mygdx.game.components.HeroComponent;
 import com.mygdx.game.entities.DisplayHero;
 import com.mygdx.game.entities.HeroFactory;
 import com.mygdx.game.types.HeroType;
-import com.mygdx.game.utils.DisplayHeroButton;
-
-import java.util.ArrayList;
-import java.util.List;
+import com.mygdx.game.ds.buttons.DisplayHeroButton;
 
 public class Board extends Actor {
     private final int screenHeight = Gdx.graphics.getHeight();
diff --git a/core/src/com/mygdx/game/utils/DisplayHeroButton.java b/core/src/com/mygdx/game/ds/buttons/DisplayHeroButton.java
similarity index 98%
rename from core/src/com/mygdx/game/utils/DisplayHeroButton.java
rename to core/src/com/mygdx/game/ds/buttons/DisplayHeroButton.java
index 1132c8a..2b7e1b4 100644
--- a/core/src/com/mygdx/game/utils/DisplayHeroButton.java
+++ b/core/src/com/mygdx/game/ds/buttons/DisplayHeroButton.java
@@ -1,4 +1,4 @@
-package com.mygdx.game.utils;
+package com.mygdx.game.ds.buttons;
 
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.math.Vector2;
diff --git a/core/src/com/mygdx/game/states/GameMenuState.java b/core/src/com/mygdx/game/states/GameMenuState.java
index a840039..a363120 100644
--- a/core/src/com/mygdx/game/states/GameMenuState.java
+++ b/core/src/com/mygdx/game/states/GameMenuState.java
@@ -17,6 +17,7 @@ public class GameMenuState extends State {
     private final Texture menuBackground;
     private final RectangleButton logo;
     private final RectangleButton settingsButton;
+    private final RectangleButton trophyButton;
     int width;
     int height;
 
@@ -28,8 +29,9 @@ public class GameMenuState extends State {
         width = Gdx.graphics.getWidth();
         height = Gdx.graphics.getHeight();
         logo = new RectangleButton(0.3f, null, (int) (Gdx.graphics.getHeight() / 2.5), "HvsMstor.png");
-        playButton = new RectangleButton(1f, null, 200, "playButton.png");
+        playButton = new RectangleButton(1f, null, 150, "playButton.png");
         settingsButton = new RectangleButton(0.4f, Gdx.graphics.getWidth() - 200, Gdx.graphics.getHeight() - 200, "settings-button.png");
+        trophyButton = new RectangleButton(0.5f, 80, Gdx.graphics.getHeight() - 210, "trophy.png");
         menuBackground = new Texture("menuBackground.png");
     }
 
@@ -53,6 +55,7 @@ public class GameMenuState extends State {
         logo.render(batch);
         playButton.render(batch);
         settingsButton.render(batch);
+        trophyButton.render(batch);
         batch.end();
     }
 
@@ -66,12 +69,12 @@ public class GameMenuState extends State {
                 gsm.push(new IntroCutsceneState());
             } else if (settingsButton.getBounds().contains(x,y)) {
                 gsm.push(new SettingsState(Enums.SettingsBackground.CITY, Enums.GameType.MENU));
+            } else if (trophyButton.getBounds().contains(x,y)) {
+                gsm.push(new LeaderBoardState());
             }
         }
     }
 
-
-
     @Override
     public void dispose() {
         playButton.dispose();
diff --git a/core/src/com/mygdx/game/states/GridState.java b/core/src/com/mygdx/game/states/GridState.java
deleted file mode 100644
index aa101cc..0000000
--- a/core/src/com/mygdx/game/states/GridState.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.mygdx.game.states;
-
-import com.badlogic.gdx.graphics.Color;
-import com.badlogic.gdx.graphics.g2d.SpriteBatch;
-import com.badlogic.gdx.utils.ScreenUtils;
-
-public class GridState extends State {
-    private GameStateManager gsm;
-
-    public GridState() {
-        super();
-        gsm = GameStateManager.getGsm();
-    }
-
-    public void create() {
-
-    }
-
-    @Override
-    public void update(float dt) {
-
-    }
-
-    @Override
-    public void render(SpriteBatch batch) {
-        ScreenUtils.clear(Color.PINK);
-    }
-
-    @Override
-    public void handleInput() {
-
-    }
-
-    @Override
-    public void dispose() {
-
-    }
-}
diff --git a/core/src/com/mygdx/game/states/IntroCutsceneState.java b/core/src/com/mygdx/game/states/IntroCutsceneState.java
index 679b225..200ffa2 100644
--- a/core/src/com/mygdx/game/states/IntroCutsceneState.java
+++ b/core/src/com/mygdx/game/states/IntroCutsceneState.java
@@ -7,19 +7,19 @@ import com.badlogic.gdx.utils.ScreenUtils;
 import com.mygdx.game.SoundManager;
 
 public class IntroCutsceneState extends State {
-    private GameStateManager gsm;
-    private Texture cityBackground;
-    private Texture explosionsBackground;
-    private Texture nick;
-    private Texture speech_1;
-    private Texture speech_2;
-    private Texture speech_3;
-    private SoundManager soundmanager = SoundManager.getInstance();
+    private final GameStateManager gsm;
+    private final Texture cityBackground;
+    private final Texture explosionsBackground;
+    private final Texture nick;
+    private final Texture speech_1;
+    private final Texture speech_2;
+    private final Texture speech_3;
+    private final SoundManager soundmanager = SoundManager.getInstance();
 
     private float nickPositionX;
-    private float nickWidth;
-    private float nickHeight;
-    private float slidingSpeed;
+    private final float nickWidth;
+    private final float nickHeight;
+    private final float slidingSpeed;
     private float elapsedTime;
     private int phase;
 
@@ -45,21 +45,15 @@ public class IntroCutsceneState extends State {
     @Override
     public void update(float dt) {
         elapsedTime += dt;
-        Boolean musicOn = false;
         handleInput();
         switch (phase) {
             case 0:
                 nickPositionX -= slidingSpeed * dt;
                 if (nickPositionX <= Gdx.graphics.getWidth() - nickWidth) {
                     nickPositionX = Gdx.graphics.getWidth() - nickWidth;
-
                     soundmanager.playMusic("avengersHype", false);
-
-
                     phase = 1;
                     elapsedTime = 0;
-
-
                 }
                 break;
             case 1:
@@ -86,9 +80,8 @@ public class IntroCutsceneState extends State {
                 break;
             case 4:
                 if (elapsedTime >= 3.0f) {
-                    //System.out.println("Cutscene finished!");
-                    goNext();
-
+                    soundmanager.stopMusic("avengersHype");
+                    gsm.push(new PlayState());
                 }
                 break;
         }
@@ -120,15 +113,15 @@ public class IntroCutsceneState extends State {
     @Override
     public void handleInput() {
         if (Gdx.input.isTouched()) {
-            goNext();
+            if (phase < 4) {
+                phase += 1;
+            } else {
+                soundmanager.stopMusic("avengersHype");
+                gsm.push(new PlayState());
+            }
         }
-
     }
 
-    public void goNext() {
-        soundmanager.stopMusic("avengersHype");
-        gsm.push(new PlayState());
-    }
     @Override
     public void dispose() {
         cityBackground.dispose();
diff --git a/core/src/com/mygdx/game/states/LeaderBoardState.java b/core/src/com/mygdx/game/states/LeaderBoardState.java
new file mode 100644
index 0000000..4521e97
--- /dev/null
+++ b/core/src/com/mygdx/game/states/LeaderBoardState.java
@@ -0,0 +1,25 @@
+package com.mygdx.game.states;
+
+import com.badlogic.gdx.graphics.g2d.SpriteBatch;
+
+public class LeaderBoardState extends State {
+    @Override
+    public void update(float dt) {
+
+    }
+
+    @Override
+    public void render(SpriteBatch batch) {
+
+    }
+
+    @Override
+    public void handleInput() {
+
+    }
+
+    @Override
+    public void dispose() {
+
+    }
+}
diff --git a/core/src/com/mygdx/game/states/StartState.java b/core/src/com/mygdx/game/states/StartState.java
deleted file mode 100644
index cc0b0ef..0000000
--- a/core/src/com/mygdx/game/states/StartState.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package com.mygdx.game.states;
-
-import com.badlogic.gdx.InputProcessor;
-import com.badlogic.gdx.graphics.Color;
-import com.badlogic.gdx.graphics.Texture;
-import com.badlogic.gdx.graphics.g2d.SpriteBatch;
-import com.badlogic.gdx.utils.ScreenUtils;
-import com.mygdx.game.ds.Board;
-
-public class StartState extends State implements InputProcessor {
-    SpriteBatch batch;
-    Board board;
-
-
-    public StartState() {
-        initialize();
-    }
-
-    public void initialize() {
-        batch = new SpriteBatch();
-        //board = new Board(6, 9, engine);
-
-        Texture texture = new Texture("characterIcon1.png");
-        Texture texture1 = new Texture("characterIcon2.png");
-
-        board.setTexture(0, 0, texture);
-        board.setTexture(0, 1, texture);
-        board.setTexture(0, 2, texture);
-        board.setTexture(0, 3, texture);
-        board.setTexture(0, 4, texture);
-        board.setTexture(0, 5, texture);
-        board.setTexture(0, 6, texture);
-        board.setTexture(0, 7, texture);
-        board.setTexture(0, 8, texture);
-
-        board.setTexture(1, 2, texture);
-        board.setTexture(2, 2, texture);
-        board.setTexture(3, 2, texture);
-        board.setTexture(4, 2, texture);
-        board.setTexture(5, 2, texture);
-
-        board.setTexture(1, 3, texture1);
-        board.setTexture(2, 3, texture1);
-        board.setTexture(3, 3, texture1);
-        board.setTexture(4, 3, texture1);
-        board.setTexture(5, 3, texture1);
-
-        board.setTexture(4, 5, texture1);
-    }
-
-    @Override
-    public void update(float dt) {
-
-    }
-
-    @Override
-    public void render(SpriteBatch batch) {
-        ScreenUtils.clear(Color.DARK_GRAY);
-        batch.begin();
-
-        int rows = board.getRows();
-        int cols = board.getCols();
-
-        // Retrieve the textures array from the board
-        Texture[][] textures = board.getTextures();
-
-        //Render board
-        board.render(batch);
-
-
-        batch.end();
-
-    }
-
-    @Override
-    public void handleInput() {
-
-    }
-
-    @Override
-    public void dispose() {
-
-    }
-
-    /*
-     * Methods for movement-functionality
-     */
-
-    @Override
-    public boolean keyDown(int keycode) {
-        return false;
-    }
-
-    @Override
-    public boolean keyUp(int keycode) {
-        return false;
-    }
-
-    @Override
-    public boolean keyTyped(char character) {
-        return false;
-    }
-
-    @Override
-    public boolean touchDown(int screenX, int screenY, int pointer, int button) {
-        return false;
-    }
-
-    @Override
-    public boolean touchUp(int screenX, int screenY, int pointer, int button) {
-        return false;
-    }
-
-    @Override
-    public boolean touchDragged(int screenX, int screenY, int pointer) {
-        return false;
-    }
-
-    @Override
-    public boolean mouseMoved(int screenX, int screenY) {
-        return false;
-    }
-
-    @Override
-    public boolean scrolled(float amountX, float amountY) {
-        return false;
-    }
-}
-- 
GitLab


From d21e7a4fb955d1dd08f1bdc71ba0aa05cbedb871 Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Sat, 22 Apr 2023 16:17:46 +0200
Subject: [PATCH 20/23] monster movement system and render

---
 .../game/components/MonsterComponent.java     |  1 +
 .../mygdx/game/entities/MonsterFactory.java   | 23 +++++++-------
 core/src/com/mygdx/game/states/PlayState.java | 22 +++++++++++---
 .../com/mygdx/game/systems/WaveSystem.java    | 30 ++++++++++++++++---
 4 files changed, 56 insertions(+), 20 deletions(-)

diff --git a/core/src/com/mygdx/game/components/MonsterComponent.java b/core/src/com/mygdx/game/components/MonsterComponent.java
index dee19a1..45f2644 100644
--- a/core/src/com/mygdx/game/components/MonsterComponent.java
+++ b/core/src/com/mygdx/game/components/MonsterComponent.java
@@ -8,6 +8,7 @@ public class MonsterComponent implements Component {
     private float movementSpeed;
     public MonsterComponent(MonsterType monsterType, float movementSpeed) {
         this.monsterType = monsterType;
+        this.movementSpeed = movementSpeed;
     }
 
     public MonsterType getMonsterType() {
diff --git a/core/src/com/mygdx/game/entities/MonsterFactory.java b/core/src/com/mygdx/game/entities/MonsterFactory.java
index f6ba04d..646c258 100644
--- a/core/src/com/mygdx/game/entities/MonsterFactory.java
+++ b/core/src/com/mygdx/game/entities/MonsterFactory.java
@@ -22,13 +22,12 @@ public class MonsterFactory {
     }
 
     private static Texture getMonsterSprite(MonsterType monsterType) {
-        //TODO endre path her
-        Texture texture = null;
+        //TODO legg til riktig bilde
         switch (monsterType) {
             case MAGNETO:
-                return new Texture(Gdx.files.internal("characterIcon3.png"));
+                return new Texture(Gdx.files.internal("Monster_3.png"));
             case JUGGERNAUT:
-                return new Texture(Gdx.files.internal("characterIcon1.png"));
+                return new Texture(Gdx.files.internal("Monster_3.png"));
             case VENOM:
                 return new Texture(Gdx.files.internal("Monster_3.png"));
             case HOBGOBLIN:
@@ -36,7 +35,7 @@ public class MonsterFactory {
             case GOBLIN_GLIDER:
                 return new Texture(Gdx.files.internal("Monster_1.png"));
             case MYSTIQUE:
-                return new Texture(Gdx.files.internal("characterIcon6.png"));
+                return new Texture(Gdx.files.internal("Monster_3.png"));
             default:
                 return null;
         }
@@ -45,19 +44,19 @@ public class MonsterFactory {
     private static float getMonsterMovementSpeed(MonsterType monsterType) {
         switch (monsterType) {
             case MAGNETO:
-                return 2f;
+                return 20f;
             case JUGGERNAUT:
-                return 4f;
+                return 30f;
             case VENOM:
-                return 1f;
+                return 30f;
             case HOBGOBLIN:
-                return 2.5f;
+                return 20f;
             case GOBLIN_GLIDER:
-                return 1.5f;
+                return 10f;
             case MYSTIQUE:
-                return 5f;
+                return 15f;
             default:
-                return 0;
+                return 30f;
         }
     }
 
diff --git a/core/src/com/mygdx/game/states/PlayState.java b/core/src/com/mygdx/game/states/PlayState.java
index 55d574d..ce61a99 100644
--- a/core/src/com/mygdx/game/states/PlayState.java
+++ b/core/src/com/mygdx/game/states/PlayState.java
@@ -26,6 +26,7 @@ import com.mygdx.game.MoneySystem;
 import com.mygdx.game.SoundManager;
 import com.mygdx.game.components.AttackComponent;
 import com.mygdx.game.components.HeroComponent;
+import com.mygdx.game.components.MonsterComponent;
 import com.mygdx.game.components.PositionComponent;
 import com.mygdx.game.components.ProjectileComponent;
 import com.mygdx.game.components.SpriteComponent;
@@ -33,6 +34,7 @@ import com.mygdx.game.entities.DisplayHero;
 import com.mygdx.game.entities.HeroFactory;
 import com.mygdx.game.ds.buttons.RectangleButton;
 import com.mygdx.game.systems.HeroSystem;
+import com.mygdx.game.systems.MonsterMovementSystem;
 import com.mygdx.game.systems.ProjectileMovementSystem;
 import com.mygdx.game.systems.WaveSystem;
 import com.mygdx.game.types.HeroType;
@@ -80,10 +82,12 @@ public class PlayState extends State{
         HeroSystem heroSystem = new HeroSystem(engine);
         ProjectileMovementSystem projectileMovementSystem = new ProjectileMovementSystem(engine);
         WaveSystem waveSystem = new WaveSystem(engine);
+        MonsterMovementSystem monsterMovementSystem = new MonsterMovementSystem(engine);
 
         engine.addSystem(heroSystem);
         engine.addSystem(projectileMovementSystem);
         engine.addSystem(waveSystem);
+        engine.addSystem(monsterMovementSystem);
 
         /*Entity spiderman = HeroFactory.createHero(HeroType.SPIDERMAN, new Vector2(50, 50));
         Entity captain = HeroFactory.createHero(HeroType.CAPTAIN_AMERICA, new Vector2(50, 50));
@@ -140,19 +144,28 @@ public class PlayState extends State{
 
     public void renderHeroes(SpriteBatch batch) {
         for (Entity e : engine.getEntitiesFor(Family.all(HeroComponent.class, AttackComponent.class).get())) {
-            Texture sprite = e.getComponent(SpriteComponent.class).getSprite();
+            Texture texture = e.getComponent(SpriteComponent.class).getSprite();
             Vector2 position = e.getComponent(PositionComponent.class).getPosition();
 
-            batch.draw(sprite, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
+            batch.draw(texture, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
         }
     }
 
     public void renderProjectiles(SpriteBatch batch) {
         for (Entity e : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
-            Texture sprite = e.getComponent(SpriteComponent.class).getSprite();
+            Texture texture = e.getComponent(SpriteComponent.class).getSprite();
             Vector2 position = e.getComponent(PositionComponent.class).getPosition();
 
-            batch.draw(sprite, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
+            batch.draw(texture, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
+        }
+    }
+
+    public void renderMonsters(SpriteBatch batch) {
+        for (Entity e : engine.getEntitiesFor(Family.all(MonsterComponent.class, PositionComponent.class).get())) {
+            Texture texture = e.getComponent(SpriteComponent.class).getSprite();
+            Vector2 position = e.getComponent(PositionComponent.class).getPosition();
+
+            batch.draw(texture, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
         }
     }
 
@@ -166,6 +179,7 @@ public class PlayState extends State{
         board.render(batch);
         renderHeroes(batch);
         renderProjectiles(batch);
+        renderMonsters(batch);
         batch.draw(menuButton.getImg(), menuButton.getPosition().x - menuButton.getWidth() / 2f, menuButton.getPosition().y, menuButton.getWidth(), menuButton.getHeight());
         batch.end();
 
diff --git a/core/src/com/mygdx/game/systems/WaveSystem.java b/core/src/com/mygdx/game/systems/WaveSystem.java
index d90174d..b525e64 100644
--- a/core/src/com/mygdx/game/systems/WaveSystem.java
+++ b/core/src/com/mygdx/game/systems/WaveSystem.java
@@ -5,12 +5,16 @@ import com.badlogic.ashley.core.Engine;
 import com.badlogic.ashley.core.Entity;
 import com.badlogic.ashley.core.Family;
 import com.badlogic.ashley.systems.IteratingSystem;
-import com.badlogic.gdx.utils.Array;
+import com.badlogic.gdx.math.Vector2;
 import com.mygdx.game.components.WaveComponent;
 import com.mygdx.game.entities.MonsterFactory;
+import com.mygdx.game.types.MonsterType;
+
+import java.util.Random;
 
 public class WaveSystem extends IteratingSystem {
     private ComponentMapper<WaveComponent> waveMapper;
+    private MonsterType[] monsterTypes;
     private Engine engine;
 
     public WaveSystem(Engine engine) {
@@ -18,6 +22,7 @@ public class WaveSystem extends IteratingSystem {
         waveMapper = ComponentMapper.getFor(WaveComponent.class);
         this.engine = engine;
         initializeWaveSystem();
+        monsterTypes = MonsterType.values();
         System.out.println("Wave 1 is starting in 5 seconds");
     }
 
@@ -39,16 +44,33 @@ public class WaveSystem extends IteratingSystem {
         //Activate the current wave
         if (wave.getWaveTimeElapsed() >= 5f && !wave.isActive()) {
             wave.setActive(true);
-            //System.out.println("Beginning wave " + wave.getWaveNumber());
+            System.out.println("Beginning wave " + wave.getWaveNumber());
+            spawnMonster(wave);
         }
 
         //Begin a new wave after the given time
-        if (wave.getWaveTimeElapsed() >= 10f) {
+        if (wave.getWaveTimeElapsed() >= 100f) {
             //System.out.println("Ending wave " + wave.getWaveNumber());
-            wave.setActive(false);
+            //wave.setActive(false);
             wave.setWaveNumber(wave.getWaveNumber() + 1);
             wave.setWaveTimeElapsed(0f);
             wave.setNumberOfMonsters(wave.getWaveNumber() + 2);
         }
+
+        //Spawn monsters every 25 seconds
+        if (wave.getTimeSinceLastSpawn() >= 25f && wave.isActive()) {
+            spawnMonster(wave);
+        }
+    }
+
+    private MonsterType getRandomType() {
+        Random rand = new Random();
+        return monsterTypes[rand.nextInt(monsterTypes.length)];
+    }
+
+    private void spawnMonster(WaveComponent wave) {
+        wave.setTimeSinceLastSpawn(0f);
+        Entity monster = MonsterFactory.createMonster(getRandomType(), new Vector2(1000f, 300f));
+        engine.addEntity(monster);
     }
 }
-- 
GitLab


From 97ddab3e54a34dca0b32b4d858176e945fd40cef Mon Sep 17 00:00:00 2001
From: Marcus Stephan Nordal <marcusn1301@gmail.com>
Date: Sat, 22 Apr 2023 17:59:54 +0200
Subject: [PATCH 21/23] collision system

---
 core/src/com/mygdx/game/entities/HeroFactory.java   | 10 +++++-----
 .../src/com/mygdx/game/entities/MonsterFactory.java | 13 ++++++++-----
 .../com/mygdx/game/entities/ProjectileFactory.java  |  2 +-
 core/src/com/mygdx/game/states/PlayState.java       |  3 +++
 .../src/com/mygdx/game/systems/CollisionSystem.java | 13 +++++++------
 core/src/com/mygdx/game/systems/HeroSystem.java     |  2 +-
 .../mygdx/game/systems/MonsterMovementSystem.java   |  5 +++++
 .../game/systems/ProjectileMovementSystem.java      |  2 ++
 core/src/com/mygdx/game/systems/WaveSystem.java     | 10 +++++++---
 9 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/core/src/com/mygdx/game/entities/HeroFactory.java b/core/src/com/mygdx/game/entities/HeroFactory.java
index e370840..60544d9 100644
--- a/core/src/com/mygdx/game/entities/HeroFactory.java
+++ b/core/src/com/mygdx/game/entities/HeroFactory.java
@@ -18,7 +18,7 @@ public class HeroFactory {
         Entity hero = new Entity();
         hero.add(new SpriteComponent(getHeroSprite(heroType)));
         hero.add(new PositionComponent(boardPosition));
-        hero.add(new AttackComponent(getHeroAttackDamage(heroType), getHeroAttackTimer(heroType), getHeroAttackTimeElapsed()));
+        hero.add(new AttackComponent(getHeroAttackTimer(heroType), getHeroAttackTimeElapsed(), getHeroAttackDamage(heroType)));
         hero.add(new HealthComponent(getHeroHealth()));
         hero.add(new HeroComponent(heroType));
         return hero;
@@ -112,13 +112,13 @@ public class HeroFactory {
     private static float getHeroAttackTimer(HeroType heroType) {
         switch (heroType) {
             case IRONMAN:
-                return 6f;
+                return 6.5f;
             case HULK:
-                return 8f;
+                return 9f;
             case SPIDERMAN:
-                return 5.5f;
+                return 6f;
             case THOR:
-                return 6.5f;
+                return 7.5f;
             case CAPTAIN_AMERICA:
                 return 7f;
             default:
diff --git a/core/src/com/mygdx/game/entities/MonsterFactory.java b/core/src/com/mygdx/game/entities/MonsterFactory.java
index 646c258..db7c946 100644
--- a/core/src/com/mygdx/game/entities/MonsterFactory.java
+++ b/core/src/com/mygdx/game/entities/MonsterFactory.java
@@ -3,8 +3,10 @@ package com.mygdx.game.entities;
 import com.badlogic.ashley.core.Entity;
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.math.Rectangle;
 import com.badlogic.gdx.math.Vector2;
 import com.mygdx.game.components.AttackComponent;
+import com.mygdx.game.components.CollisionComponent;
 import com.mygdx.game.components.MonsterComponent;
 import com.mygdx.game.components.MovementSpeedComponent;
 import com.mygdx.game.components.PositionComponent;
@@ -18,6 +20,7 @@ public class MonsterFactory {
         monster.add(new SpriteComponent(getMonsterSprite(monsterType)));
         monster.add(new PositionComponent(boardPosition));
         monster.add(new MonsterComponent(monsterType, getMonsterMovementSpeed(monsterType)));
+        monster.add(new CollisionComponent(new Rectangle(boardPosition.x, boardPosition.y, Gdx.graphics.getWidth()/30f, Gdx.graphics.getHeight()/30f)));
         return monster;
     }
 
@@ -44,19 +47,19 @@ public class MonsterFactory {
     private static float getMonsterMovementSpeed(MonsterType monsterType) {
         switch (monsterType) {
             case MAGNETO:
-                return 20f;
+                return 16f;
             case JUGGERNAUT:
-                return 30f;
+                return 13f;
             case VENOM:
-                return 30f;
+                return 14f;
             case HOBGOBLIN:
-                return 20f;
+                return 12f;
             case GOBLIN_GLIDER:
                 return 10f;
             case MYSTIQUE:
                 return 15f;
             default:
-                return 30f;
+                return 10f;
         }
     }
 
diff --git a/core/src/com/mygdx/game/entities/ProjectileFactory.java b/core/src/com/mygdx/game/entities/ProjectileFactory.java
index c38918f..f1e2c70 100644
--- a/core/src/com/mygdx/game/entities/ProjectileFactory.java
+++ b/core/src/com/mygdx/game/entities/ProjectileFactory.java
@@ -18,7 +18,7 @@ public class ProjectileFactory {
         Entity projectile = new Entity();
         projectile.add(new ProjectileComponent(true, getProjectileSpeed(heroType), sourceEntity));
         projectile.add(new SpriteComponent(getProjectileSprite(heroType)));
-        projectile.add(new CollisionComponent(new Rectangle(startingPosition.x, startingPosition.y, 10f, 10f)));
+        projectile.add(new CollisionComponent(new Rectangle(startingPosition.x, startingPosition.y, Gdx.graphics.getWidth()/30f, Gdx.graphics.getHeight()/30f)));
         projectile.add(new PositionComponent(startingPosition));
         return projectile;
     }
diff --git a/core/src/com/mygdx/game/states/PlayState.java b/core/src/com/mygdx/game/states/PlayState.java
index ce61a99..a6020a5 100644
--- a/core/src/com/mygdx/game/states/PlayState.java
+++ b/core/src/com/mygdx/game/states/PlayState.java
@@ -33,6 +33,7 @@ import com.mygdx.game.components.SpriteComponent;
 import com.mygdx.game.entities.DisplayHero;
 import com.mygdx.game.entities.HeroFactory;
 import com.mygdx.game.ds.buttons.RectangleButton;
+import com.mygdx.game.systems.CollisionSystem;
 import com.mygdx.game.systems.HeroSystem;
 import com.mygdx.game.systems.MonsterMovementSystem;
 import com.mygdx.game.systems.ProjectileMovementSystem;
@@ -83,11 +84,13 @@ public class PlayState extends State{
         ProjectileMovementSystem projectileMovementSystem = new ProjectileMovementSystem(engine);
         WaveSystem waveSystem = new WaveSystem(engine);
         MonsterMovementSystem monsterMovementSystem = new MonsterMovementSystem(engine);
+        CollisionSystem collisionSystem = new CollisionSystem(engine);
 
         engine.addSystem(heroSystem);
         engine.addSystem(projectileMovementSystem);
         engine.addSystem(waveSystem);
         engine.addSystem(monsterMovementSystem);
+        engine.addSystem(collisionSystem);
 
         /*Entity spiderman = HeroFactory.createHero(HeroType.SPIDERMAN, new Vector2(50, 50));
         Entity captain = HeroFactory.createHero(HeroType.CAPTAIN_AMERICA, new Vector2(50, 50));
diff --git a/core/src/com/mygdx/game/systems/CollisionSystem.java b/core/src/com/mygdx/game/systems/CollisionSystem.java
index 7e00ca3..496a978 100644
--- a/core/src/com/mygdx/game/systems/CollisionSystem.java
+++ b/core/src/com/mygdx/game/systems/CollisionSystem.java
@@ -25,7 +25,6 @@ public class CollisionSystem extends IteratingSystem {
 
     public CollisionSystem(Engine engine) {
         super(Family.all(PositionComponent.class, CollisionComponent.class).get());
-        healthMapper = ComponentMapper.getFor(HealthComponent.class);
         positionMapper = ComponentMapper.getFor(PositionComponent.class);
         collisionMapper = ComponentMapper.getFor(CollisionComponent.class);
         monsterMapper = ComponentMapper.getFor(MonsterComponent.class);
@@ -42,11 +41,13 @@ public class CollisionSystem extends IteratingSystem {
         //Check if projectile has collided with a monster
         // Check if the entity is a projectile
         if (projectileMapper.has(entity)) {
-            monsters = engine.getEntitiesFor(Family.all(MonsterComponent.class).get());
-
-            if (monsters.size() > 0) {
-                for (Entity monster : monsters) {
-                    //TODO
+            monsters = engine.getEntitiesFor(Family.all(MonsterComponent.class, CollisionComponent.class).get());
+            for (Entity monster : engine.getEntitiesFor(Family.all(MonsterComponent.class, CollisionComponent.class).get())) {
+                CollisionComponent monsterCollision = collisionMapper.get(monster);
+                if (collision.getHitbox().overlaps(monsterCollision.getHitbox())) {
+                    engine.removeEntity(entity);
+                    engine.removeEntity(monster);
+                    break;
                 }
             }
         }
diff --git a/core/src/com/mygdx/game/systems/HeroSystem.java b/core/src/com/mygdx/game/systems/HeroSystem.java
index 4600df1..cc64d2b 100644
--- a/core/src/com/mygdx/game/systems/HeroSystem.java
+++ b/core/src/com/mygdx/game/systems/HeroSystem.java
@@ -56,6 +56,6 @@ public class HeroSystem extends IteratingSystem {
         }
 
         //Increase the time elapsed field in the attack component on every update
-        attack.setAttackTimeElapsed(attack.getAttackTimeElapsed() + deltaTime * 5);
+        attack.setAttackTimeElapsed(attack.getAttackTimeElapsed() + deltaTime);
     }
 }
\ No newline at end of file
diff --git a/core/src/com/mygdx/game/systems/MonsterMovementSystem.java b/core/src/com/mygdx/game/systems/MonsterMovementSystem.java
index b454734..a6c0854 100644
--- a/core/src/com/mygdx/game/systems/MonsterMovementSystem.java
+++ b/core/src/com/mygdx/game/systems/MonsterMovementSystem.java
@@ -6,18 +6,21 @@ import com.badlogic.ashley.core.Entity;
 import com.badlogic.ashley.core.Family;
 import com.badlogic.ashley.systems.IteratingSystem;
 import com.badlogic.gdx.Gdx;
+import com.mygdx.game.components.CollisionComponent;
 import com.mygdx.game.components.MonsterComponent;
 import com.mygdx.game.components.PositionComponent;
 
 public class MonsterMovementSystem extends IteratingSystem {
     private ComponentMapper<MonsterComponent> monsterMapper;
     private ComponentMapper<PositionComponent> positionMapper;
+    private ComponentMapper<CollisionComponent> collisionMapper;
     private Engine engine;
 
     public MonsterMovementSystem(Engine engine) {
         super(Family.all(MonsterComponent.class, PositionComponent.class).get());
         monsterMapper = ComponentMapper.getFor(MonsterComponent.class);
         positionMapper = ComponentMapper.getFor(PositionComponent.class);
+        collisionMapper = ComponentMapper.getFor(CollisionComponent.class);
         this.engine = engine;
 
     }
@@ -26,9 +29,11 @@ public class MonsterMovementSystem extends IteratingSystem {
     protected void processEntity(Entity entity, float deltaTime) {
         MonsterComponent monster = monsterMapper.get(entity);
         PositionComponent monsterPos = positionMapper.get(entity);
+        CollisionComponent collision = collisionMapper.get(entity);
 
         //Make the monster move to the left
         monsterPos.setPosition(monsterPos.getPosition().add(monster.getMovementSpeed() * -1, 0));
+        collision.setHitbox(collision.getHitbox().setPosition(monsterPos.getPosition()));
 
         //Remove monsters that are out of bounds
         if (monsterPos.getPosition().x <= 0 + Gdx.graphics.getWidth() / 8) {
diff --git a/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java b/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
index 5a4f779..17b044b 100644
--- a/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
+++ b/core/src/com/mygdx/game/systems/ProjectileMovementSystem.java
@@ -40,7 +40,9 @@ public class ProjectileMovementSystem extends IteratingSystem {
         }
 
         //Increment the horizontal position of the projectile based on its velocity
+        //and update hitbox position
         float speed = projectileComponent.getVelocity();
         positionComponent.setPosition(positionComponent.getPosition().add(speed, 0));
+        collisionComponent.setHitbox(collisionComponent.getHitbox().setPosition(positionComponent.getPosition()));
     }
 }
diff --git a/core/src/com/mygdx/game/systems/WaveSystem.java b/core/src/com/mygdx/game/systems/WaveSystem.java
index b525e64..56c59c4 100644
--- a/core/src/com/mygdx/game/systems/WaveSystem.java
+++ b/core/src/com/mygdx/game/systems/WaveSystem.java
@@ -40,12 +40,14 @@ public class WaveSystem extends IteratingSystem {
 
         //Wave duration is incremented
         wave.setWaveTimeElapsed(wave.getWaveTimeElapsed() + deltaTime);
+        wave.setTimeSinceLastSpawn(wave.getTimeSinceLastSpawn() + deltaTime);
 
         //Activate the current wave
         if (wave.getWaveTimeElapsed() >= 5f && !wave.isActive()) {
             wave.setActive(true);
             System.out.println("Beginning wave " + wave.getWaveNumber());
             spawnMonster(wave);
+            wave.setTimeSinceLastSpawn(0f);
         }
 
         //Begin a new wave after the given time
@@ -57,9 +59,10 @@ public class WaveSystem extends IteratingSystem {
             wave.setNumberOfMonsters(wave.getWaveNumber() + 2);
         }
 
-        //Spawn monsters every 25 seconds
-        if (wave.getTimeSinceLastSpawn() >= 25f && wave.isActive()) {
+        //Spawn monsters every 10 seconds
+        if (wave.getTimeSinceLastSpawn() >= 5f && wave.isActive()) {
             spawnMonster(wave);
+            wave.setTimeSinceLastSpawn(0f);
         }
     }
 
@@ -70,7 +73,8 @@ public class WaveSystem extends IteratingSystem {
 
     private void spawnMonster(WaveComponent wave) {
         wave.setTimeSinceLastSpawn(0f);
-        Entity monster = MonsterFactory.createMonster(getRandomType(), new Vector2(1000f, 300f));
+        //TODO monster should not be placed inside a cell
+        Entity monster = MonsterFactory.createMonster(getRandomType(), new Vector2(1500f, 350f));
         engine.addEntity(monster);
     }
 }
-- 
GitLab


From da63d92192612cafdb10dd6e7788f96196a4e103 Mon Sep 17 00:00:00 2001
From: Anh <qapham@stud.ntnu.no>
Date: Sat, 22 Apr 2023 19:01:23 +0200
Subject: [PATCH 22/23] Add 8 bit trophy images

---
 assets/Trophy_2.png | Bin 0 -> 4611 bytes
 assets/Trophy_3.png | Bin 0 -> 4622 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 assets/Trophy_2.png
 create mode 100644 assets/Trophy_3.png

diff --git a/assets/Trophy_2.png b/assets/Trophy_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..d49a7efac7199c63e171fad8b85635ae346a3298
GIT binary patch
literal 4611
zcmeHLX;c$g77n{W6ZN>z0)ZYIFn|&_*2to^Ferj7VTnf44JDg`v@=CSWF4hd2m>S_
zVT*u*Nu)y|rZskeR)!{N7Dbd&BPa^pS}Y2($l|<$WB-}?F>}uJcFz3B$*EU$-@Es_
z_kQ24I<wEqT~EhAhd?0cdHne^Ujjje3Vy^TnqXxjT8x4}m1Dl{I|w!HMn4e<%fI#b
zY`Z_};81aGyIJ!Zjgj4>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of1YXz8#6Oho07CHt7~X!fZw~+Q7mit~UP*+ovd4Ql_^Lzj*yZ(E%?@VT
FKLJ*g;P(Ik

literal 0
HcmV?d00001

diff --git a/assets/Trophy_3.png b/assets/Trophy_3.png
new file mode 100644
index 0000000000000000000000000000000000000000..bb8db961327c59c4185c21e0f62626c8ec18c49a
GIT binary patch
literal 4622
zcmeHLX;c&E8V;MFTmlv}EhKVUE4yH+Yy|;DKo(g737dhmIDm?@$n8K`103sB1dc!q
zVgxFC0+dcrN`ny88VwC%*&G2;QP9f>SoSsd8#wk?f41J+bMB9voXpJoeee6c-}^kz
z<gAaEtJ)UrEd&BV&F#=ZDuEzp3qC}ZP2kGhi3SvW$;DA!4-o1*$*%~6t#{oH?)Og!
zea-zry31MHdH9fqoSX*XX3*ysZUx_F^?fL(!a7WdbpA)+bJpp;{fdr+gM{~t_uP3{
za-lP&Nmjr1Q|F_mP}-G{udjcbo;p31RwzoEOq)?A>J*4JE2hd`k6Gz^#$_2QZtJPW
z<O5y2KP<(pBOr0mz5)iJ<E5cu0YzMkSsO#72J=Ls93-|ew(WFBm1@ryJ2|4Uost{@
z6_ztD8`JQCxdLRQwtyj$ytDyfWA8Ss#S_+)l`T!mR@J@cWO*g2YtruUc%6k?O<~ye
z7gh7i_swL>GY@GB0h@zSrEFs%fxeXnlZ)|`DUq{2uw3m&Jj~h-ly10DVNo?QG6U{a
zY?OceswAh|59YErisYR&vi0&tW9b_R@by6OzW-`44LM=o-Lv94o1A2pFMS$#Z8V}S
z=Z01K*|FxJxan^UAkv@`L=u@NZb^3`^E=}N5fF*Y-!#L!wKe+w%Lqli;;{&+#MJtU
zS`<WLS%Sy#NCBdnLsI~dm1Y+oU_SdMrmq&u2=8UlVY#TXDviQ~;>#As!Y6?irECV_
z5jZe!m!bdfEW^g=DU~(olwsA&FZGTcoqshpY<DBNZE|k!PXp?MuXk81r<7p}Dc}UN
z@5QO?<;b|(TDcX?uF_OCqbtEL&rC>Y^z|%lUP;Ky%#`jsKF7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te14!L9dfLT1Zg*9-p)r
zLpi8POLk2^0Pdd<_d<#Vj5{azjmQ9RV&F?UI@J1X%&HnIjvTu?zSRfrAAfFcOocf$
zH&2rt9Z?G5O})c+*u*2Oc$o?(&E>##n1-H{lZt`xL+84{N+e|ekWE+?3rX6ISS>K1
z_{{f)Zie7l{6Ck!6)xqLI<efw+obN~RaDvAd-aXJuKm8bD&4ei60x_IDNXh|a`Nfs
zsnf~w&mF3KU~=PMKIrd=T~eCM7mrXIZabApBa4WPLsQ||2ARi**_I_0zfJqJY{6eO
zg{)p4Aa3WirD?$HWuv)QTfqy0vp>3RD#qR)RZ;@-_l~Ij&s7!bP9amf>^+g<%56;-
z@NUkf&7Q5=xKcoI0q%--2Jv8C+IJdw!on2X^#SuXLk9LPj*c5R;KTNv0r$ATNCJ02
tce#)Mtr59_8T&z;3J{o}cN(^sc1Rk<515y&fj@W%Zq8l@>klw9{sS4r<C_2g

literal 0
HcmV?d00001

-- 
GitLab


From 9633eb9d7b6183da4724a04a864a1fe2f4c87e5e Mon Sep 17 00:00:00 2001
From: Anh <qapham@stud.ntnu.no>
Date: Sat, 22 Apr 2023 19:19:24 +0200
Subject: [PATCH 23/23] Fix bugs

---
 core/src/com/mygdx/game/ds/Board.java         | 12 +++-
 core/src/com/mygdx/game/states/PlayState.java | 70 +++++++++----------
 2 files changed, 44 insertions(+), 38 deletions(-)

diff --git a/core/src/com/mygdx/game/ds/Board.java b/core/src/com/mygdx/game/ds/Board.java
index 733fd13..0d3bd84 100644
--- a/core/src/com/mygdx/game/ds/Board.java
+++ b/core/src/com/mygdx/game/ds/Board.java
@@ -41,7 +41,7 @@ public class Board extends Actor {
     private final int[][] cells;
     private Texture[][] textures;
     private final ShapeRenderer shapeRenderer;
-    private final int textureWidth;
+
     private final int textureHeight;
     private int cellWidth;
     private int cellHeight;
@@ -129,6 +129,16 @@ public class Board extends Actor {
         return cols;
     }
 
+    public int getTextureWidth() {
+        return textureWidth;
+    }
+
+    private final int textureWidth;
+
+    public int getTextureHeight() {
+        return textureHeight;
+    }
+
     public Texture[][] getTextures() {
         return textures;
     }
diff --git a/core/src/com/mygdx/game/states/PlayState.java b/core/src/com/mygdx/game/states/PlayState.java
index dd564ff..abf3534 100644
--- a/core/src/com/mygdx/game/states/PlayState.java
+++ b/core/src/com/mygdx/game/states/PlayState.java
@@ -1,47 +1,53 @@
 package com.mygdx.game.states;
 
+import com.badlogic.ashley.core.ComponentMapper;
 import com.badlogic.ashley.core.Engine;
+import com.badlogic.ashley.core.Entity;
+import com.badlogic.ashley.core.Family;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 
 import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.GL20;
+import com.badlogic.gdx.graphics.Pixmap;
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.graphics.g2d.BitmapFont;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
+import com.badlogic.gdx.math.Vector2;
+import com.badlogic.gdx.scenes.scene2d.InputEvent;
 import com.badlogic.gdx.scenes.scene2d.Stage;
 
 import com.badlogic.gdx.scenes.scene2d.ui.Image;
+import com.badlogic.gdx.scenes.scene2d.ui.Table;
 import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
 import com.badlogic.gdx.utils.viewport.ScreenViewport;
-import com.mygdx.game.ds.Board;
 import com.mygdx.game.MoneySystem;
 import com.mygdx.game.SoundManager;
 import com.mygdx.game.components.AttackComponent;
 import com.mygdx.game.components.HeroComponent;
-import com.mygdx.game.components.MonsterComponent;
 import com.mygdx.game.components.PositionComponent;
 import com.mygdx.game.components.ProjectileComponent;
 import com.mygdx.game.components.SpriteComponent;
+import com.mygdx.game.ds.Board;
 import com.mygdx.game.entities.DisplayHero;
 import com.mygdx.game.entities.HeroFactory;
 import com.mygdx.game.ds.buttons.RectangleButton;
-import com.mygdx.game.systems.CollisionSystem;
 import com.mygdx.game.systems.HeroSystem;
-import com.mygdx.game.systems.MonsterMovementSystem;
 import com.mygdx.game.systems.ProjectileMovementSystem;
-import com.mygdx.game.systems.WaveSystem;
 import com.mygdx.game.types.HeroType;
 import com.mygdx.game.utils.Enums;
 
-public class PlayState extends State {
+import java.util.ArrayList;
+import java.util.List;
+
+public class PlayState extends State{
     private SpriteBatch batch;
     private BitmapFont font;
     private Stage stage;
     private ShapeRenderer shapeRenderer;
-    private final MoneySystem moneySystem;
-    private final boolean isPlacementAllowed = false;
-    private final SoundManager soundManager = SoundManager.getInstance();
-
+    private SoundManager soundManager = SoundManager.getInstance();
+    private MoneySystem moneySystem;
+    private boolean isPlacementAllowed = false;
     private static Engine engine;
     private Board board;
     private TextButton counterText1;
@@ -49,15 +55,20 @@ public class PlayState extends State {
     private final GameStateManager gsm;
 
     public PlayState() {
+        //super(gsm);
         menuButton = new RectangleButton(0.5f, Gdx.graphics.getWidth() - 137, Gdx.graphics.getHeight() - 100, "Lobby-button.png");
         gsm = GameStateManager.getGsm();
-        batch = new SpriteBatch();
-        moneySystem = new MoneySystem(4000);
-        soundManager.playSequence();
+        initialize();
+    }
 
+    private void initialize() {
         initializeGameEngine();
+        batch = new SpriteBatch();
+        moneySystem = new MoneySystem(4000);
         initFontStageAndRenderer();
         createBoard();
+        soundManager.playSequence();
+        //Game engine & systems
     }
 
     private void initializeGameEngine() {
@@ -67,15 +78,9 @@ public class PlayState extends State {
         //Systems for game logic
         HeroSystem heroSystem = new HeroSystem(engine);
         ProjectileMovementSystem projectileMovementSystem = new ProjectileMovementSystem(engine);
-        WaveSystem waveSystem = new WaveSystem(engine);
-        MonsterMovementSystem monsterMovementSystem = new MonsterMovementSystem(engine);
-        CollisionSystem collisionSystem = new CollisionSystem(engine);
 
         engine.addSystem(heroSystem);
         engine.addSystem(projectileMovementSystem);
-        engine.addSystem(waveSystem);
-        engine.addSystem(monsterMovementSystem);
-        engine.addSystem(collisionSystem);
 
         /*Entity spiderman = HeroFactory.createHero(HeroType.SPIDERMAN, new Vector2(50, 50));
         Entity captain = HeroFactory.createHero(HeroType.CAPTAIN_AMERICA, new Vector2(50, 50));
@@ -97,12 +102,12 @@ public class PlayState extends State {
 
     @Override
     public void update(float dt) {
+        stage.draw();
         engine.update(dt);
-        handleInput();
     }
 
     public void calculateMoney() {
-        float iconSize = Gdx.graphics.getWidth() / 30f;
+        float iconSize = Gdx.graphics.getWidth() / 30;
         BitmapFont counterFont = new BitmapFont();
         counterFont.getData().setScale(4);
         // First counter
@@ -112,7 +117,7 @@ public class PlayState extends State {
         counterText1.setHeight(iconSize / 2);
         board.getRightTable().add(counterText1);
 
-        Texture counterIconTexture1 = new Texture("coin.png");
+        Texture counterIconTexture1 = new Texture("coin2.png");
         Image counterIcon1 = new Image(counterIconTexture1);
         board.getRightTable().add(counterIcon1).size(iconSize, iconSize).pad(5);
         board.getRightTable().row();
@@ -124,7 +129,7 @@ public class PlayState extends State {
         counterText2.setHeight(iconSize / 2);
         board.getRightTable().add(counterText2);
 
-        Texture counterIconTexture2 = new Texture("coin.png");
+        Texture counterIconTexture2 = new Texture("coin2.png");
         Image counterIcon2 = new Image(counterIconTexture2);
         board.getRightTable().add(counterIcon2).size(iconSize, iconSize).pad(5);
         board.getRightTable().row();
@@ -132,28 +137,19 @@ public class PlayState extends State {
 
     public void renderHeroes(SpriteBatch batch) {
         for (Entity e : engine.getEntitiesFor(Family.all(HeroComponent.class, AttackComponent.class).get())) {
-            Texture texture = e.getComponent(SpriteComponent.class).getSprite();
+            Texture sprite = e.getComponent(SpriteComponent.class).getSprite();
             Vector2 position = e.getComponent(PositionComponent.class).getPosition();
 
-            batch.draw(texture, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
+            batch.draw(sprite, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
         }
     }
 
     public void renderProjectiles(SpriteBatch batch) {
         for (Entity e : engine.getEntitiesFor(Family.all(ProjectileComponent.class, PositionComponent.class).get())) {
-            Texture texture = e.getComponent(SpriteComponent.class).getSprite();
+            Texture sprite = e.getComponent(SpriteComponent.class).getSprite();
             Vector2 position = e.getComponent(PositionComponent.class).getPosition();
 
-            batch.draw(texture, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
-        }
-    }
-
-    public void renderMonsters(SpriteBatch batch) {
-        for (Entity e : engine.getEntitiesFor(Family.all(MonsterComponent.class, PositionComponent.class).get())) {
-            Texture texture = e.getComponent(SpriteComponent.class).getSprite();
-            Vector2 position = e.getComponent(PositionComponent.class).getPosition();
-
-            batch.draw(texture, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
+            batch.draw(sprite, position.x, position.y, (float) board.getTextureWidth(), (float) board.getTextureHeight());
         }
     }
 
@@ -167,10 +163,10 @@ public class PlayState extends State {
         board.render(batch);
         renderHeroes(batch);
         renderProjectiles(batch);
-        renderMonsters(batch);
         batch.draw(menuButton.getImg(), menuButton.getPosition().x - menuButton.getWidth() / 2f, menuButton.getPosition().y, menuButton.getWidth(), menuButton.getHeight());
         batch.end();
 
+
         stage.act(Gdx.graphics.getDeltaTime());
         stage.draw();
     }
-- 
GitLab