Initial commit
This commit is contained in:
44
core/src/zero1hd/polyjet/entity/BarBeat.java
Executable file
44
core/src/zero1hd/polyjet/entity/BarBeat.java
Executable file
@@ -0,0 +1,44 @@
|
||||
package zero1hd.polyjet.entity;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
||||
|
||||
import zero1hd.polyjet.Polyjet;
|
||||
|
||||
public class BarBeat extends Entity {
|
||||
NinePatch texture;
|
||||
float rate;
|
||||
|
||||
public void initiate(float size, float rate, float spawnX, float spawnY, NinePatch texture) {
|
||||
hitpoints = 1;
|
||||
this.rate = rate;
|
||||
setPosition(spawnX, spawnY);
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (getY() + getHeight() < Polyjet.GAME_AREA_HEIGHT) {
|
||||
hitpoints = 0;
|
||||
}
|
||||
moveBy(0, -rate*delta);
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
texture.draw(batch, getX(), getY(), getWidth(), getHeight());
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageDealt() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
texture = null;
|
||||
super.reset();
|
||||
}
|
||||
}
|
71
core/src/zero1hd/polyjet/entity/Entity.java
Executable file
71
core/src/zero1hd/polyjet/entity/Entity.java
Executable file
@@ -0,0 +1,71 @@
|
||||
package zero1hd.polyjet.entity;
|
||||
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||
|
||||
public class Entity extends Actor implements Poolable {
|
||||
private Rectangle hitbox;
|
||||
protected int hitpoints;
|
||||
|
||||
public Entity() {
|
||||
hitbox = new Rectangle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float width, float height) {
|
||||
hitbox.setSize(width, height);
|
||||
super.setSize(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
hitbox.setPosition(getX(), getY());
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return amount of hp this entity has left.
|
||||
*/
|
||||
public int getHitPoints() {
|
||||
return hitpoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* used as a hitbox.
|
||||
* @return a rectangle used for hit detection
|
||||
*/
|
||||
public Rectangle getHitbox() {
|
||||
return hitbox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0 if not overridden.
|
||||
* @return the amount of damage dealt.
|
||||
*/
|
||||
public int getDamageDealt() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doesn't do anything if not overridden.
|
||||
* @param damageToDeal the amount of damage to deal to this entity.
|
||||
*/
|
||||
public void dealDamage(int damageToDeal) {
|
||||
}
|
||||
/**
|
||||
* Default value is 0 if not overridden and setup properly.
|
||||
* Note: this method is called whether or not this entity is dead. whenever two entities cross, this will be called.
|
||||
* @return the amount of points this entity is worth
|
||||
*/
|
||||
public int getPoints() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
setPosition(0, 0);
|
||||
setSize(0, 0);
|
||||
hitpoints = 0;
|
||||
}
|
||||
}
|
68
core/src/zero1hd/polyjet/entity/PolyJetEntity.java
Executable file
68
core/src/zero1hd/polyjet/entity/PolyJetEntity.java
Executable file
@@ -0,0 +1,68 @@
|
||||
package zero1hd.polyjet.entity;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
|
||||
import zero1hd.polyjet.Polyjet;
|
||||
|
||||
public class PolyJetEntity extends Actor {
|
||||
|
||||
private ParticleEffect thrust;
|
||||
private Texture polyjet;
|
||||
private ParticleEffect teleportCloak;
|
||||
|
||||
|
||||
public boolean moveLeft, moveRight, moveUp, moveDown, teleporting;
|
||||
private int rate;
|
||||
public PolyJetEntity(Polyjet core, int rate, String jet) {
|
||||
this.rate = rate;
|
||||
|
||||
setSize(3, 3);
|
||||
|
||||
setPosition(Polyjet.GAME_AREA_WIDTH/2 - getWidth()/2, -4f);
|
||||
|
||||
polyjet = core.assetManager.get("polyjet-" + jet + ".png", Texture.class);
|
||||
thrust = core.assetManager.get("standard_thrust.p", ParticleEffect.class);
|
||||
thrust.start();
|
||||
|
||||
teleportCloak = core.assetManager.get("magicCircle.png", ParticleEffect.class);
|
||||
|
||||
addAction(Actions.moveTo(getX(), 4f, 0.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
thrust.setPosition(getX()+(getWidth()-2)/2 - 1f/16f, getY()-0.15f);
|
||||
thrust.update(delta);
|
||||
teleportCloak.setPosition(getX() +(getWidth()-1)/2, getY() + (getHeight()-1)/2);
|
||||
|
||||
super.act(delta);
|
||||
|
||||
//Movement!
|
||||
if (moveLeft && !moveRight) {
|
||||
moveBy(-(rate*delta), 0);
|
||||
}
|
||||
if (moveRight && !moveLeft) {
|
||||
moveBy(rate*delta, 0);
|
||||
}
|
||||
if (moveUp && !moveDown) {
|
||||
moveBy(0, rate*delta);
|
||||
}
|
||||
|
||||
if (moveDown && !moveUp) {
|
||||
moveBy(0, -rate*delta);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
thrust.draw(batch);
|
||||
batch.draw(polyjet, getX(), getY(), getWidth(), getHeight());
|
||||
super.draw(batch, parentAlpha);
|
||||
|
||||
}
|
||||
}
|
75
core/src/zero1hd/polyjet/entity/Projectile.java
Executable file
75
core/src/zero1hd/polyjet/entity/Projectile.java
Executable file
@@ -0,0 +1,75 @@
|
||||
package zero1hd.polyjet.entity;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
|
||||
import zero1hd.polyjet.Polyjet;
|
||||
|
||||
public class Projectile extends Entity {
|
||||
float rate;
|
||||
int damage;
|
||||
Texture texture;
|
||||
int hp;
|
||||
int storedPoints;
|
||||
|
||||
public Projectile() {
|
||||
super();
|
||||
Gdx.app.debug("Projectile", "A new projectile was created.");
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param spawnX x spawn location
|
||||
* @param spawnY y spawn location
|
||||
* @param rate r/second
|
||||
* @param hp health this projectile should have
|
||||
* @param texture texture this projectile should render.
|
||||
*/
|
||||
public void initiate(float spawnX, float spawnY, float rate, int hp, Texture texture, float width, float height) {
|
||||
this.hp = hp;
|
||||
setX(spawnX);
|
||||
setY(spawnY);
|
||||
this.texture = texture;
|
||||
this.rate = rate;
|
||||
setSize(width, height);
|
||||
damage = 1;
|
||||
}
|
||||
|
||||
public void setDamage(int damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public void printDebug() {
|
||||
Gdx.app.debug("Projectile", "Coordinates (X,Y): (" + getX() + ", " + getY() + ") Current parent: " + getParent().getName());
|
||||
Gdx.app.debug("Projectile", "Width and height: " + getWidth() + "x" + getHeight());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
moveBy(0, delta*rate);
|
||||
if (getY() > Polyjet.GAME_AREA_HEIGHT) {
|
||||
hp = 0;
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
batch.draw(texture, getX(), getY(), getWidth(), getHeight());
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
texture = null;
|
||||
storedPoints = 0;
|
||||
rate = 0;
|
||||
damage = 0;
|
||||
setDebug(false);
|
||||
}
|
||||
@Override
|
||||
public int getHitPoints() {
|
||||
return hp;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user