Add a beam image, beam item, show your secondary weapon amount in the Interface bar.
Shop expanded: now you can select the secondary weapon.
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 468 B |
After Width: | Height: | Size: 897 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 484 B |
After Width: | Height: | Size: 416 KiB |
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 278 B |
|
@ -50,6 +50,13 @@ public class PlayerSession {
|
|||
*/
|
||||
private static int shipShotUpgadesBought;
|
||||
|
||||
/**
|
||||
* The secondary weapon of the ship.
|
||||
* 1 = Rocket.
|
||||
* 2 = Beam.
|
||||
*/
|
||||
private static int secondaryWeapon;
|
||||
|
||||
|
||||
/**
|
||||
* Private constructor, this class will never be instantiated.
|
||||
|
@ -216,6 +223,20 @@ public class PlayerSession {
|
|||
PlayerSession.shipShotUpgadesBought++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the secondary weapon.
|
||||
*/
|
||||
public static int getSecondsecondaryWeapon(){
|
||||
return PlayerSession.secondaryWeapon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the secondary weapon.
|
||||
*/
|
||||
public static void setSecondsecondaryWeapon(int secondaryWeapon){
|
||||
PlayerSession.secondaryWeapon = secondaryWeapon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This will reset all data from the players session.
|
||||
|
@ -225,6 +246,7 @@ public class PlayerSession {
|
|||
*/
|
||||
public static void reset() {
|
||||
PlayerSession.score = 0;
|
||||
PlayerSession.secondaryWeapon = 1;
|
||||
PlayerSession.credits = 0;
|
||||
PlayerSession.shipHealthPoints = GameConfig.initialPlayerHealthPoints;
|
||||
PlayerSession.shipShieldPoints = GameConfig.initialPlayerShieldPoints;
|
||||
|
|
|
@ -54,8 +54,8 @@ public class Player extends ShootingEntity implements KeyboardListener {
|
|||
*/
|
||||
public Player(int x, int y) {
|
||||
super(x, y);
|
||||
this.rocketAmount = 10;
|
||||
this.beamAmount = 10;
|
||||
this.rocketAmount = 1;
|
||||
this.beamAmount = 1;
|
||||
this.collisionCooldown = 150;
|
||||
this.currentCollisionCooldown = 0;
|
||||
this.setImage("images/ship.png");
|
||||
|
@ -112,11 +112,12 @@ public class Player extends ShootingEntity implements KeyboardListener {
|
|||
if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) {
|
||||
this.shoot();
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_Y) && this.rocketAmount > 0) {
|
||||
this.shootRocket();
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_X) && this.beamAmount > 0) {
|
||||
this.shootBeam();
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_Y)) {
|
||||
if(PlayerSession.getSecondsecondaryWeapon() == 1 && this.rocketAmount > 0) {
|
||||
this.shootRocket();
|
||||
}else if(PlayerSession.getSecondsecondaryWeapon() == 2 && this.beamAmount > 0) {
|
||||
this.shootBeam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -261,8 +261,8 @@ public abstract class ShootingEntity extends LivingEntity {
|
|||
*/
|
||||
public void createBeam() {
|
||||
new Beam(
|
||||
this.getX() + this.shootSpawnX,
|
||||
this.getY() + this.shootSpawnY,
|
||||
this.getX() + this.shootSpawnX - 7,
|
||||
this.getY() + this.shootSpawnY - 3,
|
||||
this.shootDirection,
|
||||
this.shootSpeed,
|
||||
this.shootDamage,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.teamteamteam.spacescooter.entity.item;
|
||||
|
||||
import de.teamteamteam.spacescooter.brain.PlayerSession;
|
||||
import de.teamteamteam.spacescooter.entity.CollidableEntity;
|
||||
import de.teamteamteam.spacescooter.entity.Player;
|
||||
import de.teamteamteam.spacescooter.entity.spi.Collidable;
|
||||
|
@ -61,7 +62,7 @@ public abstract class Item extends CollidableEntity {
|
|||
items[1] = 4; //ItemCredit
|
||||
items[2] = 2; //ItemHeal
|
||||
items[3] = 2; //ItemShield
|
||||
items[4] = 2; //ItemRocket
|
||||
items[4] = 2; //ItemRocket or ItemBeam
|
||||
items[5] = 3; //ItemIncreaseDamage
|
||||
//Add them all up
|
||||
for(i=0; i<items.length; i++) {
|
||||
|
@ -94,7 +95,11 @@ public abstract class Item extends CollidableEntity {
|
|||
new ItemShield(x, y);
|
||||
break;
|
||||
case 4:
|
||||
new ItemRocket(x, y);
|
||||
if(PlayerSession.getSecondsecondaryWeapon() == 1){
|
||||
new ItemRocket(x, y);
|
||||
}else{
|
||||
new ItemBeam(x, y);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
new ItemIncreaseDamage(x, y);
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package de.teamteamteam.spacescooter.entity.item;
|
||||
|
||||
import de.teamteamteam.spacescooter.entity.Player;
|
||||
|
||||
public class ItemBeam extends Item {
|
||||
|
||||
public ItemBeam(int x, int y) {
|
||||
super(x, y);
|
||||
this.setImage("images/items/itemBeam.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemCollected(Player player) {
|
||||
player.addBeamAmount();;
|
||||
}
|
||||
|
||||
}
|
|
@ -4,18 +4,19 @@ import de.teamteamteam.spacescooter.entity.spi.Collidable;
|
|||
|
||||
public class Beam extends Shot {
|
||||
|
||||
private int i;
|
||||
private int lifetime;
|
||||
|
||||
public Beam(int x, int y, int shootDirection, int shootSpeed, int damageValue, String filename) {
|
||||
super(x, y-35, shootDirection, shootSpeed, damageValue, filename);
|
||||
this.setImage("images/shots/beam.png");
|
||||
this.i = 0;
|
||||
this.lifetime = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
this.i++;
|
||||
if(this.i>1){
|
||||
this.lifetime++;
|
||||
if(this.lifetime>1){
|
||||
new BeamImage(this.getX(), this.getY());
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package de.teamteamteam.spacescooter.entity.shot;
|
||||
|
||||
import de.teamteamteam.spacescooter.entity.Entity;
|
||||
|
||||
public class BeamImage extends Entity {
|
||||
|
||||
private int lifetime = 0;
|
||||
|
||||
|
||||
/**
|
||||
*BeamImage show the image of the beam for a short time, without causing damage.
|
||||
*/
|
||||
public BeamImage(int x, int y) {
|
||||
super(x, y);
|
||||
this.setImage("images/shots/beam.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
this.lifetime++;
|
||||
if(this.lifetime>30){
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,7 @@ import de.teamteamteam.spacescooter.entity.spi.Collidable;
|
|||
|
||||
public class RocketExplosionRange extends Shot{
|
||||
|
||||
int i = 0;
|
||||
int lifetime = 0;
|
||||
|
||||
public RocketExplosionRange(int x, int y, int shootDirection, int shootSpeed, int damageValue, String filename) {
|
||||
super(x, y, shootDirection, shootSpeed, damageValue, filename);
|
||||
|
@ -14,8 +14,8 @@ public class RocketExplosionRange extends Shot{
|
|||
* Lifetime of the rocket explosion range.
|
||||
*/
|
||||
public void update() {
|
||||
i++;
|
||||
if(i>1){
|
||||
lifetime++;
|
||||
if(lifetime>1){
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,12 @@ package de.teamteamteam.spacescooter.gui;
|
|||
|
||||
import de.teamteamteam.spacescooter.entity.Entity;
|
||||
|
||||
//TODO: Create an ImageEntity to do this.
|
||||
public class ShopOfferValue extends Entity{
|
||||
public class ImageEntity extends Entity{
|
||||
|
||||
public ShopOfferValue(int x, int y, String filename) {
|
||||
/**
|
||||
* This only show an image.
|
||||
*/
|
||||
public ImageEntity(int x, int y, String filename) {
|
||||
super(x, y);
|
||||
setImage(filename);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package de.teamteamteam.spacescooter.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import de.teamteamteam.spacescooter.brain.PlayerSession;
|
||||
import de.teamteamteam.spacescooter.entity.Entity;
|
||||
import de.teamteamteam.spacescooter.screen.GameScreen;
|
||||
|
||||
public class SecondaryWeaponAmount extends Entity{
|
||||
|
||||
public SecondaryWeaponAmount(int x, int y) {
|
||||
super(x, y);
|
||||
if(PlayerSession.getSecondsecondaryWeapon() == 1){
|
||||
new ImageEntity(this.getX(), this.getY(), "images/shots/rocket.png");
|
||||
}else{
|
||||
new ImageEntity(this.getX(), this.getY(), "images/shots/beamamount.png");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics2D g) {
|
||||
g.setColor(Color.WHITE);
|
||||
g.setFont(new Font("Monospace", 0, 16));
|
||||
if(PlayerSession.getSecondsecondaryWeapon() == 1){
|
||||
g.drawString("x " + GameScreen.getPlayer().getRocketAmount(), this.getX() + 30, this.getY() + 12);
|
||||
}else{
|
||||
g.drawString("x " + GameScreen.getPlayer().getBeamAmount(), this.getX() + 30, this.getY() + 12);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {}
|
||||
|
||||
}
|
|
@ -19,9 +19,9 @@ public class ShopOffer extends Entity {
|
|||
this.max = max;
|
||||
for (int i = 0; i<max; i++){
|
||||
if(i<bought){
|
||||
new ShopOfferValue(x + 100 + i*35, y, "images/shopTest02.png");
|
||||
new ImageEntity(x + 140 + i*35, y - 3, "images/shop/shopbought.png");
|
||||
}else{
|
||||
new ShopOfferValue(x + 100 + i*35, y, "images/shopTest01.png");
|
||||
new ImageEntity(x + 140 + i*35, y - 3, "images/shop/shopnotbought.png");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class ShopOffer extends Entity {
|
|||
public void update() {}
|
||||
|
||||
public void buy(){
|
||||
new ShopOfferValue(this.getX() + 100 + bought*35, this.getY(), "images/shopTest02.png");
|
||||
new ImageEntity(this.getX() + 140 + bought*35, this.getY() - 3, "images/shop/shopbought.png");
|
||||
bought++;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import de.teamteamteam.spacescooter.entity.Player;
|
|||
import de.teamteamteam.spacescooter.gui.HealthBar;
|
||||
import de.teamteamteam.spacescooter.gui.InterfaceBar;
|
||||
import de.teamteamteam.spacescooter.gui.ScoreBar;
|
||||
import de.teamteamteam.spacescooter.gui.SecondaryWeaponAmount;
|
||||
import de.teamteamteam.spacescooter.gui.ShieldBar;
|
||||
import de.teamteamteam.spacescooter.level.Level;
|
||||
import de.teamteamteam.spacescooter.utility.CollisionHandler;
|
||||
|
@ -48,6 +49,7 @@ public class GameScreen extends Screen {
|
|||
new HealthBar(10, 5);
|
||||
new ShieldBar(10, 27);
|
||||
new ScoreBar(575, 33);
|
||||
new SecondaryWeaponAmount(250, 27);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public class HighscoreScreen extends Screen{
|
|||
|
||||
public HighscoreScreen(Screen parent) {
|
||||
super(parent);
|
||||
this.img = Loader.getBufferedImageByFilename("images/earthbackground.png");
|
||||
this.img = Loader.getBufferedImageByFilename("images/shopbackground.png");
|
||||
new Button(GameConfig.windowWidth/2-125, GameConfig.windowHeight-75);
|
||||
player = new Player(GameConfig.windowWidth/2-170, GameConfig.windowHeight-63);
|
||||
player.setCanMove(false);
|
||||
|
|
|
@ -11,6 +11,7 @@ import de.teamteamteam.spacescooter.brain.PlayerSession;
|
|||
import de.teamteamteam.spacescooter.control.Keyboard;
|
||||
import de.teamteamteam.spacescooter.entity.Player;
|
||||
import de.teamteamteam.spacescooter.gui.Button;
|
||||
import de.teamteamteam.spacescooter.gui.ImageEntity;
|
||||
import de.teamteamteam.spacescooter.gui.ShopOffer;
|
||||
import de.teamteamteam.spacescooter.utility.Loader;
|
||||
|
||||
|
@ -25,15 +26,28 @@ public class ShopScreen extends Screen {
|
|||
private ShopOffer damage;
|
||||
private ShopOffer shield;
|
||||
private ShopOffer life;
|
||||
private ImageEntity select;
|
||||
|
||||
/**
|
||||
* Create the shop screen.
|
||||
*/
|
||||
public ShopScreen(Screen parent) {
|
||||
super(parent);
|
||||
this.img = Loader.getBufferedImageByFilename("images/testbackground.png");
|
||||
new Button(GameConfig.windowWidth/2-125, 450);
|
||||
damage = new ShopOffer(100, 160, 15, PlayerSession.getShipShotUpgradesBought(), "Schaden");
|
||||
shield = new ShopOffer(100, 260, 15, PlayerSession.getShipShieldUpgradesBought(), "Schild");
|
||||
life = new ShopOffer(100, 360, 15, PlayerSession.getShipHealthUpgradesBought(), "Leben");
|
||||
player = new Player(50, 159);
|
||||
this.img = Loader.getBufferedImageByFilename("images/shopbackground.png");
|
||||
new Button(GameConfig.windowWidth/2-125, 500);
|
||||
damage = new ShopOffer(100, 150, 15, PlayerSession.getShipShotUpgradesBought(), "Schaden 5C");
|
||||
shield = new ShopOffer(100, 225, 15, PlayerSession.getShipShieldUpgradesBought(), "Schild 10C");
|
||||
life = new ShopOffer(100, 300, 15, PlayerSession.getShipHealthUpgradesBought(), "Leben 10C");
|
||||
new ImageEntity(GameConfig.windowWidth / 2 - 120, 365, "images/shop/shoprocket.png");
|
||||
new ImageEntity(GameConfig.windowWidth / 2 + 30, 365, "images/shop/shopbeam.png");
|
||||
if(PlayerSession.getSecondsecondaryWeapon() == 1){
|
||||
System.out.println("1");
|
||||
select = new ImageEntity(GameConfig.windowWidth / 2 - 130, 355, "images/shop/select.png");
|
||||
}else{
|
||||
System.out.println("2");
|
||||
select = new ImageEntity(GameConfig.windowWidth / 2 + 20, 355, "images/shop/select.png");
|
||||
}
|
||||
player = new Player(50, 149);
|
||||
player.setCanMove(false);
|
||||
player.setCanShoot(false);
|
||||
}
|
||||
|
@ -47,32 +61,47 @@ public class ShopScreen extends Screen {
|
|||
}
|
||||
g.setFont(new Font("Monospace", 0, 20));
|
||||
g.setColor(new Color(255, 255, 255));
|
||||
g.drawString("Credits: " + String.valueOf(PlayerSession.getCredits()), GameConfig.windowWidth/2-30, 100);
|
||||
g.drawString("Credits: " + String.valueOf(PlayerSession.getCredits()), GameConfig.windowWidth/2-45, 100);
|
||||
g.drawString("Rocket", GameConfig.windowWidth / 2 - 110, 390);
|
||||
g.drawString("Beam", GameConfig.windowWidth / 2 + 45, 390);
|
||||
g.setColor(new Color(0, 0, 0));
|
||||
g.drawString("Hauptmen\u00fc", GameConfig.windowWidth/2-55, 482);
|
||||
g.drawString("Hauptmen\u00fc", GameConfig.windowWidth/2-55, 533);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update() {
|
||||
|
||||
/**
|
||||
* Control in the menu.
|
||||
*/
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_DOWN) && !this.keyPressed && this.animationStatus == 0) {
|
||||
this.keyPressed = true;
|
||||
if(this.menuPoint<3){
|
||||
if(this.menuPoint<4){
|
||||
this.menuPoint++;
|
||||
if(menuPoint == 3){
|
||||
this.player.setPosition(GameConfig.windowWidth/2-170, this.player.getY());
|
||||
this.player.setPosition(GameConfig.windowWidth/2-180, 390);
|
||||
}else if(menuPoint == 4){
|
||||
this.player.setPosition(GameConfig.windowWidth/2-170, 508);
|
||||
}else{
|
||||
this.player.setPosition(this.player.getX(), 149+(this.menuPoint*75));
|
||||
}
|
||||
this.player.setPosition(this.player.getX(), 159+(this.menuPoint*100));
|
||||
}
|
||||
}else if(Keyboard.isKeyDown(KeyEvent.VK_UP) && !this.keyPressed && this.animationStatus == 0) {
|
||||
this.keyPressed = true;
|
||||
if(this.menuPoint>0) {
|
||||
this.menuPoint--;
|
||||
this.player.setPosition(50, this.player.getY());
|
||||
this.player.setPosition(this.player.getX(), 159+(this.menuPoint*100));
|
||||
if(menuPoint == 3){
|
||||
this.player.setPosition(GameConfig.windowWidth/2-180, 390);
|
||||
}else{
|
||||
this.player.setPosition(50, 149+(this.menuPoint*75));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Selection.
|
||||
*/
|
||||
}else if ( (Keyboard.isKeyDown(KeyEvent.VK_SPACE) || Keyboard.isKeyDown(KeyEvent.VK_ENTER)) && !this.keyPressed && this.animationStatus == 0) {
|
||||
this.keyPressed = true;
|
||||
///////////////////////////////////////////////////////////////
|
||||
switch (this.menuPoint) {
|
||||
case 0:
|
||||
if(PlayerSession.getCredits() >= 5 && damage.getBought() < damage.getMax()){
|
||||
|
@ -99,6 +128,15 @@ public class ShopScreen extends Screen {
|
|||
}
|
||||
break;
|
||||
case 3:
|
||||
if(PlayerSession.getSecondsecondaryWeapon() == 1){
|
||||
select.setPosition(GameConfig.windowWidth / 2 + 20, 355);
|
||||
PlayerSession.setSecondsecondaryWeapon(2);
|
||||
}else{
|
||||
select.setPosition(GameConfig.windowWidth / 2 - 130, 355);
|
||||
PlayerSession.setSecondsecondaryWeapon(1);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
this.animationStatus = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -107,6 +145,9 @@ public class ShopScreen extends Screen {
|
|||
this.keyPressed = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Animation.
|
||||
*/
|
||||
if(this.animationStatus == 1) {
|
||||
if(this.player.getX() <= GameConfig.windowWidth) {
|
||||
this.player.setPosition(this.player.getX() + (int) playerMoveSpeed, this.player.getY());
|
||||
|
|