Commits

Richard Bair committed 689cb5b

Renamed LevelPanel to Level. Added some stuff to hgignore (stuff idea is generating).

Comments (0)

Files changed (5)

 syntax: regexp
 ^defender/target/(?!site)
+^defender/.idea
+^defender/lib
+^defender/defender.iml

defender/src/main/java/com/fxexperience/games/defender/games/simple/Enemy.java

 
     private static final Logger log = LoggerFactory.getLogger(Enemy.class);
 
-
     /**
      * The maximum life of this enemy.
      */

defender/src/main/java/com/fxexperience/games/defender/games/simple/Level.java

+/*
+ * Copyright (c) 2012, FX Experience. All rights  reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * Neither the name of the author nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.fxexperience.games.defender.games.simple;
+
+import javafx.geometry.Bounds;
+import javafx.geometry.Insets;
+import javafx.geometry.Point2D;
+import javafx.scene.Node;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.Region;
+import javafx.scene.shape.Path;
+import javafx.scene.shape.Rectangle;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * This UI represents the game board. It has all the tiles, towers, enemies, background, and so forth.
+ * The GameControlPanelUI is separate, and has the money values etc. A single Level has a single path
+ * (or set of paths) on which the enemies roam. Multiple waves of enemies will come following one or
+ * more of those paths.
+ */
+public class LevelPanel extends Region implements GamePulseListener {
+    private static final Logger log = LoggerFactory.getLogger(LevelPanel.class);
+
+    private static final double LEVEL_HEIGHT = 600;
+    private static final double LEVEL_WIDTH = 800;
+
+    private Region background;
+    private Rectangle clip;
+    private Pane enemyLayer;
+    private Pane towerLayer;
+    private Pane projectileLayer;
+
+    private LinkedList<Wave> waves;
+    private Wave wave;
+    private Path path;
+    private List<Enemy> enemies;
+    private List<Tower> towers;
+    private List<Projectile> projectiles;
+
+    public LevelPanel(final Path path, Wave... waves) {
+
+        getStyleClass().add("game-board");
+        this.waves = new LinkedList<>(Arrays.asList(waves));
+        this.path = path;
+
+        background = new Region();
+        background.getStyleClass().add("background");
+        enemies = new ArrayList<>();
+        enemyLayer = new Pane();
+        towers = new ArrayList<>();
+        projectiles = new ArrayList<>();
+        towerLayer = new Pane();
+        projectileLayer = new Pane();
+        getChildren().addAll(background, enemyLayer, towerLayer, projectileLayer);
+
+        clip = new Rectangle();
+        setClip(clip);
+    }
+
+    @Override
+    public void pulse() {
+
+        // process waves and spawning
+        if (wave != null && wave.hasMoreEnemies()) {
+            wave.pulse();
+        } else {
+            // todo need more smarts in here around detecting end of wave, level, etc
+            // probably would like to pause at the end of a wave and show a 'success' ui, then next wave only
+            // starts once the player says go
+            if (!waves.isEmpty()) {
+                wave = waves.remove();
+                wave.setLevel(this);
+                wave.setPath(path);
+            } else {
+                // todo spawning finished - when the remaining enemies are done we have finished the level...
+                log.info("No more enemies to spawn");
+                //
+                //        // The level is complete when the spawner has finished and all enemies have been destroyed
+                //        enemyLayer.getChildren().addListener(new ListChangeListener<Node>() {
+                //            @Override
+                //            public void onChanged(Change<? extends Node> change) {
+                //                if (enemyLayer.getChildren().isEmpty() && !complte) {
+                //                    System.out.println("WAVE COMPLETE");
+                //                    if (waves.isEmpty()) {
+                //                        System.out.println("LEVEL COMPLETE");
+                //                    } else {
+                //                        startWave();
+                //                    }
+                //                }
+                //            }
+                //        });
+            }
+        }
+
+        // pulse our sprites (cache to list to avoid concurrent modification problems - maybe could be done smarter)
+        List<GamePulseListener> pulsers = new ArrayList<>();
+        pulsers.addAll(enemies);
+        pulsers.addAll(towers);
+        pulsers.addAll(projectiles);
+        for (GamePulseListener pulser : pulsers) {
+            pulser.pulse();
+        }
+    }
+
+    public List<Enemy> findEnemiesInArea(Point2D center, int radius) {
+        List<Enemy> matches = new ArrayList<>();
+        for (Enemy enemy : enemies) {
+            Bounds bounds = enemy.getBoundsInParent();
+            if (center.getX() - radius <= bounds.getMaxX() && center.getX() + radius >= bounds.getMinX()
+                    && center.getY() - radius <= bounds.getMaxY() && center.getY() + radius >= bounds.getMinY()) {
+                matches.add(enemy);
+            }
+        }
+        return matches;
+    }
+
+    public void addEnemy(Enemy enemy) {
+        enemy.setLevel(this);
+        enemies.add(enemy);
+        enemyLayer.getChildren().add(enemy);
+    }
+
+    public void removeEnemy(Enemy enemy) {
+        enemy.setLevel(null);
+        enemies.remove(enemy);
+        enemyLayer.getChildren().remove(enemy);
+    }
+
+    public void addTower(Tower tower) {
+        tower.setLevel(this);
+        towers.add(tower);
+        towerLayer.getChildren().add(tower);
+    }
+
+    public void removeTower(Tower tower) {
+        tower.setLevel(null);
+        towers.remove(tower);
+        towerLayer.getChildren().remove(tower);
+    }
+
+    public void addProjectile(Projectile projectile) {
+        projectile.setLevel(this);
+        projectiles.add(projectile);
+        projectileLayer.getChildren().add(projectile);
+    }
+
+    public void removeProjectile(Projectile projectile) {
+        projectile.setLevel(null);
+        projectiles.remove(projectile);
+        projectileLayer.getChildren().remove(projectile);
+    }
+
+    @Override
+    protected double computeMinWidth(double v) {
+        return computePrefWidth(v);
+    }
+
+    @Override
+    protected double computeMinHeight(double v) {
+        return computePrefHeight(v);
+    }
+
+    @Override
+    protected double computePrefWidth(double v) {
+        final Insets insets = getInsets();
+        return LEVEL_WIDTH + insets.getLeft() + insets.getRight();
+    }
+
+    @Override
+    protected double computePrefHeight(double v) {
+        final Insets insets = getInsets();
+        return LEVEL_HEIGHT + insets.getTop() + insets.getBottom();
+    }
+
+    @Override
+    protected double computeMaxWidth(double v) {
+        return computePrefWidth(v);
+    }
+
+    @Override
+    protected double computeMaxHeight(double v) {
+        return computePrefHeight(v);
+    }
+
+    @Override
+    protected void layoutChildren() {
+        final Insets insets = getInsets();
+        final double x = insets.getLeft();
+        final double y = insets.getTop();
+        final double width = getWidth() - insets.getLeft() - insets.getRight();
+        final double height = getHeight() - insets.getTop() - insets.getBottom();
+
+        background.resizeRelocate(x, y, width, height);
+        enemyLayer.resizeRelocate(x, y, width, height);
+        towerLayer.resizeRelocate(x, y, width, height);
+        projectileLayer.resizeRelocate(x, y, width, height);
+        clip.setX(x);
+        clip.setY(y);
+        clip.setWidth(width);
+        clip.setHeight(height);
+
+        for (Node n : getChildren()) {
+            if (n != background) {
+                n.autosize();
+            }
+        }
+    }
+}

