Permalink
Browse files

Path addition

Making the addition of new paths easier to handle. You would have to
update a certain variable if you added new paths, no more!
  • Loading branch information...
1 parent 62ccf1f commit 7d8ad64354835d91bf2fe22e639813d0136050cc @SubSage committed Apr 10, 2013
View
6 GDCalaga/data/paths.json
@@ -1,7 +1,7 @@
[
//Path 0
[
- {goalX : 400,
+ {goalX : 200,
goalY : 0,
speed : 1,
relative : true},
@@ -37,12 +37,12 @@
//Path 2
[
- {goalX : 400,
+ {goalX : 500,
goalY : -50,
speed : 1,
relative : false},
- {goalX : 200,
+ {goalX : 250,
goalY : 600,
speed : 2,
relative : false},
View
4 GDCalaga/src/org/gdc/gdcalaga/PathRegistry.java
@@ -66,4 +66,8 @@ public void loadFromJson(String path){
registerPath(newPath);
}
}
+
+ public int getNumOfPaths(){
+ return paths.size();
+ }
}
View
6 GDCalaga/src/org/gdc/gdcalaga/Spawn.java
@@ -12,18 +12,15 @@
public class Spawn
{
-
private static int wave=0;
-
public static void spawnWave(PathRegistry paths, EntityManager mng) {
int countWaves = 0;
ArrayList<Entity> ents = mng.getEntities();
for(Entity e : ents)
{
-
if(e instanceof Wave){
countWaves++;
}
@@ -34,7 +31,8 @@ public static void spawnWave(PathRegistry paths, EntityManager mng) {
{
EnemyGroup group = new EnemyGroup(mng, 100, 800, 0);
- int pathNum = (int)Math.floor(Math.random() * 3);
+ int pathNum = (int)Math.floor(Math.random() * paths.getNumOfPaths());
+
float x, y;
x = (float)(Math.random()*400);

0 comments on commit 7d8ad64

Please sign in to comment.