This commit is contained in:
Sosch 2014-10-31 09:29:00 +01:00
parent efed113880
commit 72be799fec
3 changed files with 19 additions and 35 deletions

View File

@ -6,6 +6,7 @@ import de.teamteamteam.spacescooter.utility.GameConfig;
public class Player extends ShootingEntity {
private boolean canMove = true;
public Player(int x, int y) {
super(x, y);
@ -18,19 +19,19 @@ public class Player extends ShootingEntity {
}
public void update() {
if(canMove){
if(this.canMove){
super.update();
int off = 3;
if(Keyboard.isKeyDown(KeyEvent.VK_UP) && this.y > 0) {
this.y -= off;
}
if(Keyboard.isKeyDown(KeyEvent.VK_DOWN) && this.y < (GameConfig.windowHeight - Player.img.getHeight())) {
if(Keyboard.isKeyDown(KeyEvent.VK_DOWN) && this.y < (GameConfig.windowHeight - this.getImage().getHeight())) {
this.y += off;
}
if(Keyboard.isKeyDown(KeyEvent.VK_LEFT) && this.x > 0) {
this.x -= off;
}
if(Keyboard.isKeyDown(KeyEvent.VK_RIGHT) && this.x < (GameConfig.windowWidth - Player.img.getWidth())) {
if(Keyboard.isKeyDown(KeyEvent.VK_RIGHT) && this.x < (GameConfig.windowWidth - this.getImage().getWidth())) {
this.x += off;
}
if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) {

View File

@ -1,32 +1,15 @@
package de.teamteamteam.spacescooter.gui;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.entity.Player;
public class Button extends Entity{
private static BufferedImage img;
static{
try {
img = ImageIO.read(Player.class.getClassLoader().getResourceAsStream("images/button.png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public Button(int x, int y) {
super(x, y);
this.setImage(img);
this.setImage("images/button.png");
}
@Override
public void update() {
}

View File

@ -25,7 +25,7 @@ public class GamePausedScreen extends Screen {
private int colorValue = 0;
private boolean colorValueIncrease = true;
private int menuPoint = 0;
private int animationStatus = 0; //0 = Noch nicht gestartet, 1 = Animation läuft, 2 = Animation beendet
private int animationStatus = 0; //0 = Noch nicht gestartet, 1 = Animation läuft, 2 = Animation beendet
static{
try {
@ -58,7 +58,7 @@ public class GamePausedScreen extends Screen {
g.setFont(new Font("Monospace", 0, 20));
g.setColor(new Color(0, 0, 0));
g.drawString("Weiter", GameConfig.windowWidth/2-30, 332);
g.drawString("Hauptmenü", GameConfig.windowWidth/2-50, 432);
g.drawString("Hauptmenü", GameConfig.windowWidth/2-50, 432);
}
@Override
@ -69,33 +69,33 @@ public class GamePausedScreen extends Screen {
i.next().update();
}
if(colorValueIncrease){
colorValue += 2;
if(colorValue > 70) colorValueIncrease = false;
if(this.colorValueIncrease){
this.colorValue += 2;
if(this.colorValue > 70) this.colorValueIncrease = false;
}else{
colorValue -= 2;
if(colorValue < -70) colorValueIncrease = true;
this.colorValue -= 2;
if(this.colorValue < -70) this.colorValueIncrease = true;
}
if(Keyboard.isKeyDown(KeyEvent.VK_DOWN)){
menuPoint = 1;
this.menuPoint = 1;
player.setPosition(player.getX(), 409);
}
if(Keyboard.isKeyDown(KeyEvent.VK_UP)){
menuPoint = 0;
this.menuPoint = 0;
player.setPosition(player.getX(), 309);
}
if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) {
animationStatus = 1;
this.animationStatus = 1;
}
if(animationStatus == 1){
if(this.animationStatus == 1){
if(player.getX() <= GameConfig.windowWidth){
player.setPosition(player.getX() + (int)playerMoveSpeed, player.getY());
playerMoveSpeed += 0.1;
}else animationStatus = 2;
}else if(animationStatus == 2){
switch (menuPoint) {
}else this.animationStatus = 2;
}else if(this.animationStatus == 2){
switch (this.menuPoint) {
case 0:
this.parent.setOverlay(null);
break;