shard entity functionality has been added
Before Width: | Height: | Size: 454 B After Width: | Height: | Size: 572 B |
Before Width: | Height: | Size: 547 B After Width: | Height: | Size: 696 B |
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 666 B |
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 900 B |
Before Width: | Height: | Size: 951 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 383 B |
@ -125,6 +125,7 @@ public class Polyjet extends Game {
|
||||
assetManager.load("pop_close.ogg", Sound.class);
|
||||
assetManager.load("laser.png", Texture.class);
|
||||
assetManager.load("pellet.png", Texture.class);
|
||||
assetManager.load("shard.png", Texture.class);
|
||||
}
|
||||
public void generateFonts() {
|
||||
initComplete = true;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package zero1hd.polyjet.entity;
|
||||
|
||||
public enum Entities {
|
||||
POLYJET, BAR_BEAT, VOID_CIRCLE, SHARDS, LASER, PELLET;
|
||||
POLYJET, BAR_BEAT, VOID_CIRCLE, SHARD, LASER, PELLET;
|
||||
|
||||
public float x;
|
||||
public float y;
|
||||
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.utils.Pool;
|
||||
|
||||
import zero1hd.polyjet.entity.ally.Laser;
|
||||
import zero1hd.polyjet.entity.enemies.Pellet;
|
||||
import zero1hd.polyjet.entity.enemies.Shard;
|
||||
import zero1hd.polyjet.entity.enemies.VoidCircle;
|
||||
|
||||
public class EntityController {
|
||||
@ -19,6 +20,7 @@ public class EntityController {
|
||||
//Enemy pool declaration;
|
||||
private Pool<VoidCircle> voidCirclePool;
|
||||
private Pool<Pellet> pelletPool;
|
||||
private Pool<Shard> shardPool;
|
||||
|
||||
//Ally pool declaration;
|
||||
private Pool<Laser> laserPool;
|
||||
@ -43,6 +45,12 @@ public class EntityController {
|
||||
return new Pellet(assets.get("pellet.png", Texture.class));
|
||||
}
|
||||
};
|
||||
shardPool = new Pool<Shard>() {
|
||||
@Override
|
||||
protected Shard newObject() {
|
||||
return new Shard(assets.get("shard.png", Texture.class));
|
||||
}
|
||||
};
|
||||
|
||||
//Ally pool initialization;
|
||||
laserPool = new Pool<Laser>() {
|
||||
@ -68,6 +76,10 @@ public class EntityController {
|
||||
Pellet pellet = pelletPool.obtain();
|
||||
activeEnemies.add(pellet);
|
||||
return pellet;
|
||||
case SHARD:
|
||||
Shard shard = shardPool.obtain();
|
||||
activeEnemies.add(shard);
|
||||
return shard;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -92,6 +104,13 @@ public class EntityController {
|
||||
pellet.remove();
|
||||
activeEnemies.removeValue(entity, true);
|
||||
pelletPool.free(pellet);
|
||||
break;
|
||||
case SHARD:
|
||||
Shard shard = (Shard) entity;
|
||||
shard.remove();
|
||||
activeEnemies.removeValue(entity, true);
|
||||
shardPool.free(shard);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class Pellet extends Actor implements Entity, Poolable {
|
||||
hitBox.setPosition(getX(), getY());
|
||||
super.act(delta);
|
||||
|
||||
if (getX() > Polyjet.GAME_AREA_WIDTH || getY() > Polyjet.GAME_AREA_HEIGHT || getX()-getWidth() < 0 || getY()-getHeight() < 0) {
|
||||
if (getX() > Polyjet.GAME_AREA_WIDTH || getY() > Polyjet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
|
||||
dead = true;
|
||||
}
|
||||
}
|
||||
|
48
core/src/zero1hd/polyjet/entity/enemies/Shard.java
Normal file → Executable file
@ -1,5 +1,6 @@
|
||||
package zero1hd.polyjet.entity.enemies;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
@ -7,15 +8,14 @@ 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.Disposable;
|
||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||
|
||||
import zero1hd.polyjet.Polyjet;
|
||||
import zero1hd.polyjet.entity.Entities;
|
||||
import zero1hd.polyjet.entity.Entity;
|
||||
|
||||
public class Shard extends Actor implements Entity, Poolable, Disposable {
|
||||
public class Shard extends Actor implements Entity, Poolable {
|
||||
private Sprite sprite;
|
||||
private Texture shard;
|
||||
private Rectangle hitbox;
|
||||
private Vector2 angle;
|
||||
private Vector2 center;
|
||||
@ -24,10 +24,10 @@ public class Shard extends Actor implements Entity, Poolable, Disposable {
|
||||
private float rate;
|
||||
|
||||
public Shard(Texture shardTexture) {
|
||||
this.shard = shardTexture;
|
||||
hitbox = new Rectangle();
|
||||
angle = new Vector2();
|
||||
sprite = new Sprite(shardTexture);
|
||||
sprite.setSize(2f, 3f);
|
||||
center = new Vector2();
|
||||
}
|
||||
|
||||
@ -37,15 +37,13 @@ public class Shard extends Actor implements Entity, Poolable, Disposable {
|
||||
maxHp = hp;
|
||||
setPosition(x, y);
|
||||
this.angle.set(MathUtils.sinDeg(angle), MathUtils.cosDeg(angle));
|
||||
sprite.setRotation(angle);
|
||||
setSize(1f, 1f);
|
||||
sprite.setRotation(-angle);
|
||||
setSize(2f, 2f);
|
||||
hitbox.setSize(getWidth(), getHeight());
|
||||
center.set(getWidth()/2f, getHeight()/2f);
|
||||
sprite.setOrigin(sprite.getWidth()/2f, sprite.getHeight()/2f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
hp = 0;
|
||||
@ -62,43 +60,51 @@ public class Shard extends Actor implements Entity, Poolable, Disposable {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
moveBy(angle.x*delta*rate, angle.y*rate*delta);
|
||||
sprite.setPosition(getX()+center.x, getY()+center.y);
|
||||
hitbox.setPosition(getX(), getY());
|
||||
sprite.setCenter(getX()+center.x, getY()+center.y);
|
||||
|
||||
if (getX() > Polyjet.GAME_AREA_WIDTH || getY() > Polyjet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
|
||||
hp = 0;
|
||||
}
|
||||
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
sprite.setColor(1f, 0f, (float)hp/(float)maxHp, 1f);
|
||||
sprite.draw(batch);
|
||||
batch.setColor(Color.WHITE);
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collided(Entity entity) {
|
||||
// TODO Auto-generated method stub
|
||||
switch (entity.getEntityType()) {
|
||||
case LASER:
|
||||
hp--;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle getHitZone() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return hitbox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entities getEntityType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return Entities.SHARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDead() {
|
||||
// TODO Auto-generated method stub
|
||||
if (hp <= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
shard.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import zero1hd.polyjet.entity.Entity;
|
||||
import zero1hd.polyjet.entity.EntityController;
|
||||
import zero1hd.polyjet.entity.ally.Laser;
|
||||
import zero1hd.polyjet.entity.enemies.Pellet;
|
||||
import zero1hd.polyjet.entity.enemies.Shard;
|
||||
import zero1hd.polyjet.entity.enemies.VoidCircle;
|
||||
|
||||
public class SpawnerWindow extends Window {
|
||||
@ -79,6 +80,10 @@ public class SpawnerWindow extends Window {
|
||||
voidCircle.init(mod2.getValue(), coords.x, coords.y, mod1.getValue(), mod3.getValue());
|
||||
stage.addActor(voidCircle);
|
||||
break;
|
||||
case SHARD:
|
||||
Shard shard = (Shard) entity;
|
||||
shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue());
|
||||
stage.addActor(shard);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|