diff --git a/CHANGELOG b/CHANGELOG deleted file mode 100644 index 8b137891791fe96927ad78e64b0aad7bded08bdc..0000000000000000000000000000000000000000 --- a/CHANGELOG +++ /dev/null @@ -1 +0,0 @@ - diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..d259abe54736dbb6cefa66fcecb72b757a599991 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog + +## [Unreleased] + +### Added +- + +### Fixed +- + +### Changed +- + + +### Removed +- + +##[v.v.v] - dd.mm.yyyy + +### Added diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/ButtonTransition.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/ButtonTransition.java new file mode 100644 index 0000000000000000000000000000000000000000..2af6c6d63c35c91301dfd68eab22027ced9fdcbc --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/ButtonTransition.java @@ -0,0 +1,29 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.animation.ScaleTransition; +import javafx.scene.control.Button; +import javafx.scene.control.skin.ButtonSkin; +import javafx.util.Duration; + +public class ButtonTransition extends ButtonSkin { + public ButtonTransition(Button button) { + super(button); +// set transition for mouse hovering over button + final ScaleTransition fadeIn = new ScaleTransition(Duration.millis(150)); + fadeIn.setNode(button); + fadeIn.setToX(1.1); + fadeIn.setToY(1.1); + button.setOnMouseEntered(e -> fadeIn.playFromStart()); + +// set transition for mouse exiting buttonButtonTransitionScale + final ScaleTransition fadeOut = new ScaleTransition(Duration.millis(150)); + fadeOut.setNode(button); + fadeOut.setToX(1.0); + fadeOut.setToY(1.0); + button.setOnMouseExited(e -> fadeOut.playFromStart()); + + button.setScaleX(1.0); + button.setScaleY(1.0); + } +} + diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreateMediaPlayer.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreateMediaPlayer.java new file mode 100644 index 0000000000000000000000000000000000000000..03fbd835e1a457c5f9ad0fdd649d747840a240fd --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreateMediaPlayer.java @@ -0,0 +1,23 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.scene.layout.BorderPane; +import javafx.scene.media.Media; +import javafx.scene.media.MediaPlayer; +import javafx.scene.media.MediaView; + +import java.io.File; + +public class CreateMediaPlayer { + public MediaPlayer getMediaPlayer(MediaView mediaView, File file, BorderPane parent) { + Media media = new Media(file.toURI().toString()); + MediaPlayer mediaPlayer = new MediaPlayer(media); + +// resizing once the scenes has been loaded to get width and height property + mediaPlayer.setOnReady(() -> { + mediaView.fitWidthProperty().bind(parent.getScene().widthProperty()); + mediaView.fitHeightProperty().bind(parent.getScene().heightProperty()); + }); + mediaPlayer.setAutoPlay(true); + return mediaPlayer; + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreditsController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreditsController.java new file mode 100644 index 0000000000000000000000000000000000000000..a6e47b9d714df5d509ec60ac27bd6ac89029fa5f --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreditsController.java @@ -0,0 +1,52 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Cursor; +import javafx.scene.layout.BorderPane; +import javafx.scene.media.MediaPlayer; +import javafx.scene.media.MediaView; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.Objects; +import java.util.ResourceBundle; + +public class CreditsController implements Initializable { + @FXML + public BorderPane parent; + @FXML + public MediaView mediaView; + private MediaPlayer mediaPlayer; + private final File file = new File("src/main/resources/videos/credits.mp4"); + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + parent.setStyle("-fx-background-color: black;"); + parent.setCursor(Cursor.NONE); + createMediaPlayer(); + MusicPlayerSingleton.getInstance().getMediaPlayer().dispose(); + } + + private void createMediaPlayer() { + mediaPlayer = new CreateMediaPlayer().getMediaPlayer(mediaView, file, parent); + mediaView.setMediaPlayer(mediaPlayer); + + mediaPlayer.setOnEndOfMedia(this::videoEnd); + + parent.setOnMouseClicked(mouseEvent -> videoEnd()); + } + + private void videoEnd() { + try { +// I don't know how to return to the options scene, so it just goes back to the main menu :( + mediaPlayer.dispose(); + parent.getChildren().clear(); + parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); + } catch (IOException e) { + throw new RuntimeException(); + } + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java index 2e458da47f8bfdd16359a1c95f37a80cc0adec93..2d90bb00e2c3503261084d7acf6b1dfd98593c61 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java @@ -1,9 +1,111 @@ package de.hdm_stuttgart.battlearena.Controller; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityFactory; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityType; +import de.hdm_stuttgart.battlearena.Model.Entity.IEntity; +import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; +import de.hdm_stuttgart.battlearena.Model.Map.TileManager; + +import javafx.animation.AnimationTimer; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.canvas.Canvas; +import javafx.scene.canvas.GraphicsContext; + import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -public class GameSceneController { +import java.net.URL; +import java.util.ResourceBundle; + +public class GameSceneController implements Initializable { + private static final Logger log = LogManager.getLogger(GameSceneController.class); + @FXML + private Canvas canvas2D; + + private GraphicsContext graphicsContext2D; + + InputHandler inputHandler = InputHandler.getInstance(); + + IEntity player; + IEntity enemy; + + EntityClass playerClass = EntityClass.HUMAN; + EntityClass enemyClass = EntityClass.HUMAN; + + TileManager tileManager; + + //map data + String mapString = "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 " + + "4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + + "4 2 1 1 1 1 1 2 2 2 1 1 1 1 2 1 1 3 " + + "4 1 1 1 2 2 4 3 3 1 4 3 3 3 3 2 2 3 " + + "4 1 1 1 2 2 4 1 1 1 1 1 1 1 3 1 2 3 " + + "4 1 1 1 2 2 4 1 3 3 3 1 1 1 3 2 2 3 " + + "4 1 1 1 2 2 4 1 1 1 1 1 1 1 3 2 1 3 " + + "4 1 1 1 2 2 4 3 3 1 4 3 3 3 3 2 1 3 " + + "4 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + + "4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 1 3 " + + "4 1 1 1 1 2 4 3 3 1 3 3 3 3 3 1 1 3 " + + "4 1 1 1 1 2 4 3 3 1 3 3 3 3 3 2 2 3 " + + "4 1 1 1 1 1 4 3 3 1 3 3 3 3 3 1 2 3 " + + "4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + + "4 1 1 2 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + + "4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 " + + "4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 " + + "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3"; + int horizontalTileCount = 18; + int verticalTileCount = 18; + int diffTileCount = 5; + int scaledTileSize = 48; + + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + graphicsContext2D = canvas2D.getGraphicsContext2D(); + graphicsContext2D.setImageSmoothing(false); + + player = EntityFactory.createEntity(EntityType.PLAYER, graphicsContext2D, inputHandler, playerClass, this); + enemy = EntityFactory.createEntity(EntityType.ENEMY_PLAYER, graphicsContext2D, inputHandler, enemyClass, this); + + tileManager = new TileManager(graphicsContext2D, diffTileCount, horizontalTileCount, verticalTileCount, mapString); + + AnimationTimer gameLoop = new AnimationTimer() { + @Override + public void handle(long l) { + graphicsContext2D.clearRect(0, 0, canvas2D.getWidth(), canvas2D.getHeight()); + renderContent(graphicsContext2D); + updateContent(); + } + }; + gameLoop.start(); + log.debug("Game loop started"); + } + + private void updateContent() { + player.updateEntityMovement(this); + enemy.updateEntityMovement(this); + player.attack(enemy, graphicsContext2D); + } + + private void renderContent(GraphicsContext graphicsContext) { + tileManager.renderMap(); + player.renderEntity(graphicsContext); + enemy.renderEntity(graphicsContext); + } + + public IEntity getEnemy() { + return enemy; + } + + public TileManager getTileManager() { + return tileManager; + } + + public int getScaledTileSize() { + return scaledTileSize; + } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java new file mode 100644 index 0000000000000000000000000000000000000000..7a77864cb6349989b9ee99f84e56f98932683146 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java @@ -0,0 +1,75 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Cursor; +import javafx.scene.layout.BorderPane; +import javafx.scene.media.MediaPlayer; +import javafx.scene.media.MediaView; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.Objects; +import java.util.ResourceBundle; + +public class IntroController implements Initializable { + + @FXML + public MediaView mediaView; + @FXML + public BorderPane introParent; + private final String fileName = "src/main/resources/videos/"; + // nextVideo() will iterate through this array so the next video will be played TODO: change the videos to non memes lmao + private final String[] videos = {"sony.mp4", "gamecube.mp4", "gameboy.mp4", "monke.mp4"}; + private File file = new File(fileName + videos[0]); + private int counter = 0; + private MediaPlayer mediaPlayer; + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + introParent.setStyle("-fx-background-color: black;"); + introParent.setCursor(Cursor.NONE); + createMediaPlayer(); + } + + private void createMediaPlayer() { +// initializing this.mediaPlayer + mediaPlayer = new CreateMediaPlayer().getMediaPlayer(mediaView, file, introParent); + mediaView.setMediaPlayer(mediaPlayer); + + mediaPlayer.setOnEndOfMedia(() -> { + if (counter == videos.length - 1) { + videoEnd(); + } else { + nextVideo(); + } + }); + +// TODO: make any button pressed work + introParent.setOnMouseClicked((mouseEvent) -> { + if (counter == videos.length - 1) { + videoEnd(); + } else { + nextVideo(); + } + }); + } + + private void videoEnd() { + try { + mediaPlayer.dispose(); + introParent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); + } catch (IOException e) { + throw new RuntimeException(); + } + } + + private void nextVideo() { + mediaPlayer.dispose(); + file = new File(fileName + videos[counter + 1]); + counter++; + createMediaPlayer(); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/LocalCreateController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LocalCreateController.java new file mode 100644 index 0000000000000000000000000000000000000000..12f6d654caa5d116dbb0d6be8fcf8b03d25747f8 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LocalCreateController.java @@ -0,0 +1,23 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.layout.VBox; + +import java.io.IOException; +import java.util.Objects; + +public class LocalCreateController { + @FXML public VBox parent; + private final SceneLoader sceneLoader = new SceneLoader(); + + public void playScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("Play")); + } + + public void skinSelectionScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("SkinSelection")); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MainMenuController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MainMenuController.java index 4fa73f1d596e95461bfb44775fdb526efc4377f3..5a8c9dea297cc86f74b13911c31a9318d66f6178 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MainMenuController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MainMenuController.java @@ -1,4 +1,38 @@ package de.hdm_stuttgart.battlearena.Controller; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; + public class MainMenuController { + @FXML + public VBox parent; + @FXML + public Button exitButton; + private final SceneLoader sceneLoader = new SceneLoader(); + + private void switchScene(String name) { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene(name)); + } + public void playScene() { + switchScene("Play"); + } + + public void statisticsScene() { + switchScene("Statistics"); + } + + public void optionsScene() { + switchScene("Options"); + } + + public void exit() { + Stage stage = (Stage) exitButton.getScene().getWindow(); + stage.close(); + } + + +// TODO: create skin selection scene } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java new file mode 100644 index 0000000000000000000000000000000000000000..6f980d5271853b580f31e74f3b3cac3ea1a9758d --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java @@ -0,0 +1,68 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.geometry.Rectangle2D; +import javafx.scene.control.Button; +import javafx.scene.image.ImageView; +import javafx.scene.layout.BorderPane; +import javafx.scene.media.Media; +import javafx.scene.media.MediaPlayer; +import javafx.scene.media.MediaView; +import javafx.stage.Screen; + +import java.io.File; +import java.net.URL; +import java.util.ResourceBundle; + +public class MenuBorderPaneController implements Initializable { + // TODO: change FXML variables to private. Don't know why it's not working when they're private + @FXML + public BorderPane parent; + @FXML + public Button btnRight; + @FXML + public ImageView imgLeft, imgRight; + private int counter = 1; + private final SceneLoader sceneLoader = new SceneLoader(); + MediaPlayer musicPlayer; + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + parent.setCenter(sceneLoader.loadScene("MainMenu")); +// set size for rusty gear image depending on screen resolution + Rectangle2D screen = Screen.getPrimary().getVisualBounds(); + final double imageWidth = screen.getWidth() / 6; + imgRight.setFitWidth(imageWidth); + imgRight.setPreserveRatio(true); + imgLeft.setFitWidth(imageWidth); + imgLeft.setPreserveRatio(true); + backgroundMusic("cocBackgroundMusicTest.mp3"); + } + + public void easterEgg() { + btnRight.setOnMouseClicked(mouseEvent -> counter++); + switch (counter) { + case 5: + musicPlayer.dispose(); + backgroundMusic("spongeBob.mp3"); + break; + case 12: + musicPlayer.dispose(); + backgroundMusic("stadiumRave.mp3"); + break; + case 20: + musicPlayer.dispose(); + backgroundMusic("wii.mp3"); + break; + } + } + + private void backgroundMusic(String file) { + Media media = new Media(new File("src/main/resources/sound/music/" + file).toURI().toString()); + musicPlayer = new MediaPlayer(media); + musicPlayer.setCycleCount(MediaPlayer.INDEFINITE); + musicPlayer.play(); + MusicPlayerSingleton.getInstance().setMediaPlayer(musicPlayer); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MultiplayerController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MultiplayerController.java new file mode 100644 index 0000000000000000000000000000000000000000..c0398758ef90f8af93860a24e7706c04f3293035 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MultiplayerController.java @@ -0,0 +1,24 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.scene.layout.VBox; + +public class MultiplayerController { + @FXML public VBox parent; + private final SceneLoader sceneLoader = new SceneLoader(); + + public void multiplayerCreateScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("MultiplayerCreate")); + } + + public void multiplayerJoinScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("MultiplayerJoin")); + } + + public void playScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("Play")); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MultiplayerCreateController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MultiplayerCreateController.java new file mode 100644 index 0000000000000000000000000000000000000000..3791d1b65442c4156ceed67abdabcd15d0459d64 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MultiplayerCreateController.java @@ -0,0 +1,14 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.scene.layout.VBox; + +public class MultiplayerCreateController { + @FXML public VBox parent; + private final SceneLoader sceneLoader = new SceneLoader(); + + public void multiplayerScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("Multiplayer")); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MultiplayerJoinController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MultiplayerJoinController.java new file mode 100644 index 0000000000000000000000000000000000000000..e6acf0f92a50714ee0e1a152a24ea0b6999ada31 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MultiplayerJoinController.java @@ -0,0 +1,14 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.scene.layout.VBox; + +public class MultiplayerJoinController { + @FXML public VBox parent; + private final SceneLoader sceneLoader = new SceneLoader(); + + public void multiplayerScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("Multiplayer")); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MusicPlayerSingleton.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MusicPlayerSingleton.java new file mode 100644 index 0000000000000000000000000000000000000000..5653a7c8cbca3e0278568d08fcda7dc7e1712c17 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MusicPlayerSingleton.java @@ -0,0 +1,23 @@ +package de.hdm_stuttgart.battlearena.Controller; +import javafx.scene.media.MediaPlayer; + +public class MusicPlayerSingleton { +// creating a singleton, so it can be stopped from other controller classes + private static final MusicPlayerSingleton instance = new MusicPlayerSingleton(); + private MediaPlayer mediaPlayer; + + private MusicPlayerSingleton() {} + + public static MusicPlayerSingleton getInstance() { + return instance; + } + + public MediaPlayer getMediaPlayer() { + return mediaPlayer; + } + + public void setMediaPlayer(MediaPlayer mediaPlayer) { + this.mediaPlayer = mediaPlayer; + } +} + diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/OptionsController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/OptionsController.java new file mode 100644 index 0000000000000000000000000000000000000000..6cba2a46980f3f81abb00e59b69bb6b4666104f4 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/OptionsController.java @@ -0,0 +1,45 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.control.Slider; +import javafx.scene.layout.VBox; + +import java.io.IOException; +import java.net.URL; +import java.util.Objects; +import java.util.ResourceBundle; + +public class OptionsController implements Initializable { + @FXML public VBox parent; + @FXML public Slider volumeSlider; + SceneLoader sceneLoader = new SceneLoader(); + public double volume; + MusicPlayerSingleton musicPlayer = MusicPlayerSingleton.getInstance(); + + public void creditScene() throws IOException { + parent.getChildren().clear(); + parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/credits.fxml")))); + } + + public void mainMenuScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("MainMenu")); + } + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + setVolume(); + } + + private void setVolume() { +// need a runtime database to save volume + volumeSlider.valueProperty().addListener((observableValue, oldValue, newValue) -> { + musicPlayer.getMediaPlayer().setVolume(volume); + volume = newValue.doubleValue() / 100; + musicPlayer.getMediaPlayer().setVolume(volume); + System.out.println(volume); + }); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayController.java new file mode 100644 index 0000000000000000000000000000000000000000..0b094a0e03c9fcf123fca334bd59b96f09bd719c --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayController.java @@ -0,0 +1,24 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.scene.layout.VBox; + +public class PlayController { + @FXML public VBox parent; + private final SceneLoader sceneLoader = new SceneLoader(); + + public void mainMenuScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("MainMenu")); + } + + public void localScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("LocalCreate")); + } + + public void multiplayerScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("Multiplayer")); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java new file mode 100644 index 0000000000000000000000000000000000000000..531d6229fdfc5b15342a14f662977cecff1d4f2e --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java @@ -0,0 +1,44 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.control.ToggleButton; +import javafx.scene.control.ToggleGroup; +import javafx.scene.layout.VBox; + +import java.io.IOException; +import java.net.URL; +import java.util.Objects; +import java.util.ResourceBundle; + +public class SkinSelectionController implements Initializable { + @FXML public VBox parent; + @FXML public ToggleGroup selectionButton; + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + selectionButton.selectedToggleProperty().addListener((observableValue, oldToggle, newToggle) -> { + if (selectionButton.getSelectedToggle() != null) { + ToggleButton selected = (ToggleButton) selectionButton.getSelectedToggle(); + String value = selected.getText(); + System.out.println(value); + } + }); + + } + + public void gameScene() { + try { + MusicPlayerSingleton.getInstance().getMediaPlayer().dispose(); + parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/GameScene.fxml")))); + } catch (IOException e) { + throw new RuntimeException(); + } + } + + public void back() { + parent.getChildren().clear(); + parent.getChildren().add(new SceneLoader().loadScene("LocalCreate")); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/StatisticsController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/StatisticsController.java new file mode 100644 index 0000000000000000000000000000000000000000..f591bfa15ef9a643f91fe59dc3c8c3482b085e8a --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/StatisticsController.java @@ -0,0 +1,63 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.beans.binding.Bindings; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.chart.PieChart; +import javafx.scene.layout.VBox; +import javafx.scene.text.Text; + +import java.net.URL; +import java.util.ResourceBundle; + +public class StatisticsController implements Initializable { + + @FXML public Text blocks, deaths, gameTime, gamesLost, gamesWon, kills; + @FXML public VBox parent; + @FXML public PieChart kd, wl; + SceneLoader sceneLoader = new SceneLoader(); + + public void mainMenuScene() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("MainMenu")); + } + + public void initialize(URL url, ResourceBundle resourceBundle){ + iniPieChartkd(); + iniPieChartwl(); + } + + public void iniPieChartkd() { + ObservableList<PieChart.Data> pieChartData = + FXCollections.observableArrayList( + new PieChart.Data("Kills",20), + new PieChart.Data("Deaths",12)); + + pieChartData.forEach(data -> + data.nameProperty().bind( + Bindings.concat( + data.getName(),": ", data.pieValueProperty() + ) + ) + ); + kd.getData().addAll(pieChartData); + } + public void iniPieChartwl() { + ObservableList<PieChart.Data> pieChartData = + FXCollections.observableArrayList( + new PieChart.Data("Wins",3), + new PieChart.Data("Losses",5)); + + pieChartData.forEach(data -> + data.nameProperty().bind( + Bindings.concat( + data.getName(),": ", data.pieValueProperty() + ) + ) + ); + wl.getData().addAll(pieChartData); + } +} + diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/ToggleButtonTransition.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/ToggleButtonTransition.java new file mode 100644 index 0000000000000000000000000000000000000000..6ee839dddf70e1a34ac776b9343e068234b391ab --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/ToggleButtonTransition.java @@ -0,0 +1,49 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.animation.FadeTransition; +import javafx.scene.control.ToggleButton; +import javafx.scene.control.skin.ToggleButtonSkin; +import javafx.util.Duration; + +public class ToggleButtonTransition extends ToggleButtonSkin { + private final FadeTransition fadeIn; + private final FadeTransition fadeOut; + + public ToggleButtonTransition(ToggleButton toggleButton) { + super(toggleButton); + + fadeIn = new FadeTransition(Duration.millis(150)); + fadeIn.setNode(toggleButton); + fadeIn.setToValue(1); + + fadeOut = new FadeTransition(Duration.millis(150)); + fadeOut.setNode(toggleButton); + fadeOut.setToValue(0.5); + + toggleButton.setOnMouseEntered(e -> fadeIn.playFromStart()); + toggleButton.setOnMouseExited(e -> { + if (!toggleButton.isSelected()) { + fadeOut.playFromStart(); + } + }); + + toggleButton.selectedProperty().addListener((observable, oldValue, newValue) -> { + if (newValue) { + fadeIn.playFromStart(); + fadeOut.setToValue(0.5); // Set fadeOut back to the default value + } else { + fadeOut.playFromStart(); + toggleButton.setOpacity(0.5); + } + }); + + // Set the initial opacity based on the initial selected state + toggleButton.setOpacity(toggleButton.isSelected() ? 1.0 : 0.5); + + } +} + + + + + diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java b/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java index f2952c692546cd275924f9d299819d2f70c7a7bf..d222017ae825e1a18482ab3913991df51d2df7bf 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java @@ -1,11 +1,16 @@ package de.hdm_stuttgart.battlearena.Main; +import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; import javafx.application.Application; import javafx.fxml.FXMLLoader; +import javafx.geometry.Rectangle2D; import javafx.scene.Parent; import javafx.scene.Scene; +import javafx.scene.text.Font; +import javafx.stage.Screen; import javafx.stage.Stage; +import javafx.stage.StageStyle; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -14,6 +19,9 @@ import java.util.Objects; public class Main extends Application { private static final Logger log = LogManager.getLogger(Main.class); + Rectangle2D screen = Screen.getPrimary().getVisualBounds(); + + InputHandler inputHandler = InputHandler.getInstance(); public static void main(String[] args) { launch(args); @@ -21,12 +29,26 @@ public class Main extends Application { @Override public void start(Stage stage) throws Exception { - Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MainMenu.fxml"))); +// loading font in start() because CSS can't handle whitespace in folder names + Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 20); + + Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/Intro.fxml"))); Scene scene = new Scene(root); + scene.setOnKeyPressed(inputHandler::handleKeyPress); + scene.setOnKeyReleased(inputHandler::handleKeyRelease); + stage.setTitle("BattleArena"); stage.setScene(scene); + stage.minHeightProperty().setValue(400); + stage.minWidthProperty().setValue(600); + stage.setMaximized(true); + stage.setWidth(screen.getWidth()); + stage.setHeight(screen.getHeight()); + stage.initStyle(StageStyle.UNDECORATED); + scene.getStylesheets().add(Objects.requireNonNull(this.getClass().getResource("/styles/style.css")).toExternalForm()); + stage.setScene(scene); stage.show(); log.debug("Project started successfully!"); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..9d860c1af101e6002e51c846e70d219cee7772e1 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java @@ -0,0 +1,69 @@ +package de.hdm_stuttgart.battlearena.Model.Entity; + +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.Map.ITile; + +import javafx.geometry.BoundingBox; + +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +public class CollisionHandler { + + private static final Logger log = LogManager.getLogger(CollisionHandler.class); + + public CollisionHandler() { + log.debug("CollisionHandler initialized"); + } + + public boolean handleBoxCollision(BoundingBox colliderA, BoundingBox colliderB) { + return colliderA.getMaxX() > colliderB.getMinX() && + colliderA.getMinX() < colliderB.getMaxX() && + colliderA.getMaxY() > colliderB.getMinY() && + colliderA.getMinY() < colliderB.getMaxY(); + } + + public boolean handleMapCollision(IEntity entity, int scaledTileSize, GameSceneController gameSceneController) { + int playerLeftX = (int) (entity.getBoxCollider().getMinX()); + int playerRightX = (int) (entity.getBoxCollider().getMinX() + entity.getBoxCollider().getWidth()); + int playerTopY = (int) (entity.getBoxCollider().getMinY()); + int playerBottomY = (int) (entity.getBoxCollider().getMinY() + entity.getBoxCollider().getHeight()); + + int leftColumn = playerLeftX / scaledTileSize; + int rightColumn = playerRightX / scaledTileSize; + int topRow = playerTopY / scaledTileSize; + int bottomRow = playerBottomY / scaledTileSize; + + int nextPlayerTop = (playerTopY - entity.getEntitySpeed()) / scaledTileSize; + int nextPlayerBottom = (playerBottomY + entity.getEntitySpeed()) / scaledTileSize; + int nextPlayerLeft = (playerLeftX - entity.getEntitySpeed()) / scaledTileSize; + int nextPlayerRight = (playerRightX + entity.getEntitySpeed()) / scaledTileSize; + + int[][] tileMap = gameSceneController.getTileManager().getTileMap(); + ITile[] tileSet = gameSceneController.getTileManager().getTileSet(); + int tileOne; + int tileTwo; + + switch (entity.getEntityDirection()) { + case UP: + tileOne = tileMap[nextPlayerTop][leftColumn]; + tileTwo = tileMap[nextPlayerTop][rightColumn]; + return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + case DOWN: + tileOne = tileMap[nextPlayerBottom][leftColumn]; + tileTwo = tileMap[nextPlayerBottom][rightColumn]; + return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + case LEFT: + tileOne = tileMap[topRow][nextPlayerLeft]; + tileTwo = tileMap[bottomRow][nextPlayerLeft]; + return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + case RIGHT: + tileOne = tileMap[topRow][nextPlayerRight]; + tileTwo = tileMap[bottomRow][nextPlayerRight]; + return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + default: + return true; + } + } + +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EnemyHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EnemyHandler.java index ea46bb6f0ff8235e038455fde192db494e789f94..c8fc714cc5aa2eefe30e616b5211fe76e6457ff2 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EnemyHandler.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EnemyHandler.java @@ -1,10 +1,86 @@ package de.hdm_stuttgart.battlearena.Model.Entity; +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; + +import javafx.geometry.BoundingBox; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.paint.Color; + import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -public class EnemyHandler { +class EnemyHandler implements IEntity{ private static final Logger log = LogManager.getLogger(EnemyHandler.class); -} + private final BoundingBox boxCollider = new BoundingBox(300, 200, 48, 48); + + private EntityDirection entityDirection = EntityDirection.DOWN; + + private int entitySpeed = 3; + + private int health = 10; + + @Override + public void initializeEntity() { + + } + + @Override + public void loadEntitySprites() { + + } + + @Override + public void updateEntityMovement(GameSceneController gameScene) { + + } + + @Override + public void attack(IEntity entity, GraphicsContext graphicsContext) { + + } + + @Override + public void updateEntityWalkAnimation() { + + } + + @Override + public void renderEntity(GraphicsContext graphicsContext) { + graphicsContext.setFill(Color.BLACK); + graphicsContext.fillRect(300, 200, 48, 48); + } + + @Override + public BoundingBox getBoxCollider() { + return boxCollider; + } + + @Override + public EntityDirection getEntityDirection() { + return entityDirection; + } + + @Override + public int getEntitySpeed() { + return 3; + } + + @Override + public int gotHit(int damageDone) { + log.debug(health); + return health -= damageDone; + } + + @Override + public int getMapPosX() { + return 0; + } + + @Override + public int getMapPosY() { + return 0; + } + +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityClass.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityClass.java new file mode 100644 index 0000000000000000000000000000000000000000..03b800acd74ad72318dee1df4dbf6528c53bf6d6 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityClass.java @@ -0,0 +1,8 @@ +package de.hdm_stuttgart.battlearena.Model.Entity; + +public enum EntityClass { + HUMAN, + HIGH_BORN, + LOW_BORN, + SENTINELS +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityDirection.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityDirection.java new file mode 100644 index 0000000000000000000000000000000000000000..c86d3e0e25d51cf090cede9ef3a3167745be7d0a --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityDirection.java @@ -0,0 +1,8 @@ +package de.hdm_stuttgart.battlearena.Model.Entity; + +public enum EntityDirection { + UP, + DOWN, + LEFT, + RIGHT +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..d5b4b382213c197e503a598e855940aa18821998 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java @@ -0,0 +1,27 @@ +package de.hdm_stuttgart.battlearena.Model.Entity; + +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; + +import javafx.scene.canvas.GraphicsContext; + +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +public class EntityFactory { + + private static final Logger log = LogManager.getLogger(EntityFactory.class); + + public static IEntity createEntity(EntityType entityType, GraphicsContext gameScene, InputHandler inputHandler, EntityClass entityClass, GameSceneController gameSceneController) { + if (entityType == EntityType.PLAYER) { + log.debug("Entity " + entityType + " created"); + return new Player(gameScene, inputHandler, entityClass, gameSceneController); + } else if (entityType == EntityType.ENEMY_PLAYER) { + log.debug("Entity " + entityType + " created"); + return new EnemyHandler(); + } + + throw new IllegalArgumentException ("Entity type not supported " + entityType); + } + +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityType.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityType.java new file mode 100644 index 0000000000000000000000000000000000000000..3e8560772b2e9f049e217bdeca99c30c24150e11 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityType.java @@ -0,0 +1,6 @@ +package de.hdm_stuttgart.battlearena.Model.Entity; + +public enum EntityType { + PLAYER, + ENEMY_PLAYER +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java index fd7bbc62dab3dc4952f7a50958d25bb42cf95b5a..92ca5b53906697c1bad96c2cbb59524b7bc2c40b 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java @@ -1,4 +1,33 @@ package de.hdm_stuttgart.battlearena.Model.Entity; +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import javafx.geometry.BoundingBox; +import javafx.scene.canvas.GraphicsContext; + public interface IEntity { -} + + void initializeEntity(); + + void loadEntitySprites(); + + void updateEntityMovement(GameSceneController gameScene); + + void attack(IEntity entity, GraphicsContext graphicsContext); + + void updateEntityWalkAnimation(); + + void renderEntity(GraphicsContext graphicsContext); + + BoundingBox getBoxCollider(); + + EntityDirection getEntityDirection(); + + int getEntitySpeed(); + + int gotHit(int damageDone); + + int getMapPosX(); + + int getMapPosY(); + +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java index 0384286b6f19eb3b2cd302cd23687b741eef2722..fffccf712e14e8a655bbc72622fae7e4c0d5d3b8 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java @@ -1,10 +1,347 @@ package de.hdm_stuttgart.battlearena.Model.Entity; +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; + +import javafx.geometry.BoundingBox; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.image.Image; + import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -public class Player implements IEntity { +import java.util.Objects; + +class Player implements IEntity { private static final Logger log = LogManager.getLogger(Player.class); -} + InputHandler inputHandler; + CollisionHandler collisionHandler = new CollisionHandler(); + + GraphicsContext gameScene; + + GameSceneController gameSceneController; + + private BoundingBox boxCollider; + + private Image directionDownOne, + directionDownTwo, + directionUpOne, + directionUpTwo, + directionLeftOne, + directionLeftTwo, + directionRightOne, + directionRightTwo; + + private Image swordDown, + swordUp, + swordLeft, + swordRight; + + private final EntityClass entityClass; + + private int spriteCounter = 0; + private int spriteNumber = 1; + + private final int playerWidth = 19; + private final int playerHeight = 35; + + private int scaledTileSize; + + private int mapPosX; + private int mapPosY; + private int playerSpeed; + private EntityDirection playerDirection; + + private int health = 10; + private int damage = 1; + + public Player(GraphicsContext gameScene, InputHandler inputHandler, EntityClass entityClass, GameSceneController gameSceneController) { + this.gameScene = gameScene; + this.inputHandler = inputHandler; + this.entityClass = entityClass; + this.gameSceneController = gameSceneController; + + initializeEntity(); + loadEntitySprites(); + } + + @Override + public void initializeEntity() { + scaledTileSize = gameSceneController.getScaledTileSize(); + mapPosX = 60; + mapPosY = 60; + boxCollider = new BoundingBox(mapPosX+15,mapPosY+10, playerWidth, playerHeight); + playerSpeed = 5; + playerDirection = EntityDirection.DOWN; + } + + @Override + public void loadEntitySprites() { + try { + if (entityClass == EntityClass.HUMAN) { + loadHumanSprites(); + loadWeaponSprites(); + } else if (entityClass == EntityClass.HIGH_BORN) { + loadHighBornSprites(); + loadWeaponSprites(); + } else if (entityClass == EntityClass.LOW_BORN) { + loadLowBornSprites(); + loadWeaponSprites(); + } else { + loadSentinelsSprites(); + loadWeaponSprites(); + } + } catch (Exception e) { + log.error(e); + } + } + + private void loadHumanSprites() { + directionDownOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/HumanDown01.png"))); + directionDownTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/HumanDown02.png"))); + directionUpOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/upOne.png"))); + directionUpTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/upTwo.png"))); + directionLeftOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/leftOne.png"))); + directionLeftTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/leftTwo.png"))); + directionRightOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/rightOne.png"))); + directionRightTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/rightTwo.png"))); + } + + private void loadHighBornSprites() { + directionDownOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/HumanDown01.png"))); + directionDownTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/HumanDown02.png"))); + directionUpOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/upOne.png"))); + directionUpTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/upTwo.png"))); + directionLeftOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/leftOne.png"))); + directionLeftTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/leftTwo.png"))); + directionRightOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/rightOne.png"))); + directionRightTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/rightTwo.png"))); + } + + private void loadLowBornSprites() { + directionDownOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/HumanDown01.png"))); + directionDownTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/HumanDown02.png"))); + directionUpOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/upOne.png"))); + directionUpTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/upTwo.png"))); + directionLeftOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/leftOne.png"))); + directionLeftTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/leftTwo.png"))); + directionRightOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/rightOne.png"))); + directionRightTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/rightTwo.png"))); + } + + private void loadSentinelsSprites() { + directionDownOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/HumanDown01.png"))); + directionDownTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/HumanDown02.png"))); + directionUpOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/upOne.png"))); + directionUpTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/upTwo.png"))); + directionLeftOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/leftOne.png"))); + directionLeftTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/leftTwo.png"))); + directionRightOne = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/rightOne.png"))); + directionRightTwo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/player/rightTwo.png"))); + } + + private void loadWeaponSprites() { + swordUp = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/weapons/SwordUp.png"))); + swordDown = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/weapons/SwordDown.png"))); + swordLeft = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/weapons/SwordLeft.png"))); + swordRight = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/weapons/SwordRight.png"))); + } + + @Override + public void updateEntityMovement(GameSceneController gameScene) { + if (inputHandler.isMoveUp() || inputHandler.isMoveDown() || inputHandler.isMoveLeft() || inputHandler.isMoveRight()) { + if (inputHandler.isMoveUp()) { + playerDirection = EntityDirection.UP; + } else if (inputHandler.isMoveDown()) { + playerDirection = EntityDirection.DOWN; + } else if (inputHandler.isMoveLeft()) { + playerDirection = EntityDirection.LEFT; + } else { + playerDirection = EntityDirection.RIGHT; + } + + boolean isWalkableTile = collisionHandler.handleMapCollision(this, scaledTileSize, gameSceneController); + + int lastMapPosX = mapPosX; + int lastMapPosY = mapPosY; + + if (isWalkableTile) { + switch (playerDirection) { + case UP: + mapPosY -= playerSpeed; + break; + case DOWN: + mapPosY += playerSpeed; + break; + case LEFT: + mapPosX -= playerSpeed; + break; + case RIGHT: + mapPosX += playerSpeed; + } + } + + boolean isEntityCollision = boxCollider.intersects(gameScene.getEnemy().getBoxCollider()); + //boolean isEntityCollision = collisionHandler.handleBoxCollision(boxCollider, gameScene.getEnemy().getBoxCollider()); + + if (isEntityCollision) { + if (playerDirection == EntityDirection.UP) { + mapPosY = lastMapPosY + 30; + } else if (playerDirection == EntityDirection.DOWN) { + mapPosY = lastMapPosY - 30; + } else if (playerDirection == EntityDirection.LEFT) { + mapPosX = lastMapPosX + 30; + } else { + mapPosX = lastMapPosX - 30; + } + } + + boxCollider = new BoundingBox(mapPosX+15,mapPosY+10, playerWidth, playerHeight); + + updateEntityWalkAnimation(); + + } + } + + @Override + public void attack(IEntity entity, GraphicsContext graphicsContext) { + BoundingBox hitBox; + + //Added and subtracted numbers from variables are the pixel insets of the player sprite + + int attackRange = 30; + int attackWidth = 10; + + if (inputHandler.isAttack()){ + if (playerDirection == EntityDirection.UP) { + hitBox = new BoundingBox(mapPosX+playerWidth, mapPosY-10, attackWidth, attackRange); + graphicsContext.strokeRect(mapPosX+playerWidth, mapPosY-10, attackWidth, attackRange); + graphicsContext.drawImage(swordUp, mapPosX+8, mapPosY-10, 32, 32); + if (hitBox.intersects(entity.getBoxCollider())) { + entity.gotHit(damage); + graphicsContext.strokeText("Hit", 10, 10); + } + } else if (playerDirection == EntityDirection.DOWN) { + hitBox = new BoundingBox(mapPosX+playerWidth, mapPosY+playerHeight, attackWidth, attackRange); + graphicsContext.strokeRect(mapPosX+playerWidth, mapPosY+playerHeight, attackWidth, attackRange); + graphicsContext.drawImage(swordDown, mapPosX+8, mapPosY+playerHeight, 32, 32); + if (hitBox.intersects(entity.getBoxCollider())) { + entity.gotHit(damage); + graphicsContext.strokeText("Hit", 10, 10); + } + } else if (playerDirection == EntityDirection.LEFT) { + hitBox = new BoundingBox(mapPosX-attackWidth, mapPosY+((double) playerHeight /2), + attackRange, attackWidth); + graphicsContext.strokeRect(mapPosX-attackWidth, mapPosY+((double) playerHeight /2), + attackRange, attackWidth); + graphicsContext.drawImage(swordLeft, mapPosX-8, mapPosY+8, 32, 32); + if (hitBox.intersects(entity.getBoxCollider())) { + entity.gotHit(damage); + graphicsContext.strokeText("Hit", 10, 10); + } + } else { + hitBox = new BoundingBox(mapPosX+playerWidth+attackWidth, mapPosY+((double) playerHeight /2), + attackRange, attackWidth); + graphicsContext.strokeRect(mapPosX+playerWidth+attackWidth, mapPosY+((double) playerHeight /2), + attackRange, attackWidth); + graphicsContext.drawImage(swordRight, mapPosX+playerWidth+8, mapPosY+8, 32, 32); + if (hitBox.intersects(entity.getBoxCollider())) { + entity.gotHit(damage); + graphicsContext.strokeText("Hit", 10, 10); + } + } + } + } + + @Override + public void updateEntityWalkAnimation() { + spriteCounter++; + + if (spriteCounter > 10) { + if (spriteNumber == 1) { + spriteNumber = 2; + } else if (spriteNumber == 2) { + spriteNumber = 1; + } + spriteCounter = 0; + } + } + + @Override + public void renderEntity(GraphicsContext graphicsContext) { + Image playerSprite = null; + + //for debugging collision + graphicsContext.strokeRect(mapPosX+15,mapPosY+10, playerWidth, playerHeight); + + switch (playerDirection) { + case UP: + if (spriteNumber == 1) { + playerSprite = directionUpOne; + } + if (spriteNumber == 2) { + playerSprite = directionUpTwo; + } + break; + case DOWN: + if (spriteNumber == 1) { + playerSprite = directionDownOne; + } + if (spriteNumber == 2) { + playerSprite = directionDownTwo; + } + break; + case LEFT: + if (spriteNumber == 1) { + playerSprite = directionLeftOne; + } + if (spriteNumber == 2) { + playerSprite = directionLeftTwo; + } + break; + case RIGHT: + if (spriteNumber == 1) { + playerSprite = directionRightOne; + } + if (spriteNumber == 2) { + playerSprite = directionRightTwo; + } + break; + } + + graphicsContext.drawImage(playerSprite, mapPosX, mapPosY, 48, 48); + } + + @Override + public BoundingBox getBoxCollider() { + return boxCollider; + } + + @Override + public EntityDirection getEntityDirection() { + return playerDirection; + } + + @Override + public int getEntitySpeed() { + return playerSpeed; + } + + @Override + public int gotHit(int damageDone) { + return health -= damageDone; + } + + @Override + public int getMapPosX() { + return mapPosX; + } + + @Override + public int getMapPosY() { + return mapPosY; + } + +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java index 5772a4785203b4a51e58738825772f37c11816b3..8dfd2f3d3d51063e409488e71a25814030ed2f68 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java @@ -1,5 +1,8 @@ package de.hdm_stuttgart.battlearena.Model.Inputs; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; + import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; @@ -7,4 +10,75 @@ public class InputHandler { private static final Logger log = LogManager.getLogger(InputHandler.class); -} + private static final InputHandler inputHandler = new InputHandler(); + + private InputHandler(){} + + public static InputHandler getInstance() { + return inputHandler; + } + + private boolean moveUp, moveDown, moveLeft, moveRight, attack; + + public void handleKeyPress(KeyEvent event) { + KeyCode code = event.getCode(); + + switch (code) { + case W: + moveUp = true; + break; + case S: + moveDown = true; + break; + case A: + moveLeft = true; + break; + case D: + moveRight = true; + break; + case SPACE: + attack = true; + } + } + + public void handleKeyRelease(KeyEvent event) { + KeyCode code = event.getCode(); + + switch (code) { + case W: + moveUp = false; + break; + case S: + moveDown = false; + break; + case A: + moveLeft = false; + break; + case D: + moveRight = false; + break; + case SPACE: + attack = false; + } + } + + public boolean isMoveUp() { + return moveUp; + } + + public boolean isMoveDown() { + return moveDown; + } + + public boolean isMoveLeft() { + return moveLeft; + } + + public boolean isMoveRight() { + return moveRight; + } + + public boolean isAttack() { + return attack; + } +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/BackgroundTile.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/BackgroundTile.java index 0a702580fe7a00095752ce2f6141f25caa8a0344..c7fd6bc3ad273c2e2667a9398a33c94764947ea7 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/BackgroundTile.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/BackgroundTile.java @@ -1,10 +1,31 @@ package de.hdm_stuttgart.battlearena.Model.Map; +import javafx.scene.image.Image; + import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -public class BackgroundTile implements ITile{ +class BackgroundTile implements ITile{ private static final Logger log = LogManager.getLogger(BackgroundTile.class); -} + private final Image tileSprite; + private final boolean isWalkable; + + public BackgroundTile(Image tileSprite, boolean isWalkable) { + this.tileSprite = tileSprite; + this.isWalkable = isWalkable; + } + + @Override + public boolean getCollision() { + log.debug("Collision type: " + isWalkable + " returned."); + return isWalkable; + } + + @Override + public Image getTileSprite() { + log.debug("Image returned"); + return tileSprite; + } +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/ITile.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/ITile.java index 4364ed78f3face5dcca4f183e62c11b13e43a9fd..f33750bed5ede99e059da2a7fb4e31f33bb735ad 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/ITile.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/ITile.java @@ -1,4 +1,8 @@ package de.hdm_stuttgart.battlearena.Model.Map; +import javafx.scene.image.Image; + public interface ITile { -} + boolean getCollision(); + Image getTileSprite(); +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileFactorie.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileFactorie.java deleted file mode 100644 index 8409dac4ecfd80fb60f0d9fad2337efbfad775af..0000000000000000000000000000000000000000 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileFactorie.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.hdm_stuttgart.battlearena.Model.Map; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - -public class TileFactorie { - - private static final Logger log = LogManager.getLogger(TileFactorie.class); - -} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileFactory.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..842781646eb4c59e1ba537d172414c7437b498b2 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileFactory.java @@ -0,0 +1,25 @@ +package de.hdm_stuttgart.battlearena.Model.Map; + +import javafx.scene.image.Image; + +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +public class TileFactory { + + private static final Logger log = LogManager.getLogger(TileFactory.class); + + public static ITile createTile(TileType tileType, Image tileSprite) { + if (tileType == TileType.WALKABLE) { + log.debug("Tile with type: " + tileType + " created."); + return new BackgroundTile(tileSprite, true); + } else if (tileType == TileType.NON_WALKABLE) { + log.debug("Tile with type: " + tileType + " created."); + return new BackgroundTile(tileSprite, false); + } + + log.error("TileType: " + tileType + " not supported!"); + throw new IllegalArgumentException("TileType: " + tileType + " not supported!"); + } + +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java index c57a773e4dec2aeb5b0b7da0adfeedb0b6d537e2..480478d51823c0a4992de930e4eea5f2b73f82d8 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java @@ -1,10 +1,91 @@ package de.hdm_stuttgart.battlearena.Model.Map; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.image.Image; + import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import java.util.Objects; + public class TileManager { private static final Logger log = LogManager.getLogger(TileManager.class); -} + private final GraphicsContext graphicsContext2D; + private final ITile[] tileSet; + private final int[][] tileMap; + + private final int horizontalTileCount; + private final int verticalTileCount; + + public TileManager(GraphicsContext graphicsContext2D, int diffTileCount, + int horizontalTileCount, int verticalTileCount, String mapString) { + this.graphicsContext2D = graphicsContext2D; + this.horizontalTileCount = horizontalTileCount; + this.verticalTileCount = verticalTileCount; + + tileSet = new BackgroundTile[diffTileCount]; + tileMap = new int[horizontalTileCount][verticalTileCount]; + + createTiles(); + generateMap(mapString, horizontalTileCount, verticalTileCount); + } + + private void createTiles() { + try { + tileSet[0] = TileFactory.createTile(TileType.WALKABLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/Grass01.png")))); + tileSet[1] = TileFactory.createTile(TileType.WALKABLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/Grass02.png")))); + tileSet[2] = TileFactory.createTile(TileType.WALKABLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/Grass04.png")))); + tileSet[3] = TileFactory.createTile(TileType.NON_WALKABLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/Stone01.png")))); + tileSet[4] = TileFactory.createTile(TileType.NON_WALKABLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/Stone02.png")))); + } catch (Exception e) { + log.error(e); + } + } + + private void generateMap(String mapString, int horizontalTileCount, int verticalTileCount) { + String[] tileSet = mapString.split(" "); + + int stringIndex = 0; + + for (int column = 0; column < horizontalTileCount; column++) { + for (int row = 0; row < verticalTileCount; row++) { + tileMap[column][row] = Integer.parseInt(tileSet[stringIndex]); + stringIndex++; + } + } + } + + public void renderMap() { + int currentTile; + int scaledTileSize = 48; //todo: later replace "48" with value from gameScene. + int tilePosX; + int tilePosY; + + for (int mapColumn = 0; mapColumn < horizontalTileCount; mapColumn++) { + for (int mapRow = 0; mapRow < verticalTileCount; mapRow++) { + currentTile = tileMap[mapRow][mapColumn]; + + tilePosX = mapColumn * scaledTileSize; + tilePosY = mapRow * scaledTileSize; + + graphicsContext2D.drawImage(tileSet[currentTile].getTileSprite(), tilePosX, tilePosY, + scaledTileSize, scaledTileSize); + } + } + } + + public int[][] getTileMap() { + return tileMap; + } + + public ITile[] getTileSet() { + return tileSet; + } +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileType.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileType.java new file mode 100644 index 0000000000000000000000000000000000000000..17e95c7e93fc890a5f993cc53b7eb6cfd1f4bd6b --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileType.java @@ -0,0 +1,6 @@ +package de.hdm_stuttgart.battlearena.Model.Map; + +public enum TileType { + WALKABLE, + NON_WALKABLE +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Client.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Client.java new file mode 100644 index 0000000000000000000000000000000000000000..23b1c65ccd218152576cc9c7d366e68c65d1c591 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Client.java @@ -0,0 +1,49 @@ +package de.hdm_stuttgart.battlearena.Model.Multiplayer; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.net.*; +import java.io.*; +import java.util.Arrays; + +public class Client { + private Socket clientSocket; + private PrintWriter out; + private BufferedReader in; + + private static final Logger log = LogManager.getLogger(Client.class); + + public void startConnection(String ip, int port) throws IOException { + clientSocket = new Socket(ip, port); + out = new PrintWriter(clientSocket.getOutputStream(), true); + in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); + } + + public int[] sendcords(int[] cords) throws IOException { + String message = String.join(",", Arrays.stream(cords).mapToObj(String::valueOf).toArray(String[]::new)); + out.println(message); + // log.info("Sent coordinates: " + message); + String resp = in.readLine(); + return convertStringToArray(resp); + } + + public static int[] convertStringToArray(String inputString) { + // Remove brackets and split by comma + String[] parts = inputString.substring(1, inputString.length() - 1).split(","); + + // Convert each part to integer + int[] result = new int[parts.length]; + for (int i = 0; i < parts.length; i++) { + result[i] = Integer.parseInt(parts[i].trim()); + } + + return result; + } + + public void stopConnection() throws IOException { + in.close(); + out.close(); + clientSocket.close(); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandler.java index 95967c90b0b30ad5c9832df6cb003e38f1463a3f..b47419daa11eea14e292ecab5dac7e0ae483f2b6 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandler.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandler.java @@ -1,10 +1,92 @@ package de.hdm_stuttgart.battlearena.Model.Multiplayer; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; public class ConnectionHandler { + private static int pX = 0; + private static int pY = 0; + private static int enemyX = 0; + private static int enemyY = 0; + private static int playerID = 0; + private static int[] coordinates = {pX,pY,playerID}; + private static String ipaddress = "localhost"; private static final Logger log = LogManager.getLogger(ConnectionHandler.class); + public void startHandler() throws IOException, InterruptedException { + + Client client = new Client(); + client.startConnection(ipaddress, 4444); + + ConnectionThread connectionthread = new ConnectionThread(client); + connectionthread.start(); + + } + + private static class ConnectionThread extends Thread { + private final Client client; + + public ConnectionThread(Client client) { + this.client = client; + } + + public void run() { + try { + while (!Thread.interrupted()) { + int[] cords = client.sendcords(coordinates); + enemyX = cords[0]; + enemyY = cords[1]; + // System.out.println("Enemy X: " + enemyX); + // System.out.println("Enemy Y: " + enemyY); + // System.out.println("Your PlayerID is " + cords[2]); + playerID = cords[2]; + // Assign the Values to the message to send: + coordinates[0] = pX; + coordinates[1] = pY; + coordinates[2] = playerID; + + Thread.sleep(16); + } + } catch (InterruptedException | IOException e) { + e.printStackTrace(); // Handle the exception as needed + } + } + } + + public int getPlayerID() { + return playerID; + } + + public int getpX() { + return pX; + } + + public void setpX(int pX) { + this.pX = pX; + } + + public int getpY() { + return pY; + } + + public void setpY(int pY) { + this.pY = pY; + } + + public int getEnemyX() { + return enemyX; + } + public int getEnemyY() { + return enemyY; + } + + public static void setIpaddress(String ipaddress) { + ConnectionHandler.ipaddress = ipaddress; + } } + diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/GameServer.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/GameServer.java deleted file mode 100644 index 6a4e74cfa64ea68224b76119f3943de4ee62457d..0000000000000000000000000000000000000000 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/GameServer.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.hdm_stuttgart.battlearena.Model.Multiplayer; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - -public class GameServer { - - private static final Logger log = LogManager.getLogger(GameServer.class); - -} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Server.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Server.java new file mode 100644 index 0000000000000000000000000000000000000000..8cf35eecb05a3aba1b14506b5060a94798fdea12 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Server.java @@ -0,0 +1,164 @@ +package de.hdm_stuttgart.battlearena.Model.Multiplayer; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.net.*; +import java.io.*; +import java.util.Arrays; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +public class Server { + + private static final Logger log = LogManager.getLogger(Server.class); + private ServerSocket serverSocket; + private static boolean isServerRunning = true; + private static int px; + private static int py; + + private static int enemyx = 0; + private static int enemyy = 0; + private static int playerID; + private static int playercount = 0; + private static int[] cords; + private static int[] returncords = {enemyx,enemyy,playerID}; + private boolean started = false; + private static String ipaddress = "localhost"; + + + /* public static void main(String[] args) throws IOException { //main method for testing purposes + Server server = new Server(); + log.info("server starting..."); + server.start(ipaddress, 4444); + } */ + + //use this method to start the server from another class + public void startServer() throws IOException { + Server server = new Server(); + log.info("server starting..."); + server.start("localhost",4444); + } + + public void start(String host_ip, int port) throws IOException { + serverSocket = new ServerSocket(port); + log.info("server started!"); + started = true; + while (true){ + new ServerHandler(serverSocket.accept()).start(); + } + } + + private static class ServerHandler extends Thread { + private final Socket clientSocket; + private PrintWriter out; + private BufferedReader in; + + public ServerHandler(Socket socket) { + this.clientSocket = socket; + } + + public void run() { + ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); + + executorService.scheduleAtFixedRate(() -> { + try { + BufferedReader localIn = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); + PrintWriter localOut = new PrintWriter(clientSocket.getOutputStream(), true); + + String inputLine = localIn.readLine(); + + if (inputLine != null) { + // Assuming that the input line is a comma-separated list of integers + String[] coordinates = inputLine.split(","); + cords = new int[coordinates.length]; + for (int i = 0; i < coordinates.length; i++) { + cords[i] = Integer.parseInt(coordinates[i]); + } + + //first connect of a client: + if(playercount == 0){ + //first player to connect + playercount++; + returncords[2] = 1; + + } else if(playercount == 1){ + //second player to connect + if(cords[2] == 1){ + returncords[2] = 1; + } else { + playercount++; + returncords[2] = 2; + } + + } else if(playercount == 2){ + + //check which client has connected + if (cords[2] == 1) { //player + px = cords[0]; + py = cords[1]; + + //set the cords to return: + returncords[0] = enemyx; + returncords[1] = enemyy; + + //set playerID: + returncords[2] = 1; + + } else if(cords[2] == 2) { //enemy + enemyx = cords[0]; + enemyy = cords[1]; + + //set the cords to return: + returncords[0] = px; + returncords[1] = py; + + //set playerID: + returncords[2] = 2; + + } + } + + localOut.println(Arrays.toString(returncords)); + localOut.flush(); + } + + log.info("Player X / Y : " + px + " / " + py + " Enemy X / Y : " + enemyx + " / " + enemyy); + + + //check if server was shut down: + if (!isServerRunning) { + executorService.shutdown(); + try { + if (!executorService.awaitTermination(5, TimeUnit.SECONDS)) { + executorService.shutdownNow(); + } + } catch (InterruptedException e) { + log.error("Error waiting for executor service termination: " + e.getMessage()); + } + } + + } catch (IOException e) { + throw new RuntimeException(e); + } + }, 0, 50, TimeUnit.MILLISECONDS); + } + } + + public void stopServer() { + isServerRunning = false; + try { + serverSocket.close(); // Close the server socket to break out of accept() in the main thread + } catch (IOException e) { + log.error("Error closing server socket: " + e.getMessage()); + } + } + + public boolean isStarted() { + return started; + } + public static void setIpaddress(String ipaddress) { + Server.ipaddress = ipaddress; + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/TestMap.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/TestMap.java new file mode 100644 index 0000000000000000000000000000000000000000..f6d7fdf0800d787b23fb6df532afdb898733d53c --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/TestMap.java @@ -0,0 +1,113 @@ +package de.hdm_stuttgart.battlearena.Model.Multiplayer; + +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.input.KeyCode; +import javafx.scene.layout.Pane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.stage.Stage; +import java.util.concurrent.TimeUnit; + +import java.io.IOException; + +public class TestMap extends Application { + private static final int SQUARE_SIZE = 50; + private static Rectangle square; + private static Rectangle enemy; + private Color color = Color.BLACK; + + @Override + public void start(Stage primaryStage) throws IOException, InterruptedException { + + ConnectionHandler handler = new ConnectionHandler(); + handler.startHandler(); + + TimeUnit.SECONDS.sleep(1); + + square = new Rectangle(SQUARE_SIZE, SQUARE_SIZE, color); + enemy = new Rectangle(SQUARE_SIZE, SQUARE_SIZE, color); + + Pane root = new Pane(); + root.getChildren().add(square); + root.getChildren().add(enemy); + + Scene scene = new Scene(root, 400, 400); + + scene.setOnKeyPressed(event -> handleKeyPress(event.getCode(), handler)); + + primaryStage.setTitle("Player #" + handler.getPlayerID()); + primaryStage.setScene(scene); + primaryStage.show(); + + if(handler.getPlayerID() == 1){ + square.setX(50); + square.setY(50); + enemy.setX(200); + enemy.setY(50); + } else if(handler.getPlayerID() == 2){ + square.setX(200); + square.setY(50); + enemy.setX(50); + enemy.setY(50); + } + + UpdateThread update = new UpdateThread(handler); + update.start(); + + } + + private void handleKeyPress(KeyCode code, ConnectionHandler handler) { + switch (code) { + case UP: + square.setY(square.getY() - 20); + handler.setpY(handler.getpY() - 20); + break; + case DOWN: + square.setY(square.getY() + 20); + handler.setpY(handler.getpY() + 20); + break; + case LEFT: + square.setX(square.getX() - 20); + handler.setpX(handler.getpX() - 20); + break; + case RIGHT: + square.setX(square.getX() + 20); + handler.setpX(handler.getpX() + 20); + break; + } + } + + private static class UpdateThread extends Thread { + private final ConnectionHandler handler; + + private UpdateThread(ConnectionHandler handler) { + this.handler = handler; + } + + public void run() { + while (true){ + + handler.setpX((int) square.getX()); + handler.setpY((int) square.getY()); + + //receive cords + enemy.setX(handler.getEnemyX()); + enemy.setY(handler.getEnemyY()); + + + try { + Thread.sleep(16); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + + } + } + + public static void main(String[] args) throws IOException { + launch(args); + } +} \ No newline at end of file diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index e006608abd4f23d42e2fac09ce505582f50d0423..9eadd997470ed8c1fff21144d25aaa05b0a9d7ac 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -8,8 +8,9 @@ module gui { requires com.oracle.database.jdbc; requires java.naming; + opens de.hdm_stuttgart.battlearena to javafx.fxml; exports de.hdm_stuttgart.battlearena.Main; exports de.hdm_stuttgart.battlearena.Controller; - opens de.hdm_stuttgart.battlearena.Persistance.Classes to com.google.gson, javafx.fxml; + exports de.hdm_stuttgart.battlearena.Model.Multiplayer; } diff --git a/src/main/resources/fonts/StarshipInline.ttf b/src/main/resources/fonts/StarshipInline.ttf new file mode 100644 index 0000000000000000000000000000000000000000..b738337f8929807e42f3eab6ca17b629b9dd9346 Binary files /dev/null and b/src/main/resources/fonts/StarshipInline.ttf differ diff --git a/src/main/resources/fonts/StarshipInlineGrunge.ttf b/src/main/resources/fonts/StarshipInlineGrunge.ttf new file mode 100644 index 0000000000000000000000000000000000000000..717585cf29071695d9a23cc8c28cacea0108c8d0 Binary files /dev/null and b/src/main/resources/fonts/StarshipInlineGrunge.ttf differ diff --git a/src/main/resources/fonts/StarshipShadow.ttf b/src/main/resources/fonts/StarshipShadow.ttf new file mode 100644 index 0000000000000000000000000000000000000000..87b1a315517048dea5ef414f248a124a9d36c0fb Binary files /dev/null and b/src/main/resources/fonts/StarshipShadow.ttf differ diff --git a/src/main/resources/fonts/StarshipShadowInline.ttf b/src/main/resources/fonts/StarshipShadowInline.ttf new file mode 100644 index 0000000000000000000000000000000000000000..e31a30c5608773cb0ca00947d946cf767df4df1c Binary files /dev/null and b/src/main/resources/fonts/StarshipShadowInline.ttf differ diff --git a/src/main/resources/fxml/Credits.fxml b/src/main/resources/fxml/Credits.fxml new file mode 100644 index 0000000000000000000000000000000000000000..d676f90ba0a604995e51dfa5c8ff51d3dd485aa7 --- /dev/null +++ b/src/main/resources/fxml/Credits.fxml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.media.MediaView?> + + +<BorderPane fx:id="parent" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.CreditsController"> + <center> + <MediaView fx:id="mediaView" fitHeight="200.0" fitWidth="200.0" BorderPane.alignment="CENTER" /> + </center> +</BorderPane> diff --git a/src/main/resources/fxml/GameScene.fxml b/src/main/resources/fxml/GameScene.fxml index b8a97acf0ac20383de9eb2086ae9b0c3e6e370a3..f046db58280a8ea339f035b1879ac8e6e73b8115 100644 --- a/src/main/resources/fxml/GameScene.fxml +++ b/src/main/resources/fxml/GameScene.fxml @@ -1,8 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> +<?import javafx.scene.canvas.Canvas?> <?import javafx.scene.layout.AnchorPane?> - - -<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.GameSceneController"> - +<?import javafx.scene.layout.StackPane?> + +<AnchorPane prefHeight="864.0" prefWidth="864.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.GameSceneController"> + <children> + <StackPane prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> + <children> + <Canvas fx:id="canvas2D" height="864.0" width="864.0" /> + </children> + </StackPane> + </children> </AnchorPane> diff --git a/src/main/resources/fxml/Intro.fxml b/src/main/resources/fxml/Intro.fxml new file mode 100644 index 0000000000000000000000000000000000000000..fb0cfbc611000de77a25e8fd74afdaeb358e7c82 --- /dev/null +++ b/src/main/resources/fxml/Intro.fxml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.media.MediaView?> + +<BorderPane fx:id="introParent" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.IntroController"> + <center> + <MediaView fx:id="mediaView" fitHeight="200.0" fitWidth="200.0" BorderPane.alignment="CENTER" /> + </center> +</BorderPane> diff --git a/src/main/resources/fxml/LocalCreate.fxml b/src/main/resources/fxml/LocalCreate.fxml new file mode 100644 index 0000000000000000000000000000000000000000..46cca9f8e1e83c60b4a7c8cbc9753d9083bee1a0 --- /dev/null +++ b/src/main/resources/fxml/LocalCreate.fxml @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.control.Accordion?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.RadioButton?> +<?import javafx.scene.control.TitledPane?> +<?import javafx.scene.control.ToggleGroup?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Text?> + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.LocalCreateController"> + <children> + <HBox alignment="TOP_CENTER" spacing="20.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Rounds:" /> + <Accordion> + <panes> + <TitledPane animated="false" text="untitled 1"> + <content> + <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" /> + </content> + </TitledPane> + </panes> + </Accordion> + </children> + <VBox.margin> + <Insets /> + </VBox.margin> + </HBox> + <HBox alignment="TOP_CENTER" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="213.0" spacing="20.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Time:" /> + <Accordion> + <panes> + <TitledPane animated="false" text="untitled 1"> + <content> + <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" /> + </content> + </TitledPane> + </panes> + </Accordion> + </children> + </HBox> + <HBox alignment="TOP_CENTER" spacing="10.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="PLayers:" /> + <RadioButton mnemonicParsing="false" selected="true" text="2"> + <toggleGroup> + <ToggleGroup fx:id="group31" /> + </toggleGroup> + </RadioButton> + <RadioButton mnemonicParsing="false" text="3" toggleGroup="$group31" /> + <RadioButton mnemonicParsing="false" text="4" toggleGroup="$group31" /> + </children> + </HBox> + <HBox alignment="TOP_CENTER" spacing="10.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> + <RadioButton mnemonicParsing="false" text="Yes"> + <toggleGroup> + <ToggleGroup fx:id="group1" /> + </toggleGroup> + </RadioButton> + <RadioButton mnemonicParsing="false" selected="true" text="No" toggleGroup="$group1" /> + </children> + </HBox> + <HBox alignment="TOP_CENTER" spacing="10.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> + <RadioButton mnemonicParsing="false" text="Yes"> + <toggleGroup> + <ToggleGroup fx:id="group2" /> + </toggleGroup> + </RadioButton> + <RadioButton mnemonicParsing="false" selected="true" text="No" toggleGroup="$group2" /> + </children> + </HBox> + <HBox alignment="TOP_CENTER" spacing="10.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> + <RadioButton mnemonicParsing="false" text="Yes"> + <toggleGroup> + <ToggleGroup fx:id="group3" /> + </toggleGroup> + </RadioButton> + <RadioButton mnemonicParsing="false" selected="true" text="No" toggleGroup="$group3" /> + </children> + </HBox> + <Button mnemonicParsing="false" onAction="#skinSelectionScene" text="Start" /> + <Button mnemonicParsing="false" onAction="#playScene" text="Back"> + <VBox.margin> + <Insets bottom="50.0" /> + </VBox.margin> + </Button> + <Pane VBox.vgrow="ALWAYS" /> + <Pane VBox.vgrow="ALWAYS" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/MainMenu.fxml b/src/main/resources/fxml/MainMenu.fxml index 593ebfedde7527d354af67c063ffcfc078a2472e..385eeb92c0ed4cce0d84e17363a2007d4a6c648b 100644 --- a/src/main/resources/fxml/MainMenu.fxml +++ b/src/main/resources/fxml/MainMenu.fxml @@ -1,23 +1,25 @@ <?xml version="1.0" encoding="UTF-8"?> +<?import javafx.geometry.Insets?> <?import javafx.scene.control.Button?> -<?import javafx.scene.layout.AnchorPane?> -<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Text?> - -<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MainMenuController"> - <children> - <BorderPane prefHeight="400.0" prefWidth="600.0"> - <center> - <VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" spacing="30.0" BorderPane.alignment="CENTER"> - <children> - <Button mnemonicParsing="false" text="Button" /> - <Button mnemonicParsing="false" text="Button" /> - <Button mnemonicParsing="false" text="Button" /> - </children> - </VBox> - </center> - </BorderPane> - </children> -</AnchorPane> +<VBox fx:id="parent" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" spacing="50.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MainMenuController"> + <children> + <Pane VBox.vgrow="ALWAYS" /> + <Text id="gameTitle" strokeType="OUTSIDE" strokeWidth="0.0" text="Battlearena" /> + <Button mnemonicParsing="false" onAction="#playScene" text="Play" VBox.vgrow="ALWAYS"> + <VBox.margin> + <Insets top="20.0" /> + </VBox.margin> + </Button> + <Button mnemonicParsing="false" text="Map Creator" VBox.vgrow="ALWAYS" /> + <Button mnemonicParsing="false" onAction="#statisticsScene" text="Statistics" VBox.vgrow="ALWAYS" /> + <Button mnemonicParsing="false" onAction="#optionsScene" text="Options" /> + <Button fx:id="exitButton" alignment="CENTER" mnemonicParsing="false" onAction="#exit" text="Exit" /> + <Pane VBox.vgrow="ALWAYS" /> + <Pane layoutX="10.0" layoutY="395.0" VBox.vgrow="ALWAYS" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/MenuBorderPane.fxml b/src/main/resources/fxml/MenuBorderPane.fxml new file mode 100644 index 0000000000000000000000000000000000000000..3d57e01ff6b3502f741c6c780cf56e6c04bf6419 --- /dev/null +++ b/src/main/resources/fxml/MenuBorderPane.fxml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Button?> +<?import javafx.scene.image.Image?> +<?import javafx.scene.image.ImageView?> +<?import javafx.scene.layout.BorderPane?> + +<BorderPane id="mainMenu" fx:id="parent" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MenuBorderPaneController"> + <right> + <Button fx:id="btnRight" mnemonicParsing="false" onAction="#easterEgg" prefWidth="111.0" BorderPane.alignment="BOTTOM_CENTER"> + <graphic> + <ImageView fx:id="imgRight" fitHeight="845.0" fitWidth="799.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@../textures/images/gear_with_shadow.png" /> + </image> + </ImageView> + </graphic> + </Button> + </right> + <left> + <Button mnemonicParsing="false" BorderPane.alignment="BOTTOM_CENTER"> + <graphic> + <ImageView fx:id="imgLeft" fitHeight="904.0" fitWidth="856.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@../textures/images/dont_delete_or_ui_will_break.png" /> + </image> + </ImageView> + </graphic> + </Button> + </left> +</BorderPane> diff --git a/src/main/resources/fxml/Multiplayer.fxml b/src/main/resources/fxml/Multiplayer.fxml new file mode 100644 index 0000000000000000000000000000000000000000..690769c28f168b253fbfe41f6e5e559e0decc270 --- /dev/null +++ b/src/main/resources/fxml/Multiplayer.fxml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.layout.VBox?> + + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="50.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MultiplayerController"> + <children> + <Pane maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" /> + <Button mnemonicParsing="false" onAction="#multiplayerCreateScene" text="Create" VBox.vgrow="ALWAYS"> + <VBox.margin> + <Insets top="20.0" /> + </VBox.margin> + </Button> + <Button mnemonicParsing="false" onAction="#multiplayerJoinScene" text="Join" VBox.vgrow="ALWAYS"> + <VBox.margin> + <Insets bottom="50.0" /> + </VBox.margin> + </Button> + <Button alignment="CENTER" mnemonicParsing="false" onAction="#playScene" text="Back"> + <VBox.margin> + <Insets /> + </VBox.margin> + </Button> + <Pane VBox.vgrow="ALWAYS" /> + <Pane VBox.vgrow="ALWAYS" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/MultiplayerCreate.fxml b/src/main/resources/fxml/MultiplayerCreate.fxml new file mode 100644 index 0000000000000000000000000000000000000000..b0909c0079e798d74543c95dfcb6c6f19d6cf72e --- /dev/null +++ b/src/main/resources/fxml/MultiplayerCreate.fxml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.RadioButton?> +<?import javafx.scene.control.TextField?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Text?> + + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MultiplayerCreateController"> + <children> + <Pane VBox.vgrow="ALWAYS" /> + <HBox alignment="TOP_CENTER" spacing="20.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> + <TextField /> + </children> + <VBox.margin> + <Insets top="50.0" /> + </VBox.margin> + </HBox> + <HBox alignment="TOP_CENTER" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="213.0" spacing="20.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> + <TextField /> + </children> + </HBox> + <HBox alignment="TOP_CENTER" spacing="10.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> + <RadioButton mnemonicParsing="false" text="Yes" /> + <RadioButton mnemonicParsing="false" text="No" /> + </children> + </HBox> + <AnchorPane minHeight="-Infinity" prefHeight="39.0" prefWidth="600.0"> + <children> + <VBox alignment="TOP_CENTER" layoutX="250.0" prefHeight="200.0" prefWidth="100.0" AnchorPane.leftAnchor="250.0" AnchorPane.rightAnchor="250.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text" /> + </children> + </VBox> + </children> + <VBox.margin> + <Insets top="20.0" /> + </VBox.margin> + </AnchorPane> + <Button mnemonicParsing="false" text="Start" /> + <Button mnemonicParsing="false" onAction="#multiplayerScene" text="Back" /> + <Pane VBox.vgrow="ALWAYS" /> + <Pane VBox.vgrow="ALWAYS" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/MultiplayerJoin.fxml b/src/main/resources/fxml/MultiplayerJoin.fxml new file mode 100644 index 0000000000000000000000000000000000000000..e8a48e621d53819dee9b9bf53b9440b4bbd1bb9a --- /dev/null +++ b/src/main/resources/fxml/MultiplayerJoin.fxml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.TextField?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Text?> + + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="50.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MultiplayerJoinController"> + <children> + <Pane maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="IP Adress:" /> + <TextField maxWidth="-Infinity" /> + <Button mnemonicParsing="false" text="Connect" VBox.vgrow="ALWAYS" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="[Error Message]" /> + <Pane maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" /> + <Button alignment="CENTER" mnemonicParsing="false" onAction="#multiplayerScene" text="Back" /> + <Pane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="20.0" VBox.vgrow="ALWAYS" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/Options.fxml b/src/main/resources/fxml/Options.fxml new file mode 100644 index 0000000000000000000000000000000000000000..79f14cd61fc942bff138bc3a22443bdf8f9ef2a0 --- /dev/null +++ b/src/main/resources/fxml/Options.fxml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.Slider?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Text?> + + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.OptionsController"> + <children> + <HBox alignment="CENTER"> + <children> + <VBox alignment="TOP_CENTER" spacing="10.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Volume:" /> + <Slider fx:id="volumeSlider" blockIncrement="25.0" majorTickUnit="100.0" minorTickCount="1" prefHeight="14.0" prefWidth="480.0" showTickLabels="true" value="75.0" VBox.vgrow="NEVER" /> + </children> + </VBox> + </children> + </HBox> + <Button mnemonicParsing="false" onAction="#creditScene" text="Credits" /> + <Button mnemonicParsing="false" onAction="#mainMenuScene" text="Back" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/Play.fxml b/src/main/resources/fxml/Play.fxml new file mode 100644 index 0000000000000000000000000000000000000000..1cdd69e375cc8a700854d3e66b5caa1a8b9d6ad7 --- /dev/null +++ b/src/main/resources/fxml/Play.fxml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Button?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.layout.VBox?> + + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.PlayController"> + <children> + <Pane VBox.vgrow="ALWAYS" /> + <Button mnemonicParsing="false" onAction="#localScene" text="Local" /> + <Button mnemonicParsing="false" onAction="#multiplayerScene" text="Multiplayer" /> + <Button alignment="CENTER" mnemonicParsing="false" onAction="#mainMenuScene" text="Back" /> + <Pane VBox.vgrow="ALWAYS" /> + <Pane VBox.vgrow="ALWAYS" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/SkinSelection.fxml b/src/main/resources/fxml/SkinSelection.fxml new file mode 100644 index 0000000000000000000000000000000000000000..97773771860f208bdfa49f51c5219c0e89e16ef3 --- /dev/null +++ b/src/main/resources/fxml/SkinSelection.fxml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.ToggleButton?> +<?import javafx.scene.control.ToggleGroup?> +<?import javafx.scene.image.Image?> +<?import javafx.scene.image.ImageView?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.VBox?> + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.SkinSelectionController"> + <children> + <HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="40.0"> + <children> + <ToggleButton contentDisplay="TOP" mnemonicParsing="false" text="Elias"> + <graphic> + <ImageView fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@../textures/images/elias.png" /> + </image> + </ImageView> + </graphic> + <toggleGroup> + <ToggleGroup fx:id="selectionButton" /> + </toggleGroup> + </ToggleButton> + <ToggleButton contentDisplay="TOP" mnemonicParsing="false" text="Erzan" toggleGroup="$selectionButton"> + <graphic> + <ImageView fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@../textures/images/erzan.png" /> + </image> + </ImageView> + </graphic> + </ToggleButton> + <ToggleButton contentDisplay="TOP" mnemonicParsing="false" text="Martin" toggleGroup="$selectionButton"> + <graphic> + <ImageView fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@../textures/images/martin.png" /> + </image> + </ImageView> + </graphic> + </ToggleButton> + </children> + </HBox> + <Button mnemonicParsing="false" onAction="#gameScene" text="Start" /> + <Button mnemonicParsing="false" onAction="#back" text="Back" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/Statistics.fxml b/src/main/resources/fxml/Statistics.fxml new file mode 100644 index 0000000000000000000000000000000000000000..cb429d7b51d3d377a00e0495feee430c61cd7998 --- /dev/null +++ b/src/main/resources/fxml/Statistics.fxml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.chart.PieChart?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Text?> + + +<VBox fx:id="parent" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" spacing="50.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.StatisticsController"> + <children> + <HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="30.0"> + <children> + <VBox alignment="CENTER_RIGHT" prefHeight="200.0" prefWidth="100.0" spacing="10.0" HBox.hgrow="ALWAYS"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Kills:" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Deaths:" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Blocks Destroyed:" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Games won:" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Games lost:" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Ingame time:" /> + </children> + </VBox> + <VBox alignment="CENTER_LEFT" prefHeight="200.0" prefWidth="100.0" spacing="10.0" HBox.hgrow="ALWAYS"> + <children> + <Text fx:id="kills" strokeType="OUTSIDE" strokeWidth="0.0" text="Text" /> + <Text fx:id="deaths" strokeType="OUTSIDE" strokeWidth="0.0" text="Text" /> + <Text fx:id="blocks" strokeType="OUTSIDE" strokeWidth="0.0" text="Text" /> + <Text fx:id="gamesWon" strokeType="OUTSIDE" strokeWidth="0.0" text="Text" /> + <Text fx:id="gamesLost" strokeType="OUTSIDE" strokeWidth="0.0" text="Text" /> + <Text fx:id="gameTime" strokeType="OUTSIDE" strokeWidth="0.0" text="Text" /> + </children> + <HBox.margin> + <Insets /> + </HBox.margin> + </VBox> + <VBox prefHeight="200.0" prefWidth="100.0"> + <children> + <PieChart fx:id="kd" /> + <PieChart fx:id="wl" /> + </children> + </VBox> + </children> + </HBox> + <Button mnemonicParsing="false" onAction="#mainMenuScene" text="Back" /> + </children> +</VBox> diff --git a/src/main/resources/sound/music/cocBackgroundMusicTest.mp3 b/src/main/resources/sound/music/cocBackgroundMusicTest.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..e916ecb6c0b6487e9bcb8ca6c3d54f6259eac9dc Binary files /dev/null and b/src/main/resources/sound/music/cocBackgroundMusicTest.mp3 differ diff --git a/src/main/resources/sound/music/spongeBob.mp3 b/src/main/resources/sound/music/spongeBob.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..cd919cc16ea0c103c0cc1c095f4a19ce5c88960c Binary files /dev/null and b/src/main/resources/sound/music/spongeBob.mp3 differ diff --git a/src/main/resources/sound/music/stadiumRave.mp3 b/src/main/resources/sound/music/stadiumRave.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..990274fd88b95bfc5fe584184f838cbc54c2dbdc Binary files /dev/null and b/src/main/resources/sound/music/stadiumRave.mp3 differ diff --git a/src/main/resources/sound/music/wii.mp3 b/src/main/resources/sound/music/wii.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..8b471420a2a4fbb8ff28b6ff2f8cfee463670097 Binary files /dev/null and b/src/main/resources/sound/music/wii.mp3 differ diff --git a/src/main/resources/styles/style.css b/src/main/resources/styles/style.css new file mode 100644 index 0000000000000000000000000000000000000000..bb2a6b5c6f0ed83f68a407a24e34124a8caec3fe --- /dev/null +++ b/src/main/resources/styles/style.css @@ -0,0 +1,65 @@ +* { + -fx-dark-brown: #3c2014; + -fx-brown: #956233; +} + +.root { + -fx-font-family: "Starship Shadow"; + -fx-text-fill: -fx-brown; + -fx-font-size: 50; + -fx-background-color: black; +} + +#mainMenu{ + -fx-background-image: url("../textures/images/background.png"); + -fx-background-size: cover; +} + +#gameTitle { + -fx-font-size: 100; +} + +.button { + -fx-text-fill: -fx-brown; + -fx-background-color: none; + -fx-skin: "de.hdm_stuttgart.battlearena.Controller.ButtonTransition"; +} + +.accordion { + -fx-font-size: 30; +} + +/* https://dx.dragan.ba/javafx-radiobutton-custom-css/ */ +.radio-button .radio { + -fx-border-width: 1px; + -fx-border-color: -fx-dark-brown; + -fx-background-color: none; + -fx-background-image: null; + -fx-border-radius: 15px; + -fx-padding: 3px; +} + +.radio-button .dot { + -fx-padding: 8px; +} + +.radio-button:selected .dot { + -fx-background-color: -fx-dark-brown; + -fx-background-insets: 0; +} + +.slider .track { + -fx-background-color: rgba(0, 0, 0, 0.5); + -fx-pref-height: 0.2em; + } + +.slider .thumb { + -fx-pref-height: 0.6em; + -fx-pref-width: 0.4em; + -fx-background-color: -fx-brown; +} + +.toggle-button { + -fx-skin: "de.hdm_stuttgart.battlearena.Controller.ToggleButtonTransition"; + -fx-background-color: none; +} diff --git a/src/main/resources/textures/images/background.png b/src/main/resources/textures/images/background.png new file mode 100644 index 0000000000000000000000000000000000000000..67ec5faee876e21cc496b5a4a265deed0a14a7cf Binary files /dev/null and b/src/main/resources/textures/images/background.png differ diff --git a/src/main/resources/textures/images/dont_delete_or_ui_will_break.png b/src/main/resources/textures/images/dont_delete_or_ui_will_break.png new file mode 100644 index 0000000000000000000000000000000000000000..271b72c9c2ea827a6a7b74b5612f4eba34b9253d Binary files /dev/null and b/src/main/resources/textures/images/dont_delete_or_ui_will_break.png differ diff --git a/src/main/resources/textures/images/elias.png b/src/main/resources/textures/images/elias.png new file mode 100644 index 0000000000000000000000000000000000000000..92a45fea76f21bc5eadeef287d5126c8a1278ef7 Binary files /dev/null and b/src/main/resources/textures/images/elias.png differ diff --git a/src/main/resources/textures/images/erzan.png b/src/main/resources/textures/images/erzan.png new file mode 100644 index 0000000000000000000000000000000000000000..2101d8665fa6cfe21d1eb1d94a4da796034f71c9 Binary files /dev/null and b/src/main/resources/textures/images/erzan.png differ diff --git a/src/main/resources/textures/images/gear_with_shadow.png b/src/main/resources/textures/images/gear_with_shadow.png new file mode 100644 index 0000000000000000000000000000000000000000..7dad227dd915ca1907589a15b55cecd734d03cb9 Binary files /dev/null and b/src/main/resources/textures/images/gear_with_shadow.png differ diff --git a/src/main/resources/textures/images/martin.png b/src/main/resources/textures/images/martin.png new file mode 100644 index 0000000000000000000000000000000000000000..fdaa4de0ea064ae8da30cc1a1e97799db9cb20aa Binary files /dev/null and b/src/main/resources/textures/images/martin.png differ diff --git a/src/main/resources/textures/images/rusty_metal.png b/src/main/resources/textures/images/rusty_metal.png new file mode 100644 index 0000000000000000000000000000000000000000..2b2ff5687299d78376613202e79447537f36ec9e Binary files /dev/null and b/src/main/resources/textures/images/rusty_metal.png differ diff --git a/src/main/resources/textures/images/vintage_paper_with_drawings.png b/src/main/resources/textures/images/vintage_paper_with_drawings.png new file mode 100644 index 0000000000000000000000000000000000000000..862a0ac453b013ad66807f109c987c1c85dbaae9 Binary files /dev/null and b/src/main/resources/textures/images/vintage_paper_with_drawings.png differ diff --git a/src/main/resources/textures/map/Grass01.png b/src/main/resources/textures/map/Grass01.png new file mode 100644 index 0000000000000000000000000000000000000000..e835d4676d2f80105626ece4d99b485a30b289fe Binary files /dev/null and b/src/main/resources/textures/map/Grass01.png differ diff --git a/src/main/resources/textures/map/Grass02.png b/src/main/resources/textures/map/Grass02.png new file mode 100644 index 0000000000000000000000000000000000000000..144fad81f75b681454b58768081394cb40aaeead Binary files /dev/null and b/src/main/resources/textures/map/Grass02.png differ diff --git a/src/main/resources/textures/map/Grass04.png b/src/main/resources/textures/map/Grass04.png new file mode 100644 index 0000000000000000000000000000000000000000..4ce012b5eac6c41488efe96c5f66eb43c28c98ce Binary files /dev/null and b/src/main/resources/textures/map/Grass04.png differ diff --git a/src/main/resources/textures/map/Stone01.png b/src/main/resources/textures/map/Stone01.png new file mode 100644 index 0000000000000000000000000000000000000000..b6cf13f66633060803264739b889f64c32877a0e Binary files /dev/null and b/src/main/resources/textures/map/Stone01.png differ diff --git a/src/main/resources/textures/map/Stone02.png b/src/main/resources/textures/map/Stone02.png new file mode 100644 index 0000000000000000000000000000000000000000..2ac41bee77062960aa2d8cfc921f66e45de629ba Binary files /dev/null and b/src/main/resources/textures/map/Stone02.png differ diff --git a/src/main/resources/textures/map/mapPlaceholder.png b/src/main/resources/textures/map/mapPlaceholder.png deleted file mode 100644 index ca3f707dff2cf59fbcf284b896a786fafa5e9180..0000000000000000000000000000000000000000 Binary files a/src/main/resources/textures/map/mapPlaceholder.png and /dev/null differ diff --git a/src/main/resources/textures/player/HumanDown01.png b/src/main/resources/textures/player/HumanDown01.png new file mode 100644 index 0000000000000000000000000000000000000000..ee8c9024a240bfec9f28cdecffff3060d3eb769e Binary files /dev/null and b/src/main/resources/textures/player/HumanDown01.png differ diff --git a/src/main/resources/textures/player/HumanDown02.png b/src/main/resources/textures/player/HumanDown02.png new file mode 100644 index 0000000000000000000000000000000000000000..3a96754826bed31e6baad1d519a71c2e97680821 Binary files /dev/null and b/src/main/resources/textures/player/HumanDown02.png differ diff --git a/src/main/resources/textures/player/downOne.png b/src/main/resources/textures/player/downOne.png new file mode 100644 index 0000000000000000000000000000000000000000..d1e261cc01b3a32bf937536716162ec5c61d0d50 Binary files /dev/null and b/src/main/resources/textures/player/downOne.png differ diff --git a/src/main/resources/textures/player/downTwo.png b/src/main/resources/textures/player/downTwo.png new file mode 100644 index 0000000000000000000000000000000000000000..9a14543c8d06be035ea8048428faeaa218faec32 Binary files /dev/null and b/src/main/resources/textures/player/downTwo.png differ diff --git a/src/main/resources/textures/player/leftOne.png b/src/main/resources/textures/player/leftOne.png new file mode 100644 index 0000000000000000000000000000000000000000..13cc7b495f2647d10917ebda3046cd8af32f9553 Binary files /dev/null and b/src/main/resources/textures/player/leftOne.png differ diff --git a/src/main/resources/textures/player/leftTwo.png b/src/main/resources/textures/player/leftTwo.png new file mode 100644 index 0000000000000000000000000000000000000000..cbed81ae3a90ef128cb1bd913329c211c69030bd Binary files /dev/null and b/src/main/resources/textures/player/leftTwo.png differ diff --git a/src/main/resources/textures/player/rightOne.png b/src/main/resources/textures/player/rightOne.png new file mode 100644 index 0000000000000000000000000000000000000000..5d26f27d4b44906c9c17e0625329e56407c86d8d Binary files /dev/null and b/src/main/resources/textures/player/rightOne.png differ diff --git a/src/main/resources/textures/player/rightTwo.png b/src/main/resources/textures/player/rightTwo.png new file mode 100644 index 0000000000000000000000000000000000000000..7cf375e6ef6a51ed56f485a03bb5988e21a7ed37 Binary files /dev/null and b/src/main/resources/textures/player/rightTwo.png differ diff --git a/src/main/resources/textures/player/upOne.png b/src/main/resources/textures/player/upOne.png new file mode 100644 index 0000000000000000000000000000000000000000..0e3134b32646f8587e59c68a0c62a9c8697876e1 Binary files /dev/null and b/src/main/resources/textures/player/upOne.png differ diff --git a/src/main/resources/textures/player/upTwo.png b/src/main/resources/textures/player/upTwo.png new file mode 100644 index 0000000000000000000000000000000000000000..2f698853e288792ce6879baa96d7999552fd17fe Binary files /dev/null and b/src/main/resources/textures/player/upTwo.png differ diff --git a/src/main/resources/textures/weapons/SwordDown.png b/src/main/resources/textures/weapons/SwordDown.png new file mode 100644 index 0000000000000000000000000000000000000000..dba0a85781e2e79ac38fc7004e892f7db82e04b5 Binary files /dev/null and b/src/main/resources/textures/weapons/SwordDown.png differ diff --git a/src/main/resources/textures/weapons/SwordLeft.png b/src/main/resources/textures/weapons/SwordLeft.png new file mode 100644 index 0000000000000000000000000000000000000000..f83bcf7fa199d1e4fd97352a9688a78b6a3df757 Binary files /dev/null and b/src/main/resources/textures/weapons/SwordLeft.png differ diff --git a/src/main/resources/textures/weapons/SwordRight.png b/src/main/resources/textures/weapons/SwordRight.png new file mode 100644 index 0000000000000000000000000000000000000000..35bf135d41218bbef6c6409ab4bc99efad373754 Binary files /dev/null and b/src/main/resources/textures/weapons/SwordRight.png differ diff --git a/src/main/resources/textures/weapons/SwordSwingDown.png b/src/main/resources/textures/weapons/SwordSwingDown.png new file mode 100644 index 0000000000000000000000000000000000000000..3d160e5d8d518ca696860cdc77a90b11d2e7aec8 Binary files /dev/null and b/src/main/resources/textures/weapons/SwordSwingDown.png differ diff --git a/src/main/resources/textures/weapons/SwordSwingLeft.png b/src/main/resources/textures/weapons/SwordSwingLeft.png new file mode 100644 index 0000000000000000000000000000000000000000..75dd39ee517e0714684c979e9e5052096fda3eaf Binary files /dev/null and b/src/main/resources/textures/weapons/SwordSwingLeft.png differ diff --git a/src/main/resources/textures/weapons/SwordSwingRight.png b/src/main/resources/textures/weapons/SwordSwingRight.png new file mode 100644 index 0000000000000000000000000000000000000000..a78877e88fdb0b55ffa4b5bb77f036f00f8793c1 Binary files /dev/null and b/src/main/resources/textures/weapons/SwordSwingRight.png differ diff --git a/src/main/resources/textures/weapons/SwordSwingUp.png b/src/main/resources/textures/weapons/SwordSwingUp.png new file mode 100644 index 0000000000000000000000000000000000000000..62ece9f708265ca4b3a9238c8437999825070f71 Binary files /dev/null and b/src/main/resources/textures/weapons/SwordSwingUp.png differ diff --git a/src/main/resources/textures/weapons/SwordUp.png b/src/main/resources/textures/weapons/SwordUp.png new file mode 100644 index 0000000000000000000000000000000000000000..3c6ba9f3c3170669b0e24a4bcda8ebad952f42ca Binary files /dev/null and b/src/main/resources/textures/weapons/SwordUp.png differ diff --git a/src/main/resources/videos/allMyFellas.mp4 b/src/main/resources/videos/allMyFellas.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4234d4da1c07a7e775bced2e4e44c2329c8be972 Binary files /dev/null and b/src/main/resources/videos/allMyFellas.mp4 differ diff --git a/src/main/resources/videos/bobama.mp4 b/src/main/resources/videos/bobama.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..2052b4d842a398ac1788025ed579c5054fdad680 Binary files /dev/null and b/src/main/resources/videos/bobama.mp4 differ diff --git a/src/main/resources/videos/credits.mp4 b/src/main/resources/videos/credits.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..310acc2c75039d7bdad7f3d642e2d0e828573811 Binary files /dev/null and b/src/main/resources/videos/credits.mp4 differ diff --git a/src/main/resources/videos/gameboy.mp4 b/src/main/resources/videos/gameboy.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..91a1eaa78366adbb3686a07594417fd9c8832126 Binary files /dev/null and b/src/main/resources/videos/gameboy.mp4 differ diff --git a/src/main/resources/videos/gamecube.mp4 b/src/main/resources/videos/gamecube.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..135416e7b63fc25ed1e3e2b744c6d14a78692b99 Binary files /dev/null and b/src/main/resources/videos/gamecube.mp4 differ diff --git a/src/main/resources/videos/lifeCouldBeMonke.mp4 b/src/main/resources/videos/lifeCouldBeMonke.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..67a0106470b6e00d968f9930b5081d517545b3e4 Binary files /dev/null and b/src/main/resources/videos/lifeCouldBeMonke.mp4 differ diff --git a/src/main/resources/videos/monke.mp4 b/src/main/resources/videos/monke.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c6d5f3c2e7f390276d22b26e46f462bb1e281d98 Binary files /dev/null and b/src/main/resources/videos/monke.mp4 differ diff --git a/src/main/resources/videos/pepe.mp4 b/src/main/resources/videos/pepe.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..51a5f0763924b4c623ac2b198d50b272b4758b15 Binary files /dev/null and b/src/main/resources/videos/pepe.mp4 differ diff --git a/src/main/resources/videos/russianKid.mp4 b/src/main/resources/videos/russianKid.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..08a7fe2015e28dc08e1ca6fbe907e46f691cec21 Binary files /dev/null and b/src/main/resources/videos/russianKid.mp4 differ diff --git a/src/main/resources/videos/sony.mp4 b/src/main/resources/videos/sony.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9d96aebfc39a033d379d613070c97e6122f8a175 Binary files /dev/null and b/src/main/resources/videos/sony.mp4 differ