Add the other two Stones to the game.

This commit is contained in:
Jan Philipp Timme 2014-12-02 13:04:51 +01:00
parent f1c95bf4d9
commit e8400f4f34
8 changed files with 95 additions and 20 deletions

View File

@ -7,15 +7,15 @@ spawn:EnemyBoss,1,1,50
[1-2] [1-2]
spawn:StoneOne,2,1,0 spawn:StoneOne,2,1,0
spawn:StoneOne,2,1,10 spawn:StoneOne,2,1,10
spawn:StoneOne,2,1,20 spawn:StoneTwo,2,1,20
spawn:StoneOne,2,1,30 spawn:StoneOne,2,1,30
spawn:StoneOne,2,1,40 spawn:StoneTwo,2,1,40
spawn:EnemyOne,2,1,50 spawn:EnemyOne,2,1,50
spawn:StoneOne,2,1,60 spawn:StoneOne,2,1,60
spawn:StoneOne,2,1,70 spawn:StoneThree,2,1,70
spawn:StoneOne,2,1,80 spawn:StoneOne,2,1,80
spawn:StoneOne,2,1,90 spawn:StoneThree,2,1,90
spawn:StoneOne,2,1,100 spawn:StoneThree,2,1,100
[2-4] [2-4]
spawn:EnemyOne,1,5,20 spawn:EnemyOne,1,5,20
spawn:StoneOne,4,5,50 spawn:StoneOne,4,5,50

View File

@ -35,7 +35,7 @@ public abstract class Entity implements Updateable, Paintable {
/* Explosions */ /* Explosions */
ExplosionOne, ExplosionTwo, MultiExplosion, ExplosionOne, ExplosionTwo, MultiExplosion,
/* Stones */ /* Stones */
StoneOne, StoneOne, StoneTwo, StoneThree,
/* Items */ /* Items */
ItemCredit, ItemHeal, ItemIncreaseDamage, ItemNuke, ItemOneUp, ItemRocket, ItemShield, ItemCredit, ItemHeal, ItemIncreaseDamage, ItemNuke, ItemOneUp, ItemRocket, ItemShield,
} }

View File

@ -0,0 +1,41 @@
package de.teamteamteam.spacescooter.entity.obstacle;
public abstract class MovingObstacle extends Obstacle {
/**
* Delta the Obstacle moves at on X-Axis.
* Defaults to -1.
*/
private int xDelta;
/**
* Delta the Obstacle moves at on Y-Axis.
* Defaults to 0.
*/
private int yDelta;
/**
* Default constructor.
*/
public MovingObstacle(int x, int y) {
super(x, y);
this.setMoveDeltas(-1, 0);
}
/**
* Make the Obstacle move at its defined X- and Y-Delta.
*/
public void update() {
this.transpose(this.xDelta, this.yDelta);
}
/**
* Set the deltas used to move this Obstacle.
*/
public void setMoveDeltas(int xDelta, int yDelta) {
this.xDelta = xDelta;
this.yDelta = yDelta;
}
}

View File

@ -1,6 +1,7 @@
package de.teamteamteam.spacescooter.entity.obstacle; package de.teamteamteam.spacescooter.entity.obstacle;
import de.teamteamteam.spacescooter.entity.CollidableEntity; import de.teamteamteam.spacescooter.entity.CollidableEntity;
import de.teamteamteam.spacescooter.entity.spi.Collidable;
/** /**
* Obstacles are static or floating things that do damage on collision. * Obstacles are static or floating things that do damage on collision.
@ -10,5 +11,14 @@ public abstract class Obstacle extends CollidableEntity {
public Obstacle(int x, int y) { public Obstacle(int x, int y) {
super(x, y); super(x, y);
} }
/**
* Obstacles do not care about collisions. Mostly.
* Override this if you think different.
*/
@Override
public void collideWith(Collidable entity) {
}
} }

View File

@ -1,12 +1,9 @@
package de.teamteamteam.spacescooter.entity.obstacle; package de.teamteamteam.spacescooter.entity.obstacle;
import de.teamteamteam.spacescooter.entity.spi.Collidable;
/** /**
* First proof of concept obstacle. * The first stone/meteor like object in the game!
* A simple stone that moves to the left.
*/ */
public class StoneOne extends Obstacle { public class StoneOne extends MovingObstacle {
public StoneOne(int x, int y) { public StoneOne(int x, int y) {
super(x, y); super(x, y);
@ -14,13 +11,4 @@ public class StoneOne extends Obstacle {
this.setCollisionDamage(9001); this.setCollisionDamage(9001);
} }
public void update() {
this.transpose(-1, 0);
}
@Override
public void collideWith(Collidable entity) {
}
} }

View File

@ -0,0 +1,14 @@
package de.teamteamteam.spacescooter.entity.obstacle;
/**
* Yet another stony obstacle.
*/
public class StoneThree extends MovingObstacle {
public StoneThree(int x, int y) {
super(x, y);
this.setImage("images/stones/stone03.png");
this.setCollisionDamage(9001);
}
}

View File

@ -0,0 +1,14 @@
package de.teamteamteam.spacescooter.entity.obstacle;
/**
* Yet another stony obstacle.
*/
public class StoneTwo extends MovingObstacle {
public StoneTwo(int x, int y) {
super(x, y);
this.setImage("images/stones/stone02.png");
this.setCollisionDamage(9001);
}
}

View File

@ -11,6 +11,8 @@ import de.teamteamteam.spacescooter.entity.enemy.EnemyOne;
import de.teamteamteam.spacescooter.entity.enemy.EnemyThree; import de.teamteamteam.spacescooter.entity.enemy.EnemyThree;
import de.teamteamteam.spacescooter.entity.enemy.EnemyTwo; import de.teamteamteam.spacescooter.entity.enemy.EnemyTwo;
import de.teamteamteam.spacescooter.entity.obstacle.StoneOne; import de.teamteamteam.spacescooter.entity.obstacle.StoneOne;
import de.teamteamteam.spacescooter.entity.obstacle.StoneThree;
import de.teamteamteam.spacescooter.entity.obstacle.StoneTwo;
import de.teamteamteam.spacescooter.screen.GameScreen; import de.teamteamteam.spacescooter.screen.GameScreen;
import de.teamteamteam.spacescooter.sound.SoundSystem; import de.teamteamteam.spacescooter.sound.SoundSystem;
import de.teamteamteam.spacescooter.utility.Loader; import de.teamteamteam.spacescooter.utility.Loader;
@ -189,6 +191,12 @@ public final class Level {
case StoneOne: case StoneOne:
new StoneOne(x, y); new StoneOne(x, y);
break; break;
case StoneTwo:
new StoneTwo(x, y);
break;
case StoneThree:
new StoneThree(x, y);
break;
default: default:
System.err.println("I don't know how to spawn this: " + entity); System.err.println("I don't know how to spawn this: " + entity);
break; break;