Add first obstacle as proof of concept.

This commit is contained in:
Jan Philipp Timme 2014-12-02 11:50:46 +01:00
parent de685366ee
commit bc68de5b99
8 changed files with 53 additions and 25 deletions

View File

@ -5,6 +5,7 @@ background:CloudBackground
-
[0-4]
spawn:EnemyOne,1,5
spawn:StoneOne,4,5
[4-10]
spawn:EnemyTwo,1,10
[10-25]

View File

@ -34,6 +34,8 @@ public abstract class Entity implements Updateable, Paintable {
EnemyBoss, EnemyBossMinion,
/* Explosions */
ExplosionOne, ExplosionTwo, MultiExplosion,
/* Stones */
StoneOne,
/* Items */
ItemCredit, ItemHeal, ItemIncreaseDamage, ItemNuke, ItemOneUp, ItemRocket, ItemShield,
}

View File

@ -3,6 +3,7 @@ package de.teamteamteam.spacescooter.entity;
import de.teamteamteam.spacescooter.brain.GameConfig;
import de.teamteamteam.spacescooter.brain.PlayerSession;
import de.teamteamteam.spacescooter.entity.enemy.Enemy;
import de.teamteamteam.spacescooter.entity.obstacle.Obstacle;
import de.teamteamteam.spacescooter.entity.shot.Shot;
import de.teamteamteam.spacescooter.entity.spi.Collidable;
import de.teamteamteam.spacescooter.entity.spi.Hittable;
@ -69,6 +70,10 @@ public abstract class LivingEntity extends CollidableEntity implements Hittable
return;
this.takeDamage(s.getDamageValue());
}
if (entity instanceof Obstacle) {
Obstacle o = (Obstacle) entity;
this.takeDamage(o.getCollisionDamage());
}
if (entity instanceof Player && (!(this instanceof Player))) {
Player player = (Player) entity;
this.takeDamage(player.getCollisionDamage());

View File

@ -1,25 +0,0 @@
package de.teamteamteam.spacescooter.entity;
import de.teamteamteam.spacescooter.entity.spi.Collidable;
/**
* Obstacles are static or floating things that do damage on collision.
*/
public abstract class Obstacle extends CollidableEntity {
public Obstacle(int x, int y) {
super(x, y);
}
public void update() {
// TODO Auto-generated method stub
}
@Override
public void collideWith(Collidable entity) {
// TODO Auto-generated method stub
}
}

View File

@ -9,6 +9,7 @@ import de.teamteamteam.spacescooter.brain.PlayerSession;
import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.control.KeyboardListener;
import de.teamteamteam.spacescooter.entity.enemy.Enemy;
import de.teamteamteam.spacescooter.entity.obstacle.Obstacle;
import de.teamteamteam.spacescooter.entity.shot.Shot;
import de.teamteamteam.spacescooter.entity.spi.Collidable;
import de.teamteamteam.spacescooter.sound.SoundSystem;

View File

@ -0,0 +1,14 @@
package de.teamteamteam.spacescooter.entity.obstacle;
import de.teamteamteam.spacescooter.entity.CollidableEntity;
/**
* Obstacles are static or floating things that do damage on collision.
*/
public abstract class Obstacle extends CollidableEntity {
public Obstacle(int x, int y) {
super(x, y);
}
}

View File

@ -0,0 +1,26 @@
package de.teamteamteam.spacescooter.entity.obstacle;
import de.teamteamteam.spacescooter.entity.spi.Collidable;
/**
* First proof of concept obstacle.
* A simple stone that moves to the left.
*/
public class StoneOne extends Obstacle {
public StoneOne(int x, int y) {
super(x, y);
this.setImage("images/stones/stone01.png");
this.setCollisionDamage(9001);
}
public void update() {
this.transpose(-1, 0);
}
@Override
public void collideWith(Collidable entity) {
}
}

View File

@ -10,6 +10,7 @@ import de.teamteamteam.spacescooter.entity.enemy.EnemyBoss;
import de.teamteamteam.spacescooter.entity.enemy.EnemyOne;
import de.teamteamteam.spacescooter.entity.enemy.EnemyThree;
import de.teamteamteam.spacescooter.entity.enemy.EnemyTwo;
import de.teamteamteam.spacescooter.entity.obstacle.StoneOne;
import de.teamteamteam.spacescooter.screen.GameScreen;
import de.teamteamteam.spacescooter.sound.SoundSystem;
import de.teamteamteam.spacescooter.utility.Loader;
@ -140,6 +141,9 @@ public final class Level {
case EnemyBoss:
new EnemyBoss(x, y);
break;
case StoneOne:
new StoneOne(x, y);
break;
default:
System.err.println("I don't know how to spawn this: " + entity);
break;