defender/src/main/java/com/fxexperience/games/defender/games/simple/LevelPanel.java

-/*
- * Copyright (c) 2012, FX Experience. All rights  reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided
- * with the distribution.
- *
- * Neither the name of the author nor the names of its contributors may be used to endorse or
- * promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.fxexperience.games.defender.games.simple;
-
-import javafx.geometry.Bounds;
-import javafx.geometry.Insets;
-import javafx.geometry.Point2D;
-import javafx.scene.Node;
-import javafx.scene.layout.Pane;
-import javafx.scene.layout.Region;
-import javafx.scene.shape.Path;
-import javafx.scene.shape.Rectangle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * This UI represents the game board. It has all the tiles, towers, enemies, background, and so forth.
- * The GameControlPanelUI is separate, and has the money values etc. A single Level has a single path
- * (or set of paths) on which the enemies roam. Multiple waves of enemies will come following one or
- * more of those paths.
- */
-public class LevelPanel extends Region implements GamePulseListener {
-    private static final Logger log = LoggerFactory.getLogger(LevelPanel.class);
-
-    private static final double LEVEL_HEIGHT = 600;
-    private static final double LEVEL_WIDTH = 800;
-
-    private Region background;
-    private Rectangle clip;
-    private Pane enemyLayer;
-    private Pane towerLayer;
-    private Pane projectileLayer;
-
-    private LinkedList<Wave> waves;
-    private Wave wave;
-    private Path path;
-    private List<Enemy> enemies;
-    private List<Tower> towers;
-    private List<Projectile> projectiles;
-
-    public LevelPanel(final Path path, Wave... waves) {
-
-        getStyleClass().add("game-board");
-        this.waves = new LinkedList<>(Arrays.asList(waves));
-        this.path = path;
-
-        background = new Region();
-        background.getStyleClass().add("background");
-        enemies = new ArrayList<>();
-        enemyLayer = new Pane();
-        towers = new ArrayList<>();
-        projectiles = new ArrayList<>();
-        towerLayer = new Pane();
-        projectileLayer = new Pane();
-        getChildren().addAll(background, enemyLayer, towerLayer, projectileLayer);
-
-        clip = new Rectangle();
-        setClip(clip);
-    }
-
-    @Override
-    public void pulse() {
-
-        // process waves and spawning
-        if (wave != null && wave.hasMoreEnemies()) {
-            wave.pulse();
-        } else {
-            // todo need more smarts in here around detecting end of wave, level, etc
-            // probably would like to pause at the end of a wave and show a 'success' ui, then next wave only
-            // starts once the player says go
-            if (!waves.isEmpty()) {
-                wave = waves.remove();
-                wave.setLevel(this);
-                wave.setPath(path);
-            } else {
-                // todo spawning finished - when the remaining enemies are done we have finished the level...
-                log.info("No more enemies to spawn");
-                //
-                //        // The level is complete when the spawner has finished and all enemies have been destroyed
-                //        enemyLayer.getChildren().addListener(new ListChangeListener<Node>() {
-                //            @Override
-                //            public void onChanged(Change<? extends Node> change) {
-                //                if (enemyLayer.getChildren().isEmpty() && !complte) {
-                //                    System.out.println("WAVE COMPLETE");
-                //                    if (waves.isEmpty()) {
-                //                        System.out.println("LEVEL COMPLETE");
-                //                    } else {
-                //                        startWave();
-                //                    }
-                //                }
-                //            }
-                //        });
-            }
-        }
-
-        // pulse our sprites (cache to list to avoid concurrent modification problems - maybe could be done smarter)
-        List<GamePulseListener> pulsers = new ArrayList<>();
-        pulsers.addAll(enemies);
-        pulsers.addAll(towers);
-        pulsers.addAll(projectiles);
-        for (GamePulseListener pulser : pulsers) {
-            pulser.pulse();
-        }
-    }
-
-    public List<Enemy> findEnemiesInArea(Point2D center, int radius) {
-        List<Enemy> matches = new ArrayList<>();
-        for (Enemy enemy : enemies) {
-            Bounds bounds = enemy.getBoundsInParent();
-            if (center.getX() - radius <= bounds.getMaxX() && center.getX() + radius >= bounds.getMinX()
-                    && center.getY() - radius <= bounds.getMaxY() && center.getY() + radius >= bounds.getMinY()) {
-                matches.add(enemy);
-            }
-        }
-        return matches;
-    }
-
-    public void addEnemy(Enemy enemy) {
-        enemy.setLevel(this);
-        enemies.add(enemy);
-        enemyLayer.getChildren().add(enemy);
-    }
-
-    public void removeEnemy(Enemy enemy) {
-        enemy.setLevel(null);
-        enemies.remove(enemy);
-        enemyLayer.getChildren().remove(enemy);
-    }
-
-    public void addTower(Tower tower) {
-        tower.setLevel(this);
-        towers.add(tower);
-        towerLayer.getChildren().add(tower);
-    }
-
-    public void removeTower(Tower tower) {
-        tower.setLevel(null);
-        towers.remove(tower);
-        towerLayer.getChildren().remove(tower);
-    }
-
-    public void addProjectile(Projectile projectile) {
-        projectile.setLevel(this);
-        projectiles.add(projectile);
-        projectileLayer.getChildren().add(projectile);
-    }
-
-    public void removeProjectile(Projectile projectile) {
-        projectile.setLevel(null);
-        projectiles.remove(projectile);
-        projectileLayer.getChildren().remove(projectile);
-    }
-
-    @Override
-    protected double computeMinWidth(double v) {
-        return computePrefWidth(v);
-    }
-
-    @Override
-    protected double computeMinHeight(double v) {
-        return computePrefHeight(v);
-    }
-
-    @Override
-    protected double computePrefWidth(double v) {
-        final Insets insets = getInsets();
-        return LEVEL_WIDTH + insets.getLeft() + insets.getRight();
-    }
-
-    @Override
-    protected double computePrefHeight(double v) {
-        final Insets insets = getInsets();
-        return LEVEL_HEIGHT + insets.getTop() + insets.getBottom();
-    }
-
-    @Override
-    protected double computeMaxWidth(double v) {
-        return computePrefWidth(v);
-    }
-
-    @Override
-    protected double computeMaxHeight(double v) {
-        return computePrefHeight(v);
-    }
-
-    @Override
-    protected void layoutChildren() {
-        final Insets insets = getInsets();
-        final double x = insets.getLeft();
-        final double y = insets.getTop();
-        final double width = getWidth() - insets.getLeft() - insets.getRight();
-        final double height = getHeight() - insets.getTop() - insets.getBottom();
-
-        background.resizeRelocate(x, y, width, height);
-        enemyLayer.resizeRelocate(x, y, width, height);
-        towerLayer.resizeRelocate(x, y, width, height);
-        projectileLayer.resizeRelocate(x, y, width, height);
-        clip.setX(x);
-        clip.setY(y);
-        clip.setWidth(width);
-        clip.setHeight(height);
-
-        for (Node n : getChildren()) {
-            if (n != background) {
-                n.autosize();
-            }
-        }
-    }
-}

defender/src/main/java/com/fxexperience/games/defender/games/simple/animation/MorphTransition.java

 package com.fxexperience.games.defender.games.simple.animation;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
 import javafx.animation.Transition;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.ObjectPropertyBase;
 import javafx.scene.shape.*;
 import javafx.util.Duration;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Vector;
+
 /**
 * Morphs a path from one set of path elements to another. The consequence
 * of using this class is that the PathElements of the target Path node will
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.