From 44be2981033b3840ff0ed927cfd5e7de0609e72b Mon Sep 17 00:00:00 2001 From: J0QUE Date: Sun, 19 Mar 2017 22:53:15 +0100 Subject: [PATCH] Added modloader basics, added location properties file --- src/main/java/nl/minkema/leendert/Game.java | 5 +- src/main/java/nl/minkema/leendert/Main.java | 25 +- src/main/java/nl/minkema/leendert/Menu.java | 45 +-- .../java/nl/minkema/leendert/ModLoader.java | 19 ++ src/main/resources/svg/p1.svg | 241 ++++++++++++++ src/main/resources/svg/p2.svg | 222 +++++++++++++ src/main/resources/svg/p3.svg | 306 ++++++++++++++++++ src/main/resources/svg/p4.svg | 264 +++++++++++++++ src/main/resources/svg/p5.svg | 128 ++++++++ src/main/resources/text/locations.properties | 101 ++++++ 10 files changed, 1329 insertions(+), 27 deletions(-) create mode 100644 src/main/java/nl/minkema/leendert/ModLoader.java create mode 100644 src/main/resources/svg/p1.svg create mode 100644 src/main/resources/svg/p2.svg create mode 100644 src/main/resources/svg/p3.svg create mode 100644 src/main/resources/svg/p4.svg create mode 100644 src/main/resources/svg/p5.svg create mode 100644 src/main/resources/text/locations.properties diff --git a/src/main/java/nl/minkema/leendert/Game.java b/src/main/java/nl/minkema/leendert/Game.java index 9540ae3..a96895f 100644 --- a/src/main/java/nl/minkema/leendert/Game.java +++ b/src/main/java/nl/minkema/leendert/Game.java @@ -20,7 +20,8 @@ import java.util.HashMap; public class Game extends Pane { - public static int[][] locations = {{290, 163}, {331, 162}, {372, 162}, {412, 161}, {446, 160}, {466, 201}, {429, 202}, {382, 201}, {340, 201}, {313, 201}, {274, 201}, {253, 235}, {293, 242}, {339, 243}, {370, 243}, {419, 242}, {447, 241}, {484, 241}, {517, 277}, {468, 277}, {431, 278}, {402, 280}, {344, 281}, {304, 282}, {277, 282}, {228, 283}, {216, 319}, {256, 319}, {291, 320}, {338, 324}, {367, 324}, {407, 323}, {453, 320}, {486, 320}, {528, 321}, {554, 359}, {506, 362}, {478, 362}, {432, 362}, {395, 361}, {346, 359}, {302, 360}, {272, 360}, {223, 359}, {203, 359}, {179, 359}, {210, 398}, {248, 399}, {292, 400}, {333, 404}, {373, 406}, {404, 396}, {446, 399}, {484, 401}, {523, 402}, {575, 402}, {563, 430}, {520, 438}, {460, 441}, {435, 443}, {394, 442}, {361, 442}, {311, 442}, {275, 439}, {225, 438}, {194, 438}, {203, 473}, {243, 477}, {297, 482}, {335, 482}, {375, 481}, {412, 481}, {450, 481}, {486, 480}, {533, 480}, {520, 517}, {465, 520}, {426, 522}, {389, 523}, {350, 524}, {317, 524}, {276, 524}, {238, 524}, {243, 553}, {276, 555}, {332, 558}, {370, 559}, {415, 560}, {456, 559}, {484, 560}, {479, 594}, {432, 596}, {387, 596}, {347, 597}, {313, 598}, {272, 598}, {287, 635}, {332, 636}, {368, 639}, {417, 642}, {449, 643}}; + public static int[][] locations; + public static final HashMap specials = new HashMap<>(); @@ -28,7 +29,7 @@ public class Game extends Pane { public Game() { Collections.shuffle(players); - Image bord = new Image("/svg/Bord.svg"); + Image bord = new Image(ModLoader.getFile("/svg/Bord.svg")); ImageView view = new ImageView(bord); view.setPreserveRatio(true); diff --git a/src/main/java/nl/minkema/leendert/Main.java b/src/main/java/nl/minkema/leendert/Main.java index c0ed22d..2a7d962 100644 --- a/src/main/java/nl/minkema/leendert/Main.java +++ b/src/main/java/nl/minkema/leendert/Main.java @@ -2,12 +2,11 @@ package nl.minkema.leendert; import de.codecentric.centerdevice.javafxsvg.SvgImageLoaderFactory; import javafx.application.Application; -import javafx.scene.Group; import javafx.scene.Scene; -import javafx.scene.media.Media; -import javafx.scene.media.MediaPlayer; import javafx.stage.Stage; +import java.util.Properties; + /** * @author J0QUE * @version 1.0 @@ -28,7 +27,25 @@ public class Main extends Application { } - public static void main(String[] args) { + public static void main(String[] args) throws Exception { + + Properties properties = new Properties(); + properties.load(Main.class.getResourceAsStream("/text/locations.properties")); + Game.locations = new int[properties.size()][2]; + for (int i = 0; i < properties.size(); i++) { + String[] split = properties.getProperty(String.valueOf(i)).split(","); + Game.locations[i] = new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1])}; + } + + int[][] locations = Game.locations; + for (int i = 0; i < locations.length; i++) { + int[] k = locations[i]; + if (k[0] == k[1] && k[0] == 0) { + throw new Exception("Invalid Location at index " + i); + } + } + + launch(args); } } diff --git a/src/main/java/nl/minkema/leendert/Menu.java b/src/main/java/nl/minkema/leendert/Menu.java index 4f27ea4..a364e15 100644 --- a/src/main/java/nl/minkema/leendert/Menu.java +++ b/src/main/java/nl/minkema/leendert/Menu.java @@ -26,53 +26,56 @@ import java.util.Random; */ public class Menu extends Group { - public static ArrayList playerColors = new ArrayList<>(); + private static Random random = new Random(System.currentTimeMillis()); + private final Image[] images; public Menu() throws URISyntaxException, MalformedURLException { - while (playerColors.size() < 21) { - Color c = getRandomColor(); - if (!playerColors.contains(c)) { - playerColors.add(c); - } - } ArrayList nodes = new ArrayList<>(); Image bg = new Image("https://s-media-cache-ak0.pinimg.com/originals/56/b2/3e/56b23e286dc03db415db7af75d15d58a.jpg"); ImageView view = new ImageView(bg); - System.out.println(bg.getHeight()); + view.setX(0); view.setY(0); view.setFitHeight(900); view.setPreserveRatio(true); + String loc = this.getClass().getResource("/music/menu.mp4").toString(); //loc = new File("menu.mp4").toURI().toURL().toString(); - System.out.println(loc); Media music = new Media(loc); - MediaPlayer menuplayer = new MediaPlayer(music); menuplayer.setCycleCount(Integer.MAX_VALUE); menuplayer.setVolume(0.6f); menuplayer.setAutoPlay(true); menuplayer.play(); menuplayer.play(); + nodes.add(view); nodes.add(createButton("2 players", 100, 100, event -> { System.out.println("2 players"); })); nodes.add(createButton("3 players", 100, 150, event -> System.out.println("3 players"))); - - Rectangle rectangle = new Rectangle(200, 200, 200, 200); - rectangle.setOnMouseClicked(e -> { - System.out.println("Click"); - Game.players.add(new Player(new Image("https://lh3.ggpht.com/OOXV4V9YyovafA10xZhq0QgWNwFwCEhMI9kWJ2FDkjMmLa7rDWJmSmnsgOtMWdDGg3A=w300", 50, 0, true, true))); - Game.players.add(new Player(new Image("https://lh3.googleusercontent.com/SQ3DumBwiaVOVXa0EKGfG5r1932Hj81-DtNVKC7IWjPlBA4lUU4k5BI0wbU1ivKmm6E=w170", 50, 0, true, true))); - Main.scene.setRoot(new Game()); - }); - rectangle.setFill(Color.TRANSPARENT); - nodes.add(rectangle); + int imagewidth = 150; + images = new Image[]{ + new Image("/svg/p1.svg", imagewidth, 0, true, false), + new Image("/svg/p2.svg", imagewidth, 0, true, false), + new Image("/svg/p3.svg", imagewidth, 0, true, false), + new Image("/svg/p4.svg", imagewidth, 0, true, false), + new Image("/svg/p5.svg", imagewidth, 0, true, false)}; + int x = 0, y = 0; + for (Image i : images) { + ImageView iv = new ImageView(i); + iv.setX(800 + x); + iv.setY(200 + y); + x += i.getRequestedWidth(); + if (x > 200) { + y += 150; + x = 0; + } + nodes.add(iv); + } getChildren().addAll(nodes); - playerColors.forEach(System.out::println); } public static StackPane createButton(String string, double x, double y, EventHandler onClick) { diff --git a/src/main/java/nl/minkema/leendert/ModLoader.java b/src/main/java/nl/minkema/leendert/ModLoader.java new file mode 100644 index 0000000..c373c49 --- /dev/null +++ b/src/main/java/nl/minkema/leendert/ModLoader.java @@ -0,0 +1,19 @@ +package nl.minkema.leendert; + +import java.io.File; + +/** + * @author J0QUE + * @version 1.0 + */ +public class ModLoader { + + public static String getFile(String file) { + File f = new File("mods" + file); + if (f.exists()) { + return f.getAbsolutePath(); + } + return file; + } + +} diff --git a/src/main/resources/svg/p1.svg b/src/main/resources/svg/p1.svg new file mode 100644 index 0000000..ba6adde --- /dev/null +++ b/src/main/resources/svg/p1.svg @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/svg/p2.svg b/src/main/resources/svg/p2.svg new file mode 100644 index 0000000..ea96786 --- /dev/null +++ b/src/main/resources/svg/p2.svg @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/svg/p3.svg b/src/main/resources/svg/p3.svg new file mode 100644 index 0000000..7bab421 --- /dev/null +++ b/src/main/resources/svg/p3.svg @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/svg/p4.svg b/src/main/resources/svg/p4.svg new file mode 100644 index 0000000..1565082 --- /dev/null +++ b/src/main/resources/svg/p4.svg @@ -0,0 +1,264 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/svg/p5.svg b/src/main/resources/svg/p5.svg new file mode 100644 index 0000000..3ffa3d2 --- /dev/null +++ b/src/main/resources/svg/p5.svg @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/text/locations.properties b/src/main/resources/text/locations.properties new file mode 100644 index 0000000..2d08470 --- /dev/null +++ b/src/main/resources/text/locations.properties @@ -0,0 +1,101 @@ +0: 290,163 +1: 331,162 +2: 372,162 +3: 412,161 +4: 446,160 +5: 466,201 +6: 429,202 +7: 382,201 +8: 340,201 +9: 313,201 +10: 274,201 +11: 253,235 +12: 293,242 +13: 339,243 +14: 370,243 +15: 419,242 +16: 447,241 +17: 484,241 +18: 517,277 +19: 468,277 +20: 431,278 +21: 402,280 +22: 344,281 +23: 304,282 +24: 277,282 +25: 228,283 +26: 216,319 +27: 256,319 +28: 291,320 +29: 338,324 +30: 367,324 +31: 407,323 +32: 453,320 +33: 486,320 +34: 528,321 +35: 554,359 +36: 506,362 +37: 478,362 +38: 432,362 +39: 395,361 +40: 346,359 +41: 302,360 +42: 272,360 +43: 223,359 +44: 203,359 +45: 179,359 +46: 210,398 +47: 248,399 +48: 292,400 +49: 333,404 +50: 373,406 +51: 404,396 +52: 446,399 +53: 484,401 +54: 523,402 +55: 575,402 +56: 563,430 +57: 520,438 +58: 460,441 +59: 435,443 +60: 394,442 +61: 361,442 +62: 311,442 +63: 275,439 +64: 225,438 +65: 194,438 +66: 203,473 +67: 243,477 +68: 297,482 +69: 335,482 +70: 375,481 +71: 412,481 +72: 450,481 +73: 486,480 +74: 533,480 +75: 520,517 +76: 465,520 +77: 426,522 +78: 389,523 +79: 350,524 +80: 317,524 +81: 276,524 +82: 238,524 +83: 243,553 +84: 276,555 +85: 332,558 +86: 370,559 +87: 415,560 +88: 456,559 +89: 484,560 +90: 479,594 +91: 432,596 +92: 387,596 +93: 347,597 +94: 313,598 +95: 272,598 +96: 287,635 +97: 332,636 +98: 368,639 +99: 417,642 +100: 449,643 \ No newline at end of file