fixed dumb math mistake and changes to map gen index control
This commit is contained in:
parent
e6b3960e7e
commit
013e3d7d99
@ -57,34 +57,51 @@ public class RhythmMapAlgorithm implements Runnable {
|
||||
map.beginBuild();
|
||||
for (int index = 0; index < bassPeaks.size; index++) {
|
||||
if (bassPeaks.get(index) != 0 || UMPeaks.get(index) != 0) {
|
||||
//If there is a value of some sorts that is not zero, we generate some beat for the map
|
||||
if (bassPeaks.get(index) >= avgBass) {
|
||||
float warningTime = map.goBack((int) (windowPerSecond*1.5f))/windowPerSecond;
|
||||
float endRadius = (bassPeaks.get(index)/bassMax)*(Main.GAME_AREA_HEIGHT/4f);
|
||||
map.addToMap(Entities.VOID_CIRCLE,
|
||||
endRadius,
|
||||
rand.nextFloat()*Main.GAME_AREA_WIDTH,
|
||||
rand.nextFloat()*Main.GAME_AREA_HEIGHT,
|
||||
endRadius/(avgSPB*0.7f),
|
||||
warningTime
|
||||
);
|
||||
map.resetIndex();
|
||||
if (bassPeaks.get(index) != 0) {
|
||||
//If there is a value of some sorts that is not zero, we generate some beat for the map
|
||||
if (bassPeaks.get(index) >= avgBass) {
|
||||
//If bass peak is greater than the bass peak average, then:
|
||||
int indexMoved = map.goBack((int) (windowPerSecond*1.5f));
|
||||
float waitTime = indexMoved/windowPerSecond;
|
||||
float endRadius = (bassPeaks.get(index)/bassMax)*(Main.GAME_AREA_HEIGHT/4f);
|
||||
map.addToMap(Entities.VOID_CIRCLE,
|
||||
endRadius,
|
||||
rand.nextFloat()*Main.GAME_AREA_WIDTH,
|
||||
rand.nextFloat()*Main.GAME_AREA_HEIGHT,
|
||||
endRadius/(avgSPB*0.7f),
|
||||
waitTime
|
||||
);
|
||||
map.goForward(indexMoved);
|
||||
}
|
||||
}
|
||||
if (UMPeaks.get(index) >= avgUM) {
|
||||
int spawnLocations = (Main.GAME_AREA_WIDTH-8)/8;
|
||||
map.addToMap(Entities.BAR,
|
||||
MathUtils.round(rand.nextFloat()*spawnLocations)*8,
|
||||
(8f/avgSPB)*speedMod);
|
||||
} else {
|
||||
if (UMPeaks.get(index) != 0) {
|
||||
|
||||
if (UMPeaks.get(index) != 0) {
|
||||
if (UMPeaks.get(index) >= avgUM) {
|
||||
//If upper midrange peaks are greater than average, the:
|
||||
int spawnLocations = (Main.GAME_AREA_WIDTH-8)/8;
|
||||
map.addToMap(Entities.BAR,
|
||||
MathUtils.round(rand.nextFloat()*spawnLocations)*8,
|
||||
(8f/avgSPB)*speedMod);
|
||||
} else {
|
||||
float xSpawnLocation = (rand.nextFloat()*(Main.GAME_AREA_WIDTH-2))+1;
|
||||
map.addToMap(Entities.PELLET,
|
||||
xSpawnLocation,
|
||||
Main.GAME_AREA_HEIGHT-0.25f,
|
||||
140*rand.nextFloat()+110f,
|
||||
140*rand.nextFloat()+110f,
|
||||
(Main.GAME_AREA_HEIGHT/4f)/avgSPB);
|
||||
}
|
||||
}
|
||||
|
||||
if (overlappedPeaks.get(index) != 0) {
|
||||
|
||||
}
|
||||
|
||||
if (rand.nextFloat() < 0.15f) {
|
||||
switch(rand.nextInt(10)) {
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
map.addNullToMap();
|
||||
}
|
||||
|
@ -1,15 +1,29 @@
|
||||
package zero1hd.polyjet.entity;
|
||||
|
||||
import zero1hd.polyjet.entity.ally.Laser;
|
||||
import zero1hd.polyjet.entity.ally.PolyJetEntity;
|
||||
import zero1hd.polyjet.entity.enemies.Bar;
|
||||
import zero1hd.polyjet.entity.enemies.Flake;
|
||||
import zero1hd.polyjet.entity.enemies.Pellet;
|
||||
import zero1hd.polyjet.entity.enemies.Shard;
|
||||
import zero1hd.polyjet.entity.enemies.VoidCircle;
|
||||
|
||||
public enum Entities {
|
||||
POLYJET(false), BAR(true), VOID_CIRCLE(true), SHARD(true), LASER(false), PELLET(true), FLAKE(true);
|
||||
POLYJET(false, PolyJetEntity.class), BAR(true, Bar.class), VOID_CIRCLE(true, VoidCircle.class), SHARD(true, Shard.class), LASER(false, Laser.class), PELLET(true, Pellet.class), FLAKE(true, Flake.class);
|
||||
|
||||
private boolean enemy;
|
||||
private final boolean enemy;
|
||||
private final Class<? extends Entity> classType;
|
||||
|
||||
private Entities(boolean enemy) {
|
||||
private Entities(boolean enemy, Class<? extends Entity> classType) {
|
||||
this.enemy = enemy;
|
||||
this.classType = classType;
|
||||
}
|
||||
|
||||
public boolean isEnemy() {
|
||||
return enemy;
|
||||
}
|
||||
|
||||
public Class<? extends Entity> getClassType() {
|
||||
return classType;
|
||||
}
|
||||
}
|
||||
|
@ -33,14 +33,18 @@ public class EntityController {
|
||||
private Pool<Bar> barPool;
|
||||
private Pool<Flake> flakePool;
|
||||
|
||||
private EntityController ec = this;
|
||||
|
||||
//Ally pool declaration;
|
||||
private Pool<Laser> laserPool;
|
||||
|
||||
public EntityController(AssetManager assetManager, Preferences preferences) {
|
||||
private Stage stage;
|
||||
public EntityController(AssetManager assetManager, Preferences preferences, Stage stage) {
|
||||
activeAllies = new Array<Entity>();
|
||||
activeEnemies = new Array<Entity>();
|
||||
this.assets = assetManager;
|
||||
this.prefs = preferences;
|
||||
this.stage = stage;
|
||||
|
||||
//Enemy pool initialization;
|
||||
voidCirclePool = new Pool<VoidCircle>() {
|
||||
@ -74,7 +78,7 @@ public class EntityController {
|
||||
flakePool = new Pool<Flake>() {
|
||||
@Override
|
||||
protected Flake newObject() {
|
||||
return new Flake(assets.get("flake.png", Texture.class));
|
||||
return new Flake(assets.get("flake.png", Texture.class), ec);
|
||||
}
|
||||
};
|
||||
|
||||
@ -155,13 +159,7 @@ public class EntityController {
|
||||
return bar;
|
||||
case FLAKE:
|
||||
Flake flake = flakePool.obtain();
|
||||
Shard[] shards = new Shard[(int) param[0]];
|
||||
for (int i = 0; i < shards.length; i++) {
|
||||
shards[i] = (Shard) retrieveEntity(Entities.SHARD);
|
||||
shards[i].init(param[6], param[7], param[8], param[9], (int) param[10]);
|
||||
stage.addActor(shards[i]);
|
||||
}
|
||||
flake.init(param[1], param[2], param[3], param[4], param[5], shards);
|
||||
flake.init(param[1], param[2], param[3], param[4], param[5], (int) param[0]);
|
||||
activeEnemies.add(flake);
|
||||
stage.addActor(flake);
|
||||
return flake;
|
||||
@ -228,4 +226,7 @@ public class EntityController {
|
||||
}
|
||||
}
|
||||
|
||||
public Stage getStage() {
|
||||
return stage;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.badlogic.gdx.utils.Pool.Poolable;
|
||||
import zero1hd.polyjet.Main;
|
||||
import zero1hd.polyjet.entity.Entities;
|
||||
import zero1hd.polyjet.entity.Entity;
|
||||
import zero1hd.polyjet.entity.EntityController;
|
||||
|
||||
public class Flake extends Entity implements Poolable {
|
||||
private Texture texture;
|
||||
@ -21,16 +22,23 @@ public class Flake extends Entity implements Poolable {
|
||||
private Rectangle hitbox;
|
||||
private Vector2 center;
|
||||
private Vector2 rot;
|
||||
private EntityController ec;
|
||||
|
||||
public Flake(Texture texture) {
|
||||
public Flake(Texture texture, EntityController ec) {
|
||||
this.ec = ec;
|
||||
this.texture = texture;
|
||||
hitbox = new Rectangle();
|
||||
center = new Vector2();
|
||||
rot = new Vector2();
|
||||
}
|
||||
|
||||
public void init(float x, float y, float rate, float fuse, float angle, Shard... shards) {
|
||||
this.shards = shards;
|
||||
public void init(float x, float y, float rate, float fuse, float angle, int shardCount) {
|
||||
this.shards = new Shard[shardCount];
|
||||
for (int i = 0; i < shards.length; i++) {
|
||||
shards[i] = (Shard) ec.retrieveEntity(Entities.SHARD);
|
||||
shards[i].init(x, y, 360/shards.length*i, 0, 2);
|
||||
ec.getStage().addActor(shards[i]);
|
||||
}
|
||||
setSize(3f, 3f);
|
||||
this.rate = rate;
|
||||
this.timer = fuse;
|
||||
@ -38,7 +46,7 @@ public class Flake extends Entity implements Poolable {
|
||||
hitbox.setSize(getWidth(), getHeight());
|
||||
center.set(getWidth()/2f, getHeight()/2f);
|
||||
setPosition(x-center.x, y-center.y);
|
||||
rot.set(MathUtils.sinDeg(angle), MathUtils.cosDeg(angle));
|
||||
rot.set(MathUtils.cosDeg(angle), MathUtils.sinDeg(angle));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||
|
||||
import zero1hd.polyjet.Main;
|
||||
@ -28,7 +27,7 @@ public class Pellet extends Entity implements Poolable {
|
||||
|
||||
public void init(float x, float y, float angle, float rate) {
|
||||
setPosition(x, y);
|
||||
direction.set(MathUtils.sinDeg(angle), MathUtils.cosDeg(angle));
|
||||
direction.set(MathUtils.cosDeg(angle), MathUtils.sinDeg(angle));
|
||||
setSize(0.5f, 0.5f);
|
||||
hitBox.setSize(getWidth(), getHeight());
|
||||
this.rate = rate;
|
||||
|
@ -34,8 +34,8 @@ public class Shard extends Entity implements Poolable {
|
||||
this.rate = rate;
|
||||
this.hp = hp;
|
||||
maxHp = hp;
|
||||
this.angle.set(MathUtils.sinDeg(angle), MathUtils.cosDeg(angle));
|
||||
sprite.setRotation(-angle);
|
||||
this.angle.set(MathUtils.cosDeg(angle), MathUtils.sinDeg(angle));
|
||||
sprite.setRotation(angle+90);
|
||||
setSize(2f, 2f);
|
||||
hitbox.setSize(getWidth(), getHeight());
|
||||
center.set(getWidth()/2f, getHeight()/2f);
|
||||
|
@ -46,7 +46,7 @@ public class GamePlayArea extends Stage {
|
||||
Gdx.app.debug("Game Area", "new area created");
|
||||
|
||||
polyjet = new PolyJetEntity(assetManager, 25f, 25f, "standard");
|
||||
ec = new EntityController(assetManager, prefs);
|
||||
ec = new EntityController(assetManager, prefs, this);
|
||||
collisionDetector = new CollisionDetector(ec.activeAllies, ec.activeEnemies, assetManager, prefs);
|
||||
ec.activeAllies.add(polyjet);
|
||||
addActor(polyjet);
|
||||
|
@ -96,14 +96,8 @@ public class SpawnerWindow extends Window {
|
||||
break;
|
||||
case FLAKE:
|
||||
Flake flake = (Flake) entity;
|
||||
Shard[] shards = new Shard[(int) mod4.getValue()];
|
||||
for (int i = 0; i < shards.length; i++) {
|
||||
shards[i] = (Shard) ec.retrieveEntity(Entities.SHARD);
|
||||
shards[i].init(coords.x, coords.y, 360f/shards.length*i, 0f, (int) 2);
|
||||
stage.addActor(shards[i]);
|
||||
}
|
||||
stage.addActor(flake);
|
||||
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, shards);
|
||||
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user