Initial Commit für JavaGameÜbungen

main
Alex 2 years ago
parent 6830b8ca2f
commit 13522bd781

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="F:/FH Folder/Eclipse Workspace/workspace/LWJGL/lib/lwjgl.jar">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="F:/FH Folder/Eclipse Workspace/workspace/LWJGL/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="F:/FH Folder/Eclipse Workspace/workspace/LWJGL/lib/slick.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FroggerGame</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,210 @@
package Main;
//Importe
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
public class JnP extends BasicGame
{
// Main Klasse des Games
public JnP()
{
super("Jump 'n' Pong");
}
// Objekterstellungen
Panel panel;
Level level;
UserInterface hud;
Invader invader;
Player protector;
State gameState;
Menu menu;
float waiter;// Zeit-Laufvariable
@Override
public void init(final GameContainer gc) throws SlickException
{
// TODO Auto-generated method stub
// Objekterstellung (außer Ball -> Erstellung in der Invader-Klasse
this.hud = new UserInterface();
this.invader = new Invader();
this.protector = new Player();
this.level = new Level();
this.gameState = new State();
this.menu = new Menu();
this.panel = new Panel();
// Initialisierung
this.gameState.init(gc);
this.menu.init(gc, this.gameState);
this.level.init(gc, this.invader, this.protector, this.hud, this.gameState, this.panel, this.waiter);// Initialisierung
// mit
// Vererbung
// aller
// Objekte
this.panel.init(gc, this.gameState, 1);// Initialisierung + Angabe des
// Startlevels
this.hud.init(gc, this.gameState);
this.waiter = 0; // Setzung der Zeit zu Begin
}
@Override
public void update(final GameContainer gc, final int delta) throws SlickException
{
// TODO Auto-generated method stub
final float _delta = delta / 1000f;
this.waiter += _delta; // Zeit läuft
// Menu exit
if (gc.getInput().isKeyDown(Input.KEY_ENTER) && ((this.level.selectedString == 2) || (this.menu.selectedString == 2)))
{
gc.exit();
}
// Press Enter start screen
if (gc.getInput().isKeyDown(Input.KEY_ENTER) && (this.level.selectedString == 0) && (this.level.waiter > 3) && (this.gameState.stateId == 0))
{
this.gameState.stateId = 4;
this.level.waiter = 0;
}
// Menu startgame Option
if (gc.getInput().isKeyDown(Input.KEY_ENTER) && (this.level.waiter > 0.3) && (this.menu.selectedString == 0) && (this.gameState.stateId == 4))
{
this.gameState.stateId = 6;
this.level.waiter = 0;
}
// Pause Menu resume game Option
if (gc.getInput().isKeyDown(Input.KEY_ENTER) && (this.level.waiter > 3) && (this.menu.selectedString == 0) && (this.gameState.stateId == 2))
{
this.gameState.stateId = 1;
}
// Control Instructions Screen Timer
if ((this.gameState.stateId == 6) && (this.level.waiter > 10))
{
this.gameState.stateId = 5;
this.level.waiter = 0;
}
// Intro Screen Timer
if ((this.gameState.stateId == 5) && (this.level.waiter > 5))
{
this.panel.xPos = 350;
this.gameState.stateId = 1;
this.level.waiter = 0;
}
// Win State Bedingung
if ((this.gameState.stateId == 1) && (this.level.currentLevel == 5) && (this.hud.sbar_width >= 100))
{
this.level.waiter = 0;
this.gameState.stateId = 8;
}
// Win Screen Timer
if ((this.gameState.stateId == 8) && (this.level.waiter > 5))
{
this.gameState.stateId = 4;
this.level.currentLevel = 1;
// Initialisierung eines "Neuen Spiels"
this.panel.init(gc, this.gameState, 1);
this.hud.init(gc, this.gameState);
this.invader.init(gc, this.gameState);
this.protector.init(gc, this.gameState, 50);
this.level.init(gc, this.invader, this.protector, this.hud, this.gameState, this.panel, _delta);
this.menu.init(gc, this.gameState);
}
// Pause Menu Aktivierung
if (gc.getInput().isKeyPressed(Input.KEY_P) && (this.gameState.stateId == 1))
{
this.gameState.stateId = 2;
}
// Game Over Bedingung
if ((this.hud.dbar_width <= 0) && (this.gameState.stateId == 1))
{
this.level.waiter = 0;
this.gameState.stateId = 7;
}
// Neues Game nach Game Over
if ((this.gameState.stateId == 7) && (this.level.waiter > 10))
{
this.panel.init(gc, this.gameState, 1);
this.hud.init(gc, this.gameState);
this.invader.init(gc, this.gameState);
this.protector.init(gc, this.gameState, 50);
this.level.init(gc, this.invader, this.protector, this.hud, this.gameState, this.panel, _delta);
this.menu.init(gc, this.gameState);
this.level.currentLevel = 1;
this.gameState.stateId = 4;
}
// Update Aufrufe
this.gameState.update(gc, _delta);
this.level.update(gc, _delta);
this.menu.update(gc, _delta);
this.panel.update(gc, _delta);
}
@Override
public void render(final GameContainer gc, final Graphics g) throws SlickException
{
// TODO Auto-generated method stub
// Renderaufrufe
this.gameState.render(gc, g);
this.level.render(gc, g);
this.menu.render(gc, g);
this.hud.render(gc, g);
// Titel screen Einblendung
if ((this.gameState.stateId == 0) && (this.waiter > 3))
{
g.drawString("Press Enter", 350, 550);
}
}
// Hauptmethode
public static void main(final String[] args)
{
try
{// Apperstellung
final AppGameContainer app = new AppGameContainer(new JnP());
app.setDisplayMode(800, 600, false);// Fullscreen 800x600
app.setTargetFrameRate(60);// Flüssige FPS von 60
app.setVSync(true);// VSinc um Renderprobleme bei schneller
// Objektbewegung zu verhindern
app.setShowFPS(true);
app.start();
}
catch (final SlickException e)
{
e.printStackTrace();
}
}
}

@ -0,0 +1,538 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
public class Level
{
private Image cyberg, title, paused, instructionScreen, missionScreen,
alert, clearedLevel;
private Invader invader;
private Player protector;
private UserInterface ui;
private State state;
// Levelbezeichnungen
private String[] level =
{ "-1- First Contact |", "-2- Two Paths to Core |", "-3- Cyberlabyrinth", "-4-", " -5- Final Fight |" };
// Game Over Screen Erstellung
private Image game_over_screen0, game_over_screen1, game_over_screen2,
game_over_screen3, game_over_screen4, game_over_screen5, game_over_screen6,
game_over_screen7, game_over_screen8;
Image[] game_over_screens =
{ this.game_over_screen0, this.game_over_screen1, this.game_over_screen2, this.game_over_screen3, this.game_over_screen4, this.game_over_screen5, this.game_over_screen6, this.game_over_screen7, this.game_over_screen8 };
int selectedString, currentLevel;
SpriteSheet shock, arrows_sheet, walk_demo_sheet, virus_demo_sheet,
rider_demo_sheet, shock_demo_sheet;
Animation selected, arrows, walk_demo, game_over, virus_demo, rider_demo,
shock_demo;
Panel panel;
float waiter;// Ingame Zeit
boolean changedDirection = false;// Indikator für Richtungswechsel
public void init(final GameContainer gc, final Invader invader, final Player player, final UserInterface ui, final State gameState, final Panel panel, final float waiter) throws SlickException
{
this.game_over_screen0 = new Image("Main/cybergrid.png");
this.game_over_screen1 = new Image("Main/game_Over1.png");
this.game_over_screen2 = new Image("Main/game_Over2.png");
this.game_over_screen3 = new Image("Main/game_Over3.png");
this.game_over_screen4 = new Image("Main/game_Over4.png");
this.game_over_screen5 = new Image("Main/game_Over5.png");
this.game_over_screen6 = new Image("Main/game_Over6.png");
this.game_over_screen7 = new Image("Main/game_Over7.png");
this.game_over_screen8 = new Image("Main/game_Over8.png");
this.waiter = waiter;
this.panel = panel;
this.state = gameState;
this.invader = invader;
this.protector = player;
this.ui = ui;
this.alert = new Image("Main/Hack_Alert.png");
this.clearedLevel = new Image("Main/level_cleared_screen.png");
this.instructionScreen = new Image("Main/key_instructions.png");
this.missionScreen = new Image("Main/mission.png");
this.arrows_sheet = new SpriteSheet("Main/arrows_sheet.png", 101, 101);
this.walk_demo_sheet = new SpriteSheet("Main/robot_sheet_good.png", 50, 100);
this.virus_demo_sheet = new SpriteSheet("Main/Virus_sheet.png", 72, 72);
this.rider_demo_sheet = new SpriteSheet("Main/rider.png", 75, 75);
this.shock_demo_sheet = new SpriteSheet("Main/shock.png", 75, 45);
this.arrows = new Animation(this.arrows_sheet, 0, 0, 3, 2, true, 200, true);
this.walk_demo = new Animation(this.walk_demo_sheet, 0, 0, 5, 2, true, 200, true);
this.virus_demo = new Animation(this.virus_demo_sheet, 2, 1, 3, 4, true, 200, true);
this.rider_demo = new Animation(this.rider_demo_sheet, 0, 0, 2, 0, true, 200, true);
this.shock_demo = new Animation(this.shock_demo_sheet, 0, 0, 3, 0, true, 200, true);
this.selectedString = 0;// Default Auswahl im Menu
this.currentLevel = 1;// Initial Level zu Begin
this.cyberg = new Image("Main/cybergrid.png");
this.title = new Image("Main/titel.png");
this.paused = new Image("Main/paused_menu.png");
this.shock = new SpriteSheet("Main/shock.png", 75, 45);
this.selected = new Animation(this.shock, 0, 0, 3, 0, true, 250, true);
this.protector.init(gc, gameState, 100);// Roboter Initialisierung an
// YPosition 100
invader.init(gc, gameState);
}
public void render(final GameContainer gc, final Graphics g) throws SlickException
{
// Rendering abhängig von State
switch (this.state.currentState)
{
case "win":// Sieges Screen
g.drawImage(this.clearedLevel, 0, 0);
g.setColor(Color.cyan);
g.drawLine(0, 100, 800, 100);
break;
// game over Pseudo-Animation
case "gameOver":
if (this.waiter > 5)
{
g.drawImage(this.game_over_screen8, 0, 0);
}
else if (this.waiter > 4.2)
{
g.drawImage(this.game_over_screen7, 0, 0);
}
else if (this.waiter > 3.8)
{
g.drawImage(this.game_over_screen6, 0, 0);
}
else if (this.waiter > 3.2)
{
g.drawImage(this.game_over_screen5, 0, 0);
}
else if (this.waiter > 2.8)
{
g.drawImage(this.game_over_screen4, 0, 0);
}
else if (this.waiter > 2.2)
{
g.drawImage(this.game_over_screen3, 0, 0);
}
else if (this.waiter > 1.8)
{
g.drawImage(this.game_over_screen2, 0, 0);
}
else if (this.waiter > 1.2)
{
g.drawImage(this.game_over_screen1, 0, 0);
}
else
{
g.drawImage(this.game_over_screen0, 0, 0);
}
break;
// Steuerungs Screens
case "controlInstructions":
if (this.waiter < 5)
{
g.drawImage(this.instructionScreen, 0, 0);
this.arrows.draw(150, 200);
this.walk_demo.draw(550, 200);
}
else if (this.waiter > 6)
{// "Missions screen"
g.drawImage(this.missionScreen, 0, 0);
this.walk_demo.draw(550, 200);
this.virus_demo.draw(550, 300);
this.rider_demo.draw(550, 430);
this.shock_demo.draw(550, 460);
}
break;
case "level_intro":
// Level intro je nach currentLevel
switch (this.currentLevel)
{
case 1:
this.alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("1", 300, 330);
g.drawString("-First Contact-", 330, 330);
break;
case 2:
this.alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("2", 300, 330);
g.drawString("-Two Paths to the Core-", 330, 330);
break;
case 3:
this.alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("3", 300, 330);
g.drawString("-The Cyberlabyrinth-", 330, 330);
break;
case 4:
this.alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("4", 300, 330);
g.drawString("-The prelast level-", 330, 330);
break;
case 5:
this.alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("5", 300, 330);
g.drawString("-Final Fight-", 330, 330);
break;
}
break;
case "titel":
g.drawImage(this.title, 0, 0);
break;
case "paused":
this.cyberg.draw(0, 0, 800, 600);
this.panel.render(gc, g);
this.protector.render(gc, g);
this.invader.render(gc, g);
g.setColor(Color.magenta);
// Pause Menü Tags
this.paused.draw(225, 250);
g.drawString("Resume Game", 425, 290);
g.drawString("Options(Not Implemented)", 425, 320);
g.drawString("Exit Game", 425, 350);
// Name des Levels in der UI
switch (this.currentLevel)
{
case 1:
g.drawString(this.level[0], 30, 555);
break;
case 2:
g.drawString(this.level[1], 30, 555);
break;
case 3:
g.drawString(this.level[2], 30, 555);
break;
case 4:
g.drawString(this.level[3], 30, 555);
break;
case 5:
g.drawString(this.level[4], 30, 555);
break;
}
switch (this.selectedString)
{
case 0:
this.selected.draw(325, 280);
break;
case 1:
this.selected.draw(325, 310);
break;
case 2:
this.selected.draw(325, 340);
break;
}
break;
case "start":
this.cyberg.draw(0, 0, 800, 600);
this.panel.render(gc, g);
this.protector.render(gc, g);
this.invader.render(gc, g);
g.setColor(Color.red);
g.drawLine(0, gc.getHeight() - 50, 800, gc.getHeight() - 50);// Systemlebenslinie
g.setColor(Color.magenta);
switch (this.currentLevel)
{
case 1:
g.drawString(this.level[0], 30, 555);
break;
case 2:
g.drawString(this.level[1], 30, 555);
break;
case 3:
g.drawString(this.level[2], 30, 555);
break;
case 4:
g.drawString(this.level[3], 30, 555);
break;
case 5:
g.drawString(this.level[4], 30, 555);
break;
}
break;
}
}
public void update(final GameContainer gc, final float _delta) throws SlickException
{
this.waiter += _delta;// Ingame Zeit
switch (this.state.currentState)
{
case "paused":
// Kontrolle im Menü
if (gc.getInput().isKeyPressed(Input.KEY_UP) && (this.selectedString > 0))
{
this.selectedString--;
}
if (gc.getInput().isKeyPressed(Input.KEY_DOWN) && (this.selectedString < 2))
{
this.selectedString++;
}
break;
case "start":
this.protector.update(gc, _delta);
this.invader.update(gc, _delta);
if (!this.invader.isParalized && (this.invader.para_timer >= 5) && (this.currentLevel == 5))
{
// invader movement in final level//
if (((this.invader.riderX + 75) > (this.panel.xPos + (this.panel.xSize * 15))) && (this.changedDirection == false))
{
this.invader.flightSpdX *= -1;
this.invader.fly_right = false;
this.changedDirection = true;
}
if (((this.invader.riderX - 75) < (this.panel.xPos + (this.panel.xSize * 1))) && (this.changedDirection == false))
{
this.invader.flightSpdX *= -1;
this.invader.fly_right = true;
this.changedDirection = true;
}
if ((this.invader.riderX < (this.panel.xPos + (this.panel.xSize * 9))) && (this.invader.riderX > (this.panel.xPos + (this.panel.xSize * 6))) && (this.changedDirection == true))
{
this.changedDirection = false;
}
// Ball Bewegung im letzten level
if ((this.invader.ball.xPos - 36) > (this.panel.xPos + (this.panel.xSize * 15)))
{
this.invader.ball.collisionManager("x_inverted");
}
if ((this.invader.ball.xPos + 36) < (this.panel.xPos + (this.panel.xSize * 1)))
{
this.invader.ball.collisionManager("x_inverted");
}
}
// Level ende und wechsel zum nächsten Level
if ((this.panel.xPos <= -4350) && this.protector.isLanded)
{
this.currentLevel++;
this.waiter = 0;
this.state.stateId = 5;
this.panel.init(gc, this.state, this.currentLevel);
this.protector.init(gc, this.state, -100);
this.invader.init(gc, this.state);
this.ui.sbar_width = 0;
this.invader.isParalized = false;
this.panel.xPos = 350;
}
// Roboter - Panel kollision
for (int i = 1; i < this.panel.collisionarea.length; i++)
{
if (this.panel.collisionarea[i].intersects(this.protector.getCollisionarea()) && !this.protector.hasFloorContact)
{
this.protector.ySpd = 0;
this.protector.setFloorContact(true);
this.protector.isLanded = true;
}
else
{
this.protector.hasFloorContact = false;
}
// einsetzen der "Gravitation"
if (this.panel.collisionarea[i].intersects(this.protector.getCollisionarea()) && !this.protector.hasFloorContact)
{
this.protector.ySpd *= 0;
}
}
// Roboter Sprung
if (gc.getInput().isKeyDown(Input.KEY_UP) && this.protector.isLanded)
{
if (this.protector.isRunningRight)
{
this.protector.move = 3;
}
else if (this.protector.isRunningLeft)
{
this.protector.move = 4;
}
else
{
this.protector.move = 0;
}
this.protector.hasFloorContact = false;
this.protector.ySpd = -400;
this.protector.isLanded = false;
}
// Ball fliegt oben aus dem Screen
if ((this.invader.ball.yPos < 0) && !this.invader.ball.ballIsKilled)
{
this.invader.ball.killBall(gc);
this.protector.ballhit = false;
}
// Kollision Ball - Hacker
if ((this.invader.ball.yPos < (this.invader.riderY + 75)) && (this.invader.ball.yPos > this.invader.riderY) && (this.invader.ball.xPos < (this.invader.riderX + 75)) && (this.invader.ball.xPos > this.invader.riderX))
{
this.invader.ball.killBall(gc);
this.ui.sbar_width += 20;
this.protector.ballhit = false;
}
// Disconnected Erzeugung
if ((this.ui.sbar_width >= 100) && !this.invader.isParalized)
{
this.invader.isParalized = true;
this.invader.paralized();
}
// ReConect des Hackers
if ((this.invader.para_timer >= 5) && (this.ui.sbar_width >= 100))
{
this.ui.sbar_width -= 100;
this.invader.isParalized = false;
}
// Ball Kollidiert mit Systemlebenslinie
if ((this.invader.ball.yPos >= (gc.getHeight() - 50)))
{
this.invader.ball.killBall(gc);
this.protector.ballhit = false;
if (this.ui.dbar_width > 0)
{
this.ui.dbar_width -= 20;
}
}
// Ball - Roboter Kollision
if ((this.invader.ball.yPos >= (this.protector.yPos - 50)) && (this.invader.ball.xPos >= (this.protector.xPos - 25)) && (this.invader.ball.xPos <= (this.protector.xPos + 25)) && (this.invader.ball.yPos <= (this.protector.yPos + 50)) && !this.protector.ballhit)
{
this.invader.ball.collisionManager("y_inverted");
this.protector.ballhit = true;
}
// roboter rechtsbewegung
if (gc.getInput().isKeyDown(Input.KEY_RIGHT))
{
if (this.protector.isLanded)
{
this.protector.move = 1;
}
else
{
this.protector.move = 3;
}
this.panel.xSpd = -200;
this.invader.ball.xPos -= 3;
if (!this.invader.isParalized)
{
this.invader.riderX -= 3;
}
}
else
// roboter Linksbewegung
if (gc.getInput().isKeyDown(Input.KEY_LEFT))
{
if (this.protector.isLanded)
{
this.protector.move = 2;
}
else
{
this.protector.move = 4;
}
this.panel.xSpd = 200;
this.invader.ball.xPos += 3;
if (!this.invader.isParalized)
{
this.invader.riderX += 3;
}
}
else
{// roboter stand bewegung
this.protector.move = 0;
this.panel.xSpd = 0;
}
// roboter fliegt unten durch den Screen
if (this.protector.yPos > 800)
{
this.protector.init(gc, this.state, -100);
this.panel.xPos = 350;
this.invader.init(gc, this.state);
this.invader.ball.killBall(gc);
this.ui.sbar_width = 0;
this.ui.dbar_width -= 20;
this.invader.isParalized = false;
}
break;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 KiB

Binary file not shown.

Binary file not shown.

@ -0,0 +1,72 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
public class Ball {
SpriteSheet virus_sheet;
Animation virus;
int xPos,yPos;
float xSpd,ySpd;
boolean isColliding = false,ballIsKilled = true;
//initial methode mit Koordinatenbestimmung und startrichtung
void init (GameContainer gc,int xPos, int yPos, int invaderSpd) throws SlickException{
this.xPos = xPos;
this.yPos = yPos;
this.xSpd = 1.0f * invaderSpd;//initiierung mit Hacker flugrichtungsindikation
this.ySpd = 1.0f;
virus_sheet = new SpriteSheet ("Main/Virus_sheet.png", 72, 72);
virus = new Animation(virus_sheet,2,1,3,4,true,200,true);
}
void render(GameContainer gc, Graphics g) throws SlickException{
virus.draw(xPos-36, yPos-36);
}
void update(GameContainer gc, float _delta)throws SlickException{
this.xPos += xSpd;
this.yPos += ySpd;
}
public void collisionManager(String direction){//Verwaltet Apprallrichtung und intensität
switch(direction){
case "x_inverted" :this.xSpd *= -1; break;
case "y_inverted" :this.ySpd *= -1; break;
case "rebounce" :this.xSpd *= -1; this.ySpd *= -1;break;
case "left" :this.xSpd *= -1; this.ySpd *= -1;break;
case "midleft" :this.xSpd *= 2; this.ySpd *= -1;break;
case "middle" :this.ySpd *= -1; break;
case "midright" :this.xSpd *= 2; this.ySpd *= -1;break;
case "right" :this.xSpd *= -1; this.ySpd *= -1;break;
}
}
//ball "zerstörung"
public void killBall(GameContainer gc) throws SlickException{
init(gc, -50,350, 1);
ballIsKilled=true;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@ -0,0 +1,140 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
public class Invader {
int riderX, riderY,flightSpdX,flightSpdY;
SpriteSheet rider,shocking;
Animation flight_left, flight_right,shock;
String flight_direction;//Flugrichtung
float countDown,para_timer;
boolean readyToFire,//Check für die Abschuss automatik
ball_shoot,//Check ob Ball abgefeuert wurde
fly_right,//Check ob Flugrichtung rechts
isParalized;//Disconnected check
Ball ball;//Definierung eines Ball objektes
private State state;
void init(GameContainer gc, State gameState) throws SlickException{
this.state = gameState;
riderX = 450;
riderY = 30;
flightSpdX = 1;
flightSpdY = 1;
flight_direction = "right";
fly_right = true;
ball_shoot= false;
isParalized = false;
rider = new SpriteSheet("Main/rider.png", 75, 75);
shocking = new SpriteSheet("Main/shock.png", 75, 45);
flight_left = new Animation(rider,0,1,2,1,true,250,true);
flight_right = new Animation(rider,0,0,2,0,true,250,true);
shock = new Animation(shocking,0,0,3,0,true,250,true);
countDown = 3.1f;
para_timer = 5.1f;
readyToFire = false;
ball = new Ball();//erstellung des Ballobjektes
}
void render(GameContainer gc, Graphics g) throws SlickException{
switch(state.currentState){
case "titel":break;
case "start": case "paused":
if(fly_right)//rechtsflug animation
flight_right.draw(riderX, riderY);
else//linksflug animation
flight_left.draw(riderX, riderY);
//ball wird nur gerendert falls er abgeschossen wurde
if(ball_shoot){
ball.render(gc, g);
}
//shock animation des Disconnected Status
if(para_timer < 5){
shock.draw(riderX, riderY+20);
}
break;
}
}
void update(GameContainer gc, float _delta) throws SlickException{
switch(state.currentState){
case "paused":break;
case "start" :
countDown += _delta;
para_timer += _delta;
//flug nur bei Connected Status
if(!isParalized&& para_timer >=5 ){
riderX += flightSpdX;
//Abschuss automatik
if(readyToFire == true && countDown > 3 ){
ball.init(gc, riderX+37, riderY+80, flightSpdX);
ball_shoot = true;
readyToFire= false;
}
}
//ball bewegung
if(ball_shoot&&!ball.ballIsKilled)
ball.update(gc, _delta );
//ball wird bei zerstörung für den schuss vorbereitet
if(ball.ballIsKilled){
prepareToFire();
ball.ballIsKilled =false;
}
gc.getInput().clearKeyPressedRecord();//Tastendruck löschung zur Sicherheit
break;
}
}
//Abschussmethode
void prepareToFire(){
countDown = 0;
readyToFire = true;
ball_shoot = false;
}
//Disconnected Methode
void paralized(){
para_timer = 0;
}
}

@ -0,0 +1,175 @@
package Main;
//Importe
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;//für Tastennutzung
import org.newdawn.slick.SlickException;
public class JnP extends BasicGame {
//Main Klasse des Games
public JnP() {
super("Jump 'n' Pong");
}
//Objekterstellungen
Panel panel;
Level level;
UserInterface hud;
Invader invader;
Player protector;
State gameState;
Menu menu;
float waiter;//Zeit-Laufvariable
public void init(GameContainer gc) throws SlickException {
// TODO Auto-generated method stub
//Objekterstellung (außer Ball -> Erstellung in der Invader-Klasse
hud = new UserInterface();
invader = new Invader();
protector = new Player();
level = new Level();
gameState = new State();
menu = new Menu();
panel = new Panel();
//Initialisierung
gameState.init(gc);
menu.init(gc, gameState);
level.init(gc,invader,protector,hud,gameState,panel,waiter);//Initialisierung mit Vererbung aller Objekte
panel.init(gc,gameState,1);// Initialisierung + Angabe des Startlevels
hud.init(gc,gameState);
waiter = 0; //Setzung der Zeit zu Begin
}
@Override
public void update(GameContainer gc, int delta) throws SlickException {
// TODO Auto-generated method stub
float _delta = delta /1000f;
this.waiter += _delta; //Zeit läuft
//Menu exit
if(gc.getInput().isKeyDown(Input.KEY_ENTER) && (level.selectedString == 2||menu.selectedString == 2))
gc.exit();
// Press Enter start screen
if(gc.getInput().isKeyDown(Input.KEY_ENTER)&& (level.selectedString == 0)&& level.waiter >3 && gameState.stateId==0){
gameState.stateId = 4;level.waiter = 0;
}
//Menu startgame Option
if(gc.getInput().isKeyDown(Input.KEY_ENTER)&&level.waiter >0.3 && (menu.selectedString == 0) && gameState.stateId==4){
gameState.stateId = 6;level.waiter = 0;
}
//Pause Menu resume game Option
if(gc.getInput().isKeyDown(Input.KEY_ENTER)&&level.waiter >3 && (menu.selectedString == 0) && gameState.stateId==2){
gameState.stateId = 1;
}
//Control Instructions Screen Timer
if(gameState.stateId == 6 && level.waiter >10){
gameState.stateId = 5;
level.waiter = 0;
}
//Intro Screen Timer
if(gameState.stateId == 5 && level.waiter > 5){
panel.xPos = 350;
gameState.stateId = 1;
level.waiter = 0;
}
//Win State Bedingung
if(gameState.stateId == 1 && level.currentLevel == 5 && hud.sbar_width >=100){
level.waiter = 0 ;
gameState.stateId = 8;
}
//Win Screen Timer
if(gameState.stateId == 8 && level.waiter > 5){
gameState.stateId = 4;
level.currentLevel = 1;
//Initialisierung eines "Neuen Spiels"
panel.init(gc, gameState, 1);
hud.init(gc, gameState);
invader.init(gc, gameState);
protector.init(gc, gameState, 50);
level.init(gc, invader, protector, hud, gameState, panel, _delta);
menu.init(gc, gameState);
}
//Pause Menu Aktivierung
if(gc.getInput().isKeyPressed(Input.KEY_P )&& (gameState.stateId == 1))
gameState.stateId = 2;
//Game Over Bedingung
if(hud.dbar_width<=0 && gameState.stateId==1){
level.waiter = 0;
gameState.stateId = 7;
}
//Neues Game nach Game Over
if(gameState.stateId == 7 &&level.waiter > 10){
panel.init(gc, gameState, 1);
hud.init(gc, gameState);
invader.init(gc, gameState);
protector.init(gc, gameState, 50);
level.init(gc, invader, protector, hud, gameState, panel, _delta);
menu.init(gc, gameState);
level.currentLevel = 1;
gameState.stateId = 4;
}
//Update Aufrufe
gameState.update(gc, _delta);
level.update(gc, _delta);
menu.update(gc, _delta);
panel.update(gc, _delta);
}
@Override
public void render(GameContainer gc, Graphics g) throws SlickException {
// TODO Auto-generated method stub
//Renderaufrufe
gameState.render(gc, g);
level.render(gc, g);
menu.render(gc, g);
hud.render(gc, g);
//Titel screen Einblendung
if(gameState.stateId == 0 && waiter >3){
g.drawString("Press Enter", 350, 550);
}
}
//Hauptmethode
public static void main(String[] args) {
try {//Apperstellung
AppGameContainer app = new AppGameContainer(new JnP());
app.setDisplayMode(800, 600, true);//Fullscreen 800x600
app.setTargetFrameRate(60);//Flüssige FPS von 60
app.setVSync(true);//VSinc um Renderprobleme bei schneller Objektbewegung zu verhindern
app.setShowFPS(false);
app.start();
}
catch (SlickException e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,455 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
public class Level{
private Image cyberg,title,paused,instructionScreen,missionScreen,alert,clearedLevel;
private Invader invader;
private Player protector;
private UserInterface ui;
private State state;
//Levelbezeichnungen
private String[] level = {"-1- First Contact |", "-2- Two Paths to Core |", "-3- Cyberlabyrinth", "-4-", " -5- Final Fight |"};
//Game Over Screen Erstellung
private Image game_over_screen0,game_over_screen1,game_over_screen2,game_over_screen3,game_over_screen4,game_over_screen5,game_over_screen6,game_over_screen7,game_over_screen8;
Image[] game_over_screens = { game_over_screen0,
game_over_screen1,
game_over_screen2,
game_over_screen3,
game_over_screen4,
game_over_screen5,
game_over_screen6,
game_over_screen7,
game_over_screen8};
int selectedString,currentLevel;
SpriteSheet shock,arrows_sheet,walk_demo_sheet,virus_demo_sheet,rider_demo_sheet,shock_demo_sheet;
Animation selected,arrows,walk_demo,game_over,virus_demo,rider_demo,shock_demo;
Panel panel;
float waiter;//Ingame Zeit
boolean changedDirection = false;//Indikator für Richtungswechsel
public void init(GameContainer gc, Invader invader, Player player, UserInterface ui, State gameState, Panel panel, float waiter) throws SlickException{
game_over_screen0 = new Image("Main/cybergrid.png");
game_over_screen1 = new Image("Main/game_Over1.png");
game_over_screen2 = new Image("Main/game_Over2.png");
game_over_screen3 = new Image("Main/game_Over3.png");
game_over_screen4 = new Image("Main/game_Over4.png");
game_over_screen5 = new Image("Main/game_Over5.png");
game_over_screen6 = new Image("Main/game_Over6.png");
game_over_screen7 = new Image("Main/game_Over7.png");
game_over_screen8 = new Image("Main/game_Over8.png");
this.waiter = waiter;
this.panel = panel;
this.state = gameState;
this.invader = invader;
this.protector = player;
this.ui = ui;
alert = new Image("Main/Hack_Alert.png");
clearedLevel = new Image("Main/level_cleared_screen.png");
instructionScreen = new Image("Main/key_instructions.png");
missionScreen = new Image("Main/mission.png");
arrows_sheet = new SpriteSheet("Main/arrows_sheet.png" ,101, 101);
walk_demo_sheet = new SpriteSheet("Main/robot_sheet_good.png",50,100);
virus_demo_sheet = new SpriteSheet("Main/Virus_sheet.png",72,72);
rider_demo_sheet = new SpriteSheet("Main/rider.png",75,75);
shock_demo_sheet = new SpriteSheet("Main/shock.png",75,45);
arrows = new Animation(arrows_sheet,0,0,3,2,true,200, true);
walk_demo = new Animation(walk_demo_sheet,0,0,5,2,true,200,true);
virus_demo = new Animation(virus_demo_sheet,2,1,3,4,true,200,true);
rider_demo = new Animation(rider_demo_sheet,0,0,2,0,true,200,true);
shock_demo = new Animation(shock_demo_sheet,0,0,3,0,true,200,true);
selectedString = 0;//Default Auswahl im Menu
currentLevel = 1;//Initial Level zu Begin
cyberg = new Image("Main/cybergrid.png");
title = new Image("Main/titel.png");
paused = new Image("Main/paused_menu.png");
shock = new SpriteSheet("Main/shock.png", 75, 45);
selected = new Animation(shock,0,0,3,0,true,250,true);
protector.init(gc,gameState,100);//Roboter Initialisierung an YPosition 100
invader.init(gc,gameState);
}
public void render (GameContainer gc, Graphics g)throws SlickException{
//Rendering abhängig von State
switch(state.currentState){
case "win" ://Sieges Screen
g.drawImage(clearedLevel, 0, 0);
g.setColor(Color.cyan);
g.drawLine(0, 100, 800, 100);
break;
//game over Pseudo-Animation
case "gameOver":
if(waiter > 5)
g.drawImage(game_over_screen8, 0, 0);
else if ( waiter > 4.2)
g.drawImage(game_over_screen7, 0, 0);
else if(waiter > 3.8)
g.drawImage(game_over_screen6, 0, 0);
else if(waiter > 3.2)
g.drawImage(game_over_screen5, 0, 0);
else if(waiter > 2.8)
g.drawImage(game_over_screen4, 0, 0);
else if(waiter > 2.2)
g.drawImage(game_over_screen3, 0, 0);
else if(waiter > 1.8)
g.drawImage(game_over_screen2, 0, 0);
else if(waiter > 1.2)
g.drawImage(game_over_screen1, 0, 0);
else
g.drawImage(game_over_screen0, 0, 0);
break;
//Steuerungs Screens
case "controlInstructions":
if(waiter < 5){
g.drawImage(instructionScreen, 0, 0);
arrows.draw(150, 200);
walk_demo.draw(550, 200);
}
else if(waiter >6){//"Missions screen"
g.drawImage(missionScreen, 0, 0);
walk_demo.draw(550, 200);
virus_demo.draw(550, 300);
rider_demo.draw(550, 430);
shock_demo.draw(550, 460);
}
break;
case "level_intro":
//Level intro je nach currentLevel
switch(currentLevel){
case 1:alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("1", 300, 330);
g.drawString("-First Contact-", 330, 330);
break;
case 2:alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("2", 300, 330);
g.drawString("-Two Paths to the Core-", 330, 330);
break;
case 3:alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("3", 300, 330);
g.drawString("-The Cyberlabyrinth-", 330, 330);
break;
case 4:alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("4", 300, 330);
g.drawString("-The prelast level-", 330, 330);
break;
case 5:alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("5", 300, 330);
g.drawString("-Final Fight-", 330, 330);
break;
}
break;
case "titel":
g.drawImage(title, 0, 0);break;
case"paused":
cyberg.draw(0, 0, 800, 600);
panel.render(gc,g);
protector.render(gc, g);
invader.render(gc, g);
g.setColor(Color.magenta);
//Pause Menü Tags
paused.draw(225, 250);
g.drawString("Resume Game", 425, 290);
g.drawString("Options(Not Implemented)", 425, 320);
g.drawString("Exit Game", 425, 350);
//Name des Levels in der UI
switch(currentLevel){
case 1:g.drawString(level[0], 30, 555);break;
case 2:g.drawString(level[1], 30, 555);break;
case 3:g.drawString(level[2], 30, 555);break;
case 4:g.drawString(level[3], 30, 555);break;
case 5:g.drawString(level[4], 30, 555);break;
}
switch(selectedString){
case 0: selected.draw(325, 280);break;
case 1: selected.draw(325, 310);break;
case 2: selected.draw(325, 340);break;
}
break;
case"start":
cyberg.draw(0, 0, 800, 600);
panel.render(gc,g);
protector.render(gc, g);
invader.render(gc, g);
g.setColor(Color.red);
g.drawLine(0, gc.getHeight()-50, 800, gc.getHeight()-50);//Systemlebenslinie
g.setColor(Color.magenta);
switch(currentLevel){
case 1:g.drawString(level[0], 30, 555);break;
case 2:g.drawString(level[1], 30, 555);break;
case 3:g.drawString(level[2], 30, 555);break;
case 4:g.drawString(level[3], 30, 555);break;
case 5:g.drawString(level[4], 30, 555);break;
}
break;
}
}
public void update (GameContainer gc,float _delta)throws SlickException{
this.waiter += _delta;//Ingame Zeit
switch(state.currentState){
case "paused":
//Kontrolle im Menü
if(gc.getInput().isKeyPressed(Input.KEY_UP)&& selectedString >0)
selectedString--;
if(gc.getInput().isKeyPressed(Input.KEY_DOWN)&& selectedString <2)
selectedString++;
break;
case "start":
protector.update(gc, _delta);
invader.update(gc, _delta);
if(!invader.isParalized&& invader.para_timer >=5 && currentLevel == 5){
//invader movement in final level//
if(invader.riderX+75 > panel.xPos+panel.xSize*15 && changedDirection == false){
invader.flightSpdX *= -1;
invader.fly_right = false;
changedDirection = true;
}
if(invader.riderX -75 < panel.xPos+panel.xSize*1 && changedDirection == false){
invader.flightSpdX *= -1;
invader.fly_right = true;
changedDirection = true;
}
if(invader.riderX < panel.xPos+panel.xSize*9 &&
invader.riderX > panel.xPos+panel.xSize*6 && changedDirection == true)
changedDirection = false;
//Ball Bewegung im letzten level
if(invader.ball.xPos-36 > panel.xPos+panel.xSize*15)
invader.ball.collisionManager("x_inverted");
if(invader.ball.xPos+36 < panel.xPos+panel.xSize*1)
invader.ball.collisionManager("x_inverted");
}
//Level ende und wechsel zum nächsten Level
if(panel.xPos <= -4350 && protector.isLanded){
currentLevel++;
waiter = 0;
state.stateId = 5;
panel.init(gc, state, currentLevel);
protector.init(gc, state, -100);
invader.init(gc, state);
ui.sbar_width = 0;
invader.isParalized = false;
panel.xPos = 350;
}
//Roboter - Panel kollision
for(int i = 1; i< panel.collisionarea.length;i++){
if(panel.collisionarea[i].intersects(protector.getCollisionarea())&&!protector.hasFloorContact){
protector.ySpd = 0;
protector.setFloorContact(true);
protector.isLanded = true;
} else
protector.hasFloorContact = false;
//einsetzen der "Gravitation"
if(panel.collisionarea[i].intersects(protector.getCollisionarea())&& !protector.hasFloorContact){
protector.ySpd *=0;
}
}
//Roboter Sprung
if(gc.getInput().isKeyDown(Input.KEY_UP)&& protector.isLanded)
{
if(protector.isRunningRight){
protector.move = 3;
}
else
if(protector.isRunningLeft){
protector.move = 4;
}
else
protector.move = 0;
protector.hasFloorContact = false;
protector.ySpd = -400;
protector.isLanded = false;
}
//Ball fliegt oben aus dem Screen
if(invader.ball.yPos < 0&& !invader.ball.ballIsKilled){
invader.ball.killBall(gc);
protector.ballhit =false;
}
//Kollision Ball - Hacker
if(invader.ball.yPos < invader.riderY + 75 &&
invader.ball.yPos > invader.riderY &&
invader.ball.xPos < invader.riderX + 75 &&
invader.ball.xPos > invader.riderX ){
invader.ball.killBall(gc);
ui.sbar_width += 20;
protector.ballhit=false;
}
//Disconnected Erzeugung
if(ui.sbar_width >= 100 && !invader.isParalized){
invader.isParalized = true;
invader.paralized();
}
//ReConect des Hackers
if(invader.para_timer >= 5 && ui.sbar_width >= 100){
ui.sbar_width -=100;
invader.isParalized = false;
}
// Ball Kollidiert mit Systemlebenslinie
if( (invader.ball.yPos >= gc.getHeight()-50)){
invader.ball.killBall(gc);
protector.ballhit=false;
if(ui.dbar_width >0)
ui.dbar_width -= 20;
}
//Ball - Roboter Kollision
if(invader.ball.yPos >= protector.yPos -50 &&
invader.ball.xPos >= protector.xPos -25&&
invader.ball.xPos <= protector.xPos + 25&&
invader.ball.yPos <= protector.yPos +50&&
!protector.ballhit){
invader.ball.collisionManager("y_inverted");
protector.ballhit= true;
}
//roboter rechtsbewegung
if(gc.getInput().isKeyDown(Input.KEY_RIGHT)){
if(protector.isLanded)protector.move = 1;
else
protector.move = 3;
panel.xSpd=-200;
invader.ball.xPos-=3;
if(!invader.isParalized)
invader.riderX -=3;
}
else
//roboter Linksbewegung
if(gc.getInput().isKeyDown(Input.KEY_LEFT)){
if(protector.isLanded)protector.move = 2;
else
protector.move = 4;
panel.xSpd=200;
invader.ball.xPos+=3;
if(!invader.isParalized)
invader.riderX +=3;
}
else
{//roboter stand bewegung
protector.move = 0;
panel.xSpd=0;
}
//roboter fliegt unten durch den Screen
if(protector.yPos > 800){
protector.init(gc, state,-100 );
panel.xPos = 350;
invader.init(gc, state);
invader.ball.killBall(gc);
ui.sbar_width = 0;
ui.dbar_width -=20 ;
invader.isParalized = false;
}
break;
}
}
}

@ -0,0 +1,70 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
public class Menu {
Image menu;
State state;
String selectedOption;
int selectedString;
SpriteSheet shocking;
Animation selected;
public void init(GameContainer gc, State state) throws SlickException{
this.state= state;
selectedString = 0;
menu = new Image ("Main/menu.png");
shocking = new SpriteSheet("Main/shock.png", 75, 45);
selected = new Animation(shocking,0,0,3,0,true,250,true);//Auswahl im Menu
}
public void render(GameContainer gc, Graphics g)throws SlickException{
g.setColor(Color.magenta);
if(state.currentState == "menu"){
menu.draw(0, 0);
g.scale(2, 2);
switch(selectedString){
case 0: selected.draw(100, 70);break;
case 1: selected.draw(100, 130);break;
case 2: selected.draw(100, 190);break;
}//Menu auswahl punkte
g.drawString("Start Game", 150, 80);
g.drawString("Options Game", 150, 140);
g.drawString("Exit Game", 150, 200);
g.scale(0.5f, 0.5f);
}
}
public void update(GameContainer gc, float _delta)throws SlickException{
switch(state.stateId){
case 0: case 1:break;
case 4: switch(selectedString){
case 0: selectedOption = "Start Game";selectedString = 0;break;
case 1: selectedOption = "Options";selectedString = 1;break;
case 2: selectedOption = "Exit Game";selectedString = 2;break;
}
if(gc.getInput().isKeyPressed(Input.KEY_UP)&& selectedString >0)
selectedString--;
if(gc.getInput().isKeyPressed(Input.KEY_DOWN)&& selectedString <2)
selectedString++;
break;
}
}
}

@ -0,0 +1,238 @@
package Main;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;
public class Panel {
Image panel;
int i ;
int xPos,xSize,yPos,xSpd;
//Level Modelierungen
int[] yPos_level1= {0,12,12,11,11,10,10, 9, 9,-1,-1,
-1,-1, 9, 9, 9,10,10,11,11,12,
12,-1,-1,11,11,-1,-1,10,10,-1,
-1, 9, 9,-1,-1,-1, 9, 9,-1,-1,
-1,-1, 9, 9, 9,-1,-1,-1,-1,-1,
11,11,-1,-1,10,10,12,12, 7, 7,
7,-1,-1,-1,-1,-1, 8, 8, 7, 7,
-1,-1,-1,-1,-1,-1,11,11,-1,-1,
-1,-1,-1,12,12,10,10,-1,-1,-1,
-1,-1,11,11,12,12,12,12,12};
int[] yPos_level2= {0, 9, 9, 9,-1,-1, 8,10, 5,12, 5,
12, 9, 9, 9,-1, 5,12,-1,-1, 5,
-1,12,-1,-1,-1,-1,11,11,11,-1,
-1,-1,-1,10,10,10,-1,-1,-1,-1,
9, 9, 9,-1,12,12,12,-1, 8, 8,
8,-1,12,12,-1, 7, 7, 7,12,12,
12,12, 6, 6, 6,-1,12,12,-1, 5,
5, 5,-1,-1,-1,-1,-1,-1,-1,12,
12,12,12,12,12,-1,-1,-1,10,10,
10,-1,-1,-1, 9, 9,10,10,10};
int[] yPos_level3= {0, 7, 7, 7,11,11,11,-1,-1, 8, 8,
8,-1,-1,-1, 5, 5, 5,-1,-1, 8,
-1,-1,-1,-1,12,-1, 6,-1,-1, 9,
-1, 5, 5, 6, 6, 8, 8, 8, 9, 9,
-1,-1,-1, 6,12,-1, 9,-1,-1, 5,
5, 5, 9, 7, 6,12,-1,-1,-1,11,
6,12,12, 9, 5, 5,-1,-1,-1,-1,
-1,-1,-1, 9, 9, 9, 9,-1,-1,-1,
-1,12,12,-1, 6,12, 5,10,-1,-1,
-1, 5, 7, 7, 8, 8, 8, 8, 8};
int[] yPos_level4= {0,12,12,11,11,10,10,11,11,12,12,
11,12,12,11,11,12,12,10,10,19,
19,19,10,11,11,12,12,12,12,12,
12,11,11,11,10,10,10, 8,11, 8,
11,10,10,10, 9, 9, 8, 4,11, 4,
11, 4,11, 8, 8, 8, 4,11, 4,11,
4,12, 8, 8, 9, 9, 9,10,10,10,
11,11,11,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12};
int[] yPos_finalLevel= {0,12, 5,-1, 9,-1,-1,12, 5,-1,-1, 9,-1, 5,12};
State state;
Rectangle[] collisionarea;// Kollisionsvierecke für die Roboter-Panel Kollisionen
int currentLevel;
public void init(GameContainer gc, State state,int currentLevel) throws SlickException {
// TODO Auto-generated method stub
this.state = state;
this.currentLevel = currentLevel;
panel = new Image ("Main/panel.png");
//initialwerte
xSize = 50;//breite eines Panels
yPos = 40;// höhe eines Panels
xPos = 350;//Initial Position des ersten Panels
xSpd = 0;
//initiierung der einzelnen Kollisionsvierecke der jeweiligen Levels
switch(currentLevel){
case 1:
collisionarea = new Rectangle[yPos_level1.length];
for(int i = 1; i<yPos_level1.length;i++){
collisionarea = new Rectangle[yPos_level1.length];
//Errechnung nach Shema: xPosGesamt(leicht von rand weg,yPosGesamt aus Arrays+untere hälfte für Draufsteh effekt, breite des Rechtecks, höhe des Rechtecks
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level1[i]+20, 40, 20);
}break;
case 2:
collisionarea = new Rectangle[yPos_level2.length];
for(int i = 1; i<yPos_level2.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level2[i]+20, 40, 20);
}break;
case 3:
collisionarea = new Rectangle[yPos_level3.length];
for(int i = 1; i<yPos_level3.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level3[i]+20, 40, 20);
}break;
case 4:
collisionarea = new Rectangle[yPos_level4.length];
for(int i = 1; i<yPos_level4.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level4[i]+20, 40, 20);
}break;
case 5:
collisionarea = new Rectangle[yPos_finalLevel.length];
for(int i = 1; i<yPos_finalLevel.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_finalLevel[i]+20, 40, 20);
}break;
}
}
public void update(GameContainer gc, float _delta)throws SlickException {
// TODO Auto-generated method stub
xPos += xSpd* _delta;
//erstellung aller Panels durch Errechnung der Position
switch(currentLevel){
case 1:
for(int i = 1; i<yPos_level1.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level1[i]+20, 40, 10);
}
break;
case 2:
for(int i = 1; i<yPos_level2.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level2[i]+20, 40, 10);
}
break;
case 3:
for(int i = 1; i<yPos_level3.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level3[i]+20, 40, 10);
}
break;
case 4:
for(int i = 1; i<yPos_level4.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level4[i]+20, 40, 10);
}
break;
case 5:
for(int i = 1; i<yPos_finalLevel.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_finalLevel[i]+20, 40, 10);
}
break;
}
}
public void render(GameContainer gc, Graphics g)throws SlickException {
// TODO Auto-generated method stub
switch(state.currentState){
case "start":
switch(currentLevel){
case 1:
for( i = 1; i<yPos_level1.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level1[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 2:
for( i = 1; i<yPos_level2.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level2[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 3:
for( i = 1; i<yPos_level3.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level3[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 4:
for( i = 1; i<yPos_level4.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level4[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 5:
for( i = 1; i<yPos_finalLevel.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_finalLevel[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
}
case "paused":
switch(currentLevel){
case 1:
for( i = 1; i<yPos_level1.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level1[i]);
}
break;
case 2:
for( i = 1; i<yPos_level2.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level2[i]);
}
break;
case 3:
for( i = 1; i<yPos_level3.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level3[i]);
}
break;
case 4:
for( i = 1; i<yPos_level4.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level4[i]);
}
break;
case 5:
for( i = 1; i<yPos_finalLevel.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_finalLevel[i]);
}
break;
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

@ -0,0 +1,95 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.geom.Rectangle;
public class Player {
SpriteSheet robot;
Animation walk_right,walk_left,jump_left,jump_right,stand;
int xPos,yPos;
float xSpd,ySpd;
private State state;
boolean isRunningRight, isRunningLeft,isStandingRight, hasFloorContact, isLanded, ballhit;//checks
char move;//Bewegungsanimationswähler
Rectangle collisionarea;//Kollisionsviereck an den Füßen des Roboters
void init(GameContainer gc, State gameState , int yPos) throws SlickException{
this.yPos = yPos;
this.state = gameState;
robot = new SpriteSheet("Main/robot_sheet_good.png",50,100);
walk_right = new Animation(robot,0,0,6,0,true,200,true);
walk_left = new Animation(robot,0,1,6,1,true,200,true);
jump_right = new Animation(robot,0,2,5,2,true,200,true);
jump_right.setLooping(false);
jump_left = new Animation(robot,0,3,5,3,true,200,true);
jump_left.setLooping(false);
stand = new Animation(robot,0,4,2,4,true,200,true);
xPos = 400;
ySpd = 0;
xSpd = 0;
collisionarea = new Rectangle(xPos-15, yPos+20, 35, 20);
ballhit = false;
}
void render(GameContainer gc, Graphics g)throws SlickException{
switch(state.currentState){
case "titel": break;
case "start": case "paused":
//Auswahl der zu rendernden Animation
switch(move){
case 0: stand.draw(xPos-24,yPos-50);break;
case 1:/*Run right*/walk_right.draw(xPos-25, yPos-50); break;
case 2:/*Run left*/walk_left.draw(xPos-25, yPos-50); break;
case 3:/*jump right*/jump_right.draw(xPos-25, yPos-50);break;
case 4:/*jump left*/jump_left.draw(xPos-25, yPos-50);break;
}
break;
}
}
void update(GameContainer gc, float _delta)throws SlickException{
//update der Position des Quadrates
collisionarea = new Rectangle(xPos-15, yPos+20, 35, 20);
switch(state.currentState){
case "paused":break;
case "start":
this.xPos += this.xSpd * _delta;
this.yPos += this.ySpd * _delta;
if(!hasFloorContact)//Gravitation
this.ySpd += 750.0f * _delta;
break;
}
}
void setFloorContact(boolean status){
this.hasFloorContact=status;
}
Rectangle getCollisionarea(){
return collisionarea;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

@ -0,0 +1,34 @@
package Main;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
public class State {
int stateId;
String currentState;
public void init(GameContainer gc) {
// TODO Auto-generated method stub
stateId = 0;
currentState ="titel";
}
public void update(GameContainer gc, float _delta) {
// TODO Auto-generated method stub
switch(stateId){//definierung der States
case 0 : currentState = "titel";break;
case 1 : currentState = "start";break;
case 2 : currentState = "paused";break;
case 4 : currentState = "menu";break;
case 5 : currentState = "level_intro";break;
case 6 : currentState = "controlInstructions";break;
case 7 : currentState = "gameOver";break;
case 8 : currentState = "win";break;
}
}
public void render(GameContainer gc, Graphics g) {
// TODO Auto-generated method stub
}
}

@ -0,0 +1,64 @@
package Main;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
public class UserInterface {
Image destructionBar;
Image emptyBar;
Image shieldBar;
int dbar_width, sbar_width;
private State state;
public void init(GameContainer gc, State gameState) throws SlickException {
// TODO Auto-generated method stub
this.state = gameState;
destructionBar = new Image("Main/destruction_bar.png");
shieldBar = new Image("Main/shield_bar.png");
emptyBar = new Image("Main/empty_bar.png");
dbar_width = 100;
sbar_width = 0;
}
public void render(GameContainer gc, Graphics g){
switch(state.currentState){
case "titel":break;
case "start": case "paused":
g.scale(2, 2);
emptyBar.draw(290, 25, 100, 12);
emptyBar.draw(290, 286, 100, 12);
shieldBar.draw(290, 25, sbar_width, 12);
destructionBar.draw(290, 286, dbar_width, 12);
g.scale(0.5f, 0.5f);
g.setColor(Color.blue);
g.drawString("Eject Progress", 625, 27);
g.setColor(Color.magenta);
g.drawString("System Stability", 600 ,555 );
/*
* Item Slots
g.setColor(Color.darkGray);
g.fillRect(480, 570, 30, 30, 15);
g.fillRect(520, 570, 30, 30, 15);
*/
break;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 KiB

@ -0,0 +1,95 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.geom.Rectangle;
public class Player {
SpriteSheet robot;
Animation walk_right,walk_left,jump_left,jump_right,stand;
int xPos,yPos;
float xSpd,ySpd;
private State state;
boolean isRunningRight, isRunningLeft,isStandingRight, hasFloorContact, isLanded, ballhit;//checks
char move;//Bewegungsanimationswähler
Rectangle collisionarea;//Kollisionsviereck an den Füßen des Roboters
void init(GameContainer gc, State gameState , int yPos) throws SlickException{
this.yPos = yPos;
this.state = gameState;
robot = new SpriteSheet("Main/robot_sheet_good.png",50,100);
walk_right = new Animation(robot,0,0,6,0,true,200,true);
walk_left = new Animation(robot,0,1,6,1,true,200,true);
jump_right = new Animation(robot,0,2,5,2,true,200,true);
jump_right.setLooping(false);
jump_left = new Animation(robot,0,3,5,3,true,200,true);
jump_left.setLooping(false);
stand = new Animation(robot,0,4,2,4,true,200,true);
xPos = 400;
ySpd = 0;
xSpd = 0;
collisionarea = new Rectangle(xPos-15, yPos+20, 35, 20);
ballhit = false;
}
void render(GameContainer gc, Graphics g)throws SlickException{
switch(state.currentState){
case "titel": break;
case "start": case "paused":
//Auswahl der zu rendernden Animation
switch(move){
case 0: stand.draw(xPos-24,yPos-50);break;
case 1:/*Run right*/walk_right.draw(xPos-25, yPos-50); break;
case 2:/*Run left*/walk_left.draw(xPos-25, yPos-50); break;
case 3:/*jump right*/jump_right.draw(xPos-25, yPos-50);break;
case 4:/*jump left*/jump_left.draw(xPos-25, yPos-50);break;
}
break;
}
}
void update(GameContainer gc, float _delta)throws SlickException{
//update der Position des Quadrates
collisionarea = new Rectangle(xPos-15, yPos+20, 35, 20);
switch(state.currentState){
case "paused":break;
case "start":
this.xPos += this.xSpd * _delta;
this.yPos += this.ySpd * _delta;
if(!hasFloorContact)//Gravitation
this.ySpd += 750.0f * _delta;
break;
}
}
void setFloorContact(boolean status){
this.hasFloorContact=status;
}
Rectangle getCollisionarea(){
return collisionarea;
}
}

Binary file not shown.

@ -0,0 +1,72 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
public class Ball {
SpriteSheet virus_sheet;
Animation virus;
int xPos,yPos;
float xSpd,ySpd;
boolean isColliding = false,ballIsKilled = true;
//initial methode mit Koordinatenbestimmung und startrichtung
void init (GameContainer gc,int xPos, int yPos, int invaderSpd) throws SlickException{
this.xPos = xPos;
this.yPos = yPos;
this.xSpd = 1.0f * invaderSpd;//initiierung mit Hacker flugrichtungsindikation
this.ySpd = 1.0f;
virus_sheet = new SpriteSheet ("Main/Virus_sheet.png", 72, 72);
virus = new Animation(virus_sheet,2,1,3,4,true,200,true);
}
void render(GameContainer gc, Graphics g) throws SlickException{
virus.draw(xPos-36, yPos-36);
}
void update(GameContainer gc, float _delta)throws SlickException{
this.xPos += xSpd;
this.yPos += ySpd;
}
public void collisionManager(String direction){//Verwaltet Apprallrichtung und intensität
switch(direction){
case "x_inverted" :this.xSpd *= -1; break;
case "y_inverted" :this.ySpd *= -1; break;
case "rebounce" :this.xSpd *= -1; this.ySpd *= -1;break;
case "left" :this.xSpd *= -1; this.ySpd *= -1;break;
case "midleft" :this.xSpd *= 2; this.ySpd *= -1;break;
case "middle" :this.ySpd *= -1; break;
case "midright" :this.xSpd *= 2; this.ySpd *= -1;break;
case "right" :this.xSpd *= -1; this.ySpd *= -1;break;
}
}
//ball "zerstörung"
public void killBall(GameContainer gc) throws SlickException{
init(gc, -50,350, 1);
ballIsKilled=true;
}
}

@ -0,0 +1,140 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
public class Invader {
int riderX, riderY,flightSpdX,flightSpdY;
SpriteSheet rider,shocking;
Animation flight_left, flight_right,shock;
String flight_direction;//Flugrichtung
float countDown,para_timer;
boolean readyToFire,//Check für die Abschuss automatik
ball_shoot,//Check ob Ball abgefeuert wurde
fly_right,//Check ob Flugrichtung rechts
isParalized;//Disconnected check
Ball ball;//Definierung eines Ball objektes
private State state;
void init(GameContainer gc, State gameState) throws SlickException{
this.state = gameState;
riderX = 450;
riderY = 30;
flightSpdX = 1;
flightSpdY = 1;
flight_direction = "right";
fly_right = true;
ball_shoot= false;
isParalized = false;
rider = new SpriteSheet("Main/rider.png", 75, 75);
shocking = new SpriteSheet("Main/shock.png", 75, 45);
flight_left = new Animation(rider,0,1,2,1,true,250,true);
flight_right = new Animation(rider,0,0,2,0,true,250,true);
shock = new Animation(shocking,0,0,3,0,true,250,true);
countDown = 3.1f;
para_timer = 5.1f;
readyToFire = false;
ball = new Ball();//erstellung des Ballobjektes
}
void render(GameContainer gc, Graphics g) throws SlickException{
switch(state.currentState){
case "titel":break;
case "start": case "paused":
if(fly_right)//rechtsflug animation
flight_right.draw(riderX, riderY);
else//linksflug animation
flight_left.draw(riderX, riderY);
//ball wird nur gerendert falls er abgeschossen wurde
if(ball_shoot){
ball.render(gc, g);
}
//shock animation des Disconnected Status
if(para_timer < 5){
shock.draw(riderX, riderY+20);
}
break;
}
}
void update(GameContainer gc, float _delta) throws SlickException{
switch(state.currentState){
case "paused":break;
case "start" :
countDown += _delta;
para_timer += _delta;
//flug nur bei Connected Status
if(!isParalized&& para_timer >=5 ){
riderX += flightSpdX;
//Abschuss automatik
if(readyToFire == true && countDown > 3 ){
ball.init(gc, riderX+37, riderY+80, flightSpdX);
ball_shoot = true;
readyToFire= false;
}
}
//ball bewegung
if(ball_shoot&&!ball.ballIsKilled)
ball.update(gc, _delta );
//ball wird bei zerstörung für den schuss vorbereitet
if(ball.ballIsKilled){
prepareToFire();
ball.ballIsKilled =false;
}
gc.getInput().clearKeyPressedRecord();//Tastendruck löschung zur Sicherheit
break;
}
}
//Abschussmethode
void prepareToFire(){
countDown = 0;
readyToFire = true;
ball_shoot = false;
}
//Disconnected Methode
void paralized(){
para_timer = 0;
}
}

@ -0,0 +1,175 @@
package Main;
//Importe
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;//für Tastennutzung
import org.newdawn.slick.SlickException;
public class JnP extends BasicGame {
//Main Klasse des Games
public JnP() {
super("Jump 'n' Pong");
}
//Objekterstellungen
Panel panel;
Level level;
UserInterface hud;
Invader invader;
Player protector;
State gameState;
Menu menu;
float waiter;//Zeit-Laufvariable
public void init(GameContainer gc) throws SlickException {
// TODO Auto-generated method stub
//Objekterstellung (außer Ball -> Erstellung in der Invader-Klasse
hud = new UserInterface();
invader = new Invader();
protector = new Player();
level = new Level();
gameState = new State();
menu = new Menu();
panel = new Panel();
//Initialisierung
gameState.init(gc);
menu.init(gc, gameState);
level.init(gc,invader,protector,hud,gameState,panel,waiter);//Initialisierung mit Vererbung aller Objekte
panel.init(gc,gameState,1);// Initialisierung + Angabe des Startlevels
hud.init(gc,gameState);
waiter = 0; //Setzung der Zeit zu Begin
}
@Override
public void update(GameContainer gc, int delta) throws SlickException {
// TODO Auto-generated method stub
float _delta = delta /1000f;
this.waiter += _delta; //Zeit läuft
//Menu exit
if(gc.getInput().isKeyDown(Input.KEY_ENTER) && (level.selectedString == 2||menu.selectedString == 2))
gc.exit();
// Press Enter start screen
if(gc.getInput().isKeyDown(Input.KEY_ENTER)&& (level.selectedString == 0)&& level.waiter >3 && gameState.stateId==0){
gameState.stateId = 4;level.waiter = 0;
}
//Menu startgame Option
if(gc.getInput().isKeyDown(Input.KEY_ENTER)&&level.waiter >0.3 && (menu.selectedString == 0) && gameState.stateId==4){
gameState.stateId = 6;level.waiter = 0;
}
//Pause Menu resume game Option
if(gc.getInput().isKeyDown(Input.KEY_ENTER)&&level.waiter >3 && (menu.selectedString == 0) && gameState.stateId==2){
gameState.stateId = 1;
}
//Control Instructions Screen Timer
if(gameState.stateId == 6 && level.waiter >10){
gameState.stateId = 5;
level.waiter = 0;
}
//Intro Screen Timer
if(gameState.stateId == 5 && level.waiter > 5){
panel.xPos = 350;
gameState.stateId = 1;
level.waiter = 0;
}
//Win State Bedingung
if(gameState.stateId == 1 && level.currentLevel == 5 && hud.sbar_width >=100){
level.waiter = 0 ;
gameState.stateId = 8;
}
//Win Screen Timer
if(gameState.stateId == 8 && level.waiter > 5){
gameState.stateId = 4;
level.currentLevel = 1;
//Initialisierung eines "Neuen Spiels"
panel.init(gc, gameState, 1);
hud.init(gc, gameState);
invader.init(gc, gameState);
protector.init(gc, gameState, 50);
level.init(gc, invader, protector, hud, gameState, panel, _delta);
menu.init(gc, gameState);
}
//Pause Menu Aktivierung
if(gc.getInput().isKeyPressed(Input.KEY_P )&& (gameState.stateId == 1))
gameState.stateId = 2;
//Game Over Bedingung
if(hud.dbar_width<=0 && gameState.stateId==1){
level.waiter = 0;
gameState.stateId = 7;
}
//Neues Game nach Game Over
if(gameState.stateId == 7 &&level.waiter > 10){
panel.init(gc, gameState, 1);
hud.init(gc, gameState);
invader.init(gc, gameState);
protector.init(gc, gameState, 50);
level.init(gc, invader, protector, hud, gameState, panel, _delta);
menu.init(gc, gameState);
level.currentLevel = 1;
gameState.stateId = 4;
}
//Update Aufrufe
gameState.update(gc, _delta);
level.update(gc, _delta);
menu.update(gc, _delta);
panel.update(gc, _delta);
}
@Override
public void render(GameContainer gc, Graphics g) throws SlickException {
// TODO Auto-generated method stub
//Renderaufrufe
gameState.render(gc, g);
level.render(gc, g);
menu.render(gc, g);
hud.render(gc, g);
//Titel screen Einblendung
if(gameState.stateId == 0 && waiter >3){
g.drawString("Press Enter", 350, 550);
}
}
//Hauptmethode
public static void main(String[] args) {
try {//Apperstellung
AppGameContainer app = new AppGameContainer(new JnP());
app.setDisplayMode(800, 600, true);//Fullscreen 800x600
app.setTargetFrameRate(60);//Flüssige FPS von 60
app.setVSync(true);//VSinc um Renderprobleme bei schneller Objektbewegung zu verhindern
app.setShowFPS(false);
app.start();
}
catch (SlickException e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,455 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
public class Level{
private Image cyberg,title,paused,instructionScreen,missionScreen,alert,clearedLevel;
private Invader invader;
private Player protector;
private UserInterface ui;
private State state;
//Levelbezeichnungen
private String[] level = {"-1- First Contact |", "-2- Two Paths to Core |", "-3- Cyberlabyrinth", "-4-", " -5- Final Fight |"};
//Game Over Screen Erstellung
private Image game_over_screen0,game_over_screen1,game_over_screen2,game_over_screen3,game_over_screen4,game_over_screen5,game_over_screen6,game_over_screen7,game_over_screen8;
Image[] game_over_screens = { game_over_screen0,
game_over_screen1,
game_over_screen2,
game_over_screen3,
game_over_screen4,
game_over_screen5,
game_over_screen6,
game_over_screen7,
game_over_screen8};
int selectedString,currentLevel;
SpriteSheet shock,arrows_sheet,walk_demo_sheet,virus_demo_sheet,rider_demo_sheet,shock_demo_sheet;
Animation selected,arrows,walk_demo,game_over,virus_demo,rider_demo,shock_demo;
Panel panel;
float waiter;//Ingame Zeit
boolean changedDirection = false;//Indikator für Richtungswechsel
public void init(GameContainer gc, Invader invader, Player player, UserInterface ui, State gameState, Panel panel, float waiter) throws SlickException{
game_over_screen0 = new Image("Main/cybergrid.png");
game_over_screen1 = new Image("Main/game_Over1.png");
game_over_screen2 = new Image("Main/game_Over2.png");
game_over_screen3 = new Image("Main/game_Over3.png");
game_over_screen4 = new Image("Main/game_Over4.png");
game_over_screen5 = new Image("Main/game_Over5.png");
game_over_screen6 = new Image("Main/game_Over6.png");
game_over_screen7 = new Image("Main/game_Over7.png");
game_over_screen8 = new Image("Main/game_Over8.png");
this.waiter = waiter;
this.panel = panel;
this.state = gameState;
this.invader = invader;
this.protector = player;
this.ui = ui;
alert = new Image("Main/Hack_Alert.png");
clearedLevel = new Image("Main/level_cleared_screen.png");
instructionScreen = new Image("Main/key_instructions.png");
missionScreen = new Image("Main/mission.png");
arrows_sheet = new SpriteSheet("Main/arrows_sheet.png" ,101, 101);
walk_demo_sheet = new SpriteSheet("Main/robot_sheet_good.png",50,100);
virus_demo_sheet = new SpriteSheet("Main/Virus_sheet.png",72,72);
rider_demo_sheet = new SpriteSheet("Main/rider.png",75,75);
shock_demo_sheet = new SpriteSheet("Main/shock.png",75,45);
arrows = new Animation(arrows_sheet,0,0,3,2,true,200, true);
walk_demo = new Animation(walk_demo_sheet,0,0,5,2,true,200,true);
virus_demo = new Animation(virus_demo_sheet,2,1,3,4,true,200,true);
rider_demo = new Animation(rider_demo_sheet,0,0,2,0,true,200,true);
shock_demo = new Animation(shock_demo_sheet,0,0,3,0,true,200,true);
selectedString = 0;//Default Auswahl im Menu
currentLevel = 1;//Initial Level zu Begin
cyberg = new Image("Main/cybergrid.png");
title = new Image("Main/titel.png");
paused = new Image("Main/paused_menu.png");
shock = new SpriteSheet("Main/shock.png", 75, 45);
selected = new Animation(shock,0,0,3,0,true,250,true);
protector.init(gc,gameState,100);//Roboter Initialisierung an YPosition 100
invader.init(gc,gameState);
}
public void render (GameContainer gc, Graphics g)throws SlickException{
//Rendering abhängig von State
switch(state.currentState){
case "win" ://Sieges Screen
g.drawImage(clearedLevel, 0, 0);
g.setColor(Color.cyan);
g.drawLine(0, 100, 800, 100);
break;
//game over Pseudo-Animation
case "gameOver":
if(waiter > 5)
g.drawImage(game_over_screen8, 0, 0);
else if ( waiter > 4.2)
g.drawImage(game_over_screen7, 0, 0);
else if(waiter > 3.8)
g.drawImage(game_over_screen6, 0, 0);
else if(waiter > 3.2)
g.drawImage(game_over_screen5, 0, 0);
else if(waiter > 2.8)
g.drawImage(game_over_screen4, 0, 0);
else if(waiter > 2.2)
g.drawImage(game_over_screen3, 0, 0);
else if(waiter > 1.8)
g.drawImage(game_over_screen2, 0, 0);
else if(waiter > 1.2)
g.drawImage(game_over_screen1, 0, 0);
else
g.drawImage(game_over_screen0, 0, 0);
break;
//Steuerungs Screens
case "controlInstructions":
if(waiter < 5){
g.drawImage(instructionScreen, 0, 0);
arrows.draw(150, 200);
walk_demo.draw(550, 200);
}
else if(waiter >6){//"Missions screen"
g.drawImage(missionScreen, 0, 0);
walk_demo.draw(550, 200);
virus_demo.draw(550, 300);
rider_demo.draw(550, 430);
shock_demo.draw(550, 460);
}
break;
case "level_intro":
//Level intro je nach currentLevel
switch(currentLevel){
case 1:alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("1", 300, 330);
g.drawString("-First Contact-", 330, 330);
break;
case 2:alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("2", 300, 330);
g.drawString("-Two Paths to the Core-", 330, 330);
break;
case 3:alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("3", 300, 330);
g.drawString("-The Cyberlabyrinth-", 330, 330);
break;
case 4:alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("4", 300, 330);
g.drawString("-The prelast level-", 330, 330);
break;
case 5:alert.draw(0, 0);
g.setColor(Color.red);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.setColor(Color.white);
g.drawString("5", 300, 330);
g.drawString("-Final Fight-", 330, 330);
break;
}
break;
case "titel":
g.drawImage(title, 0, 0);break;
case"paused":
cyberg.draw(0, 0, 800, 600);
panel.render(gc,g);
protector.render(gc, g);
invader.render(gc, g);
g.setColor(Color.magenta);
//Pause Menü Tags
paused.draw(225, 250);
g.drawString("Resume Game", 425, 290);
g.drawString("Options(Not Implemented)", 425, 320);
g.drawString("Exit Game", 425, 350);
//Name des Levels in der UI
switch(currentLevel){
case 1:g.drawString(level[0], 30, 555);break;
case 2:g.drawString(level[1], 30, 555);break;
case 3:g.drawString(level[2], 30, 555);break;
case 4:g.drawString(level[3], 30, 555);break;
case 5:g.drawString(level[4], 30, 555);break;
}
switch(selectedString){
case 0: selected.draw(325, 280);break;
case 1: selected.draw(325, 310);break;
case 2: selected.draw(325, 340);break;
}
break;
case"start":
cyberg.draw(0, 0, 800, 600);
panel.render(gc,g);
protector.render(gc, g);
invader.render(gc, g);
g.setColor(Color.red);
g.drawLine(0, gc.getHeight()-50, 800, gc.getHeight()-50);//Systemlebenslinie
g.setColor(Color.magenta);
switch(currentLevel){
case 1:g.drawString(level[0], 30, 555);break;
case 2:g.drawString(level[1], 30, 555);break;
case 3:g.drawString(level[2], 30, 555);break;
case 4:g.drawString(level[3], 30, 555);break;
case 5:g.drawString(level[4], 30, 555);break;
}
break;
}
}
public void update (GameContainer gc,float _delta)throws SlickException{
this.waiter += _delta;//Ingame Zeit
switch(state.currentState){
case "paused":
//Kontrolle im Menü
if(gc.getInput().isKeyPressed(Input.KEY_UP)&& selectedString >0)
selectedString--;
if(gc.getInput().isKeyPressed(Input.KEY_DOWN)&& selectedString <2)
selectedString++;
break;
case "start":
protector.update(gc, _delta);
invader.update(gc, _delta);
if(!invader.isParalized&& invader.para_timer >=5 && currentLevel == 5){
//invader movement in final level//
if(invader.riderX+75 > panel.xPos+panel.xSize*15 && changedDirection == false){
invader.flightSpdX *= -1;
invader.fly_right = false;
changedDirection = true;
}
if(invader.riderX -75 < panel.xPos+panel.xSize*1 && changedDirection == false){
invader.flightSpdX *= -1;
invader.fly_right = true;
changedDirection = true;
}
if(invader.riderX < panel.xPos+panel.xSize*9 &&
invader.riderX > panel.xPos+panel.xSize*6 && changedDirection == true)
changedDirection = false;
//Ball Bewegung im letzten level
if(invader.ball.xPos-36 > panel.xPos+panel.xSize*15)
invader.ball.collisionManager("x_inverted");
if(invader.ball.xPos+36 < panel.xPos+panel.xSize*1)
invader.ball.collisionManager("x_inverted");
}
//Level ende und wechsel zum nächsten Level
if(panel.xPos <= -4350 && protector.isLanded){
currentLevel++;
waiter = 0;
state.stateId = 5;
panel.init(gc, state, currentLevel);
protector.init(gc, state, -100);
invader.init(gc, state);
ui.sbar_width = 0;
invader.isParalized = false;
panel.xPos = 350;
}
//Roboter - Panel kollision
for(int i = 1; i< panel.collisionarea.length;i++){
if(panel.collisionarea[i].intersects(protector.getCollisionarea())&&!protector.hasFloorContact){
protector.ySpd = 0;
protector.setFloorContact(true);
protector.isLanded = true;
} else
protector.hasFloorContact = false;
//einsetzen der "Gravitation"
if(panel.collisionarea[i].intersects(protector.getCollisionarea())&& !protector.hasFloorContact){
protector.ySpd *=0;
}
}
//Roboter Sprung
if(gc.getInput().isKeyDown(Input.KEY_UP)&& protector.isLanded)
{
if(protector.isRunningRight){
protector.move = 3;
}
else
if(protector.isRunningLeft){
protector.move = 4;
}
else
protector.move = 0;
protector.hasFloorContact = false;
protector.ySpd = -400;
protector.isLanded = false;
}
//Ball fliegt oben aus dem Screen
if(invader.ball.yPos < 0&& !invader.ball.ballIsKilled){
invader.ball.killBall(gc);
protector.ballhit =false;
}
//Kollision Ball - Hacker
if(invader.ball.yPos < invader.riderY + 75 &&
invader.ball.yPos > invader.riderY &&
invader.ball.xPos < invader.riderX + 75 &&
invader.ball.xPos > invader.riderX ){
invader.ball.killBall(gc);
ui.sbar_width += 20;
protector.ballhit=false;
}
//Disconnected Erzeugung
if(ui.sbar_width >= 100 && !invader.isParalized){
invader.isParalized = true;
invader.paralized();
}
//ReConect des Hackers
if(invader.para_timer >= 5 && ui.sbar_width >= 100){
ui.sbar_width -=100;
invader.isParalized = false;
}
// Ball Kollidiert mit Systemlebenslinie
if( (invader.ball.yPos >= gc.getHeight()-50)){
invader.ball.killBall(gc);
protector.ballhit=false;
if(ui.dbar_width >0)
ui.dbar_width -= 20;
}
//Ball - Roboter Kollision
if(invader.ball.yPos >= protector.yPos -50 &&
invader.ball.xPos >= protector.xPos -25&&
invader.ball.xPos <= protector.xPos + 25&&
invader.ball.yPos <= protector.yPos +50&&
!protector.ballhit){
invader.ball.collisionManager("y_inverted");
protector.ballhit= true;
}
//roboter rechtsbewegung
if(gc.getInput().isKeyDown(Input.KEY_RIGHT)){
if(protector.isLanded)protector.move = 1;
else
protector.move = 3;
panel.xSpd=-200;
invader.ball.xPos-=3;
if(!invader.isParalized)
invader.riderX -=3;
}
else
//roboter Linksbewegung
if(gc.getInput().isKeyDown(Input.KEY_LEFT)){
if(protector.isLanded)protector.move = 2;
else
protector.move = 4;
panel.xSpd=200;
invader.ball.xPos+=3;
if(!invader.isParalized)
invader.riderX +=3;
}
else
{//roboter stand bewegung
protector.move = 0;
panel.xSpd=0;
}
//roboter fliegt unten durch den Screen
if(protector.yPos > 800){
protector.init(gc, state,-100 );
panel.xPos = 350;
invader.init(gc, state);
invader.ball.killBall(gc);
ui.sbar_width = 0;
ui.dbar_width -=20 ;
invader.isParalized = false;
}
break;
}
}
}

@ -0,0 +1,70 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
public class Menu {
Image menu;
State state;
String selectedOption;
int selectedString;
SpriteSheet shocking;
Animation selected;
public void init(GameContainer gc, State state) throws SlickException{
this.state= state;
selectedString = 0;
menu = new Image ("Main/menu.png");
shocking = new SpriteSheet("Main/shock.png", 75, 45);
selected = new Animation(shocking,0,0,3,0,true,250,true);//Auswahl im Menu
}
public void render(GameContainer gc, Graphics g)throws SlickException{
g.setColor(Color.magenta);
if(state.currentState == "menu"){
menu.draw(0, 0);
g.scale(2, 2);
switch(selectedString){
case 0: selected.draw(100, 70);break;
case 1: selected.draw(100, 130);break;
case 2: selected.draw(100, 190);break;
}//Menu auswahl punkte
g.drawString("Start Game", 150, 80);
g.drawString("Options Game", 150, 140);
g.drawString("Exit Game", 150, 200);
g.scale(0.5f, 0.5f);
}
}
public void update(GameContainer gc, float _delta)throws SlickException{
switch(state.stateId){
case 0: case 1:break;
case 4: switch(selectedString){
case 0: selectedOption = "Start Game";selectedString = 0;break;
case 1: selectedOption = "Options";selectedString = 1;break;
case 2: selectedOption = "Exit Game";selectedString = 2;break;
}
if(gc.getInput().isKeyPressed(Input.KEY_UP)&& selectedString >0)
selectedString--;
if(gc.getInput().isKeyPressed(Input.KEY_DOWN)&& selectedString <2)
selectedString++;
break;
}
}
}

@ -0,0 +1,238 @@
package Main;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;
public class Panel {
Image panel;
int i ;
int xPos,xSize,yPos,xSpd;
//Level Modelierungen
int[] yPos_level1= {0,12,12,11,11,10,10, 9, 9,-1,-1,
-1,-1, 9, 9, 9,10,10,11,11,12,
12,-1,-1,11,11,-1,-1,10,10,-1,
-1, 9, 9,-1,-1,-1, 9, 9,-1,-1,
-1,-1, 9, 9, 9,-1,-1,-1,-1,-1,
11,11,-1,-1,10,10,12,12, 7, 7,
7,-1,-1,-1,-1,-1, 8, 8, 7, 7,
-1,-1,-1,-1,-1,-1,11,11,-1,-1,
-1,-1,-1,12,12,10,10,-1,-1,-1,
-1,-1,11,11,12,12,12,12,12};
int[] yPos_level2= {0, 9, 9, 9,-1,-1, 8,10, 5,12, 5,
12, 9, 9, 9,-1, 5,12,-1,-1, 5,
-1,12,-1,-1,-1,-1,11,11,11,-1,
-1,-1,-1,10,10,10,-1,-1,-1,-1,
9, 9, 9,-1,12,12,12,-1, 8, 8,
8,-1,12,12,-1, 7, 7, 7,12,12,
12,12, 6, 6, 6,-1,12,12,-1, 5,
5, 5,-1,-1,-1,-1,-1,-1,-1,12,
12,12,12,12,12,-1,-1,-1,10,10,
10,-1,-1,-1, 9, 9,10,10,10};
int[] yPos_level3= {0, 7, 7, 7,11,11,11,-1,-1, 8, 8,
8,-1,-1,-1, 5, 5, 5,-1,-1, 8,
-1,-1,-1,-1,12,-1, 6,-1,-1, 9,
-1, 5, 5, 6, 6, 8, 8, 8, 9, 9,
-1,-1,-1, 6,12,-1, 9,-1,-1, 5,
5, 5, 9, 7, 6,12,-1,-1,-1,11,
6,12,12, 9, 5, 5,-1,-1,-1,-1,
-1,-1,-1, 9, 9, 9, 9,-1,-1,-1,
-1,12,12,-1, 6,12, 5,10,-1,-1,
-1, 5, 7, 7, 8, 8, 8, 8, 8};
int[] yPos_level4= {0,12,12,11,11,10,10,11,11,12,12,
11,12,12,11,11,12,12,10,10,19,
19,19,10,11,11,12,12,12,12,12,
12,11,11,11,10,10,10, 8,11, 8,
11,10,10,10, 9, 9, 8, 4,11, 4,
11, 4,11, 8, 8, 8, 4,11, 4,11,
4,12, 8, 8, 9, 9, 9,10,10,10,
11,11,11,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12};
int[] yPos_finalLevel= {0,12, 5,-1, 9,-1,-1,12, 5,-1,-1, 9,-1, 5,12};
State state;
Rectangle[] collisionarea;// Kollisionsvierecke für die Roboter-Panel Kollisionen
int currentLevel;
public void init(GameContainer gc, State state,int currentLevel) throws SlickException {
// TODO Auto-generated method stub
this.state = state;
this.currentLevel = currentLevel;
panel = new Image ("Main/panel.png");
//initialwerte
xSize = 50;//breite eines Panels
yPos = 40;// höhe eines Panels
xPos = 350;//Initial Position des ersten Panels
xSpd = 0;
//initiierung der einzelnen Kollisionsvierecke der jeweiligen Levels
switch(currentLevel){
case 1:
collisionarea = new Rectangle[yPos_level1.length];
for(int i = 1; i<yPos_level1.length;i++){
collisionarea = new Rectangle[yPos_level1.length];
//Errechnung nach Shema: xPosGesamt(leicht von rand weg,yPosGesamt aus Arrays+untere hälfte für Draufsteh effekt, breite des Rechtecks, höhe des Rechtecks
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level1[i]+20, 40, 20);
}break;
case 2:
collisionarea = new Rectangle[yPos_level2.length];
for(int i = 1; i<yPos_level2.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level2[i]+20, 40, 20);
}break;
case 3:
collisionarea = new Rectangle[yPos_level3.length];
for(int i = 1; i<yPos_level3.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level3[i]+20, 40, 20);
}break;
case 4:
collisionarea = new Rectangle[yPos_level4.length];
for(int i = 1; i<yPos_level4.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level4[i]+20, 40, 20);
}break;
case 5:
collisionarea = new Rectangle[yPos_finalLevel.length];
for(int i = 1; i<yPos_finalLevel.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_finalLevel[i]+20, 40, 20);
}break;
}
}
public void update(GameContainer gc, float _delta)throws SlickException {
// TODO Auto-generated method stub
xPos += xSpd* _delta;
//erstellung aller Panels durch Errechnung der Position
switch(currentLevel){
case 1:
for(int i = 1; i<yPos_level1.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level1[i]+20, 40, 10);
}
break;
case 2:
for(int i = 1; i<yPos_level2.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level2[i]+20, 40, 10);
}
break;
case 3:
for(int i = 1; i<yPos_level3.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level3[i]+20, 40, 10);
}
break;
case 4:
for(int i = 1; i<yPos_level4.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level4[i]+20, 40, 10);
}
break;
case 5:
for(int i = 1; i<yPos_finalLevel.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_finalLevel[i]+20, 40, 10);
}
break;
}
}
public void render(GameContainer gc, Graphics g)throws SlickException {
// TODO Auto-generated method stub
switch(state.currentState){
case "start":
switch(currentLevel){
case 1:
for( i = 1; i<yPos_level1.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level1[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 2:
for( i = 1; i<yPos_level2.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level2[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 3:
for( i = 1; i<yPos_level3.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level3[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 4:
for( i = 1; i<yPos_level4.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level4[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 5:
for( i = 1; i<yPos_finalLevel.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_finalLevel[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
}
case "paused":
switch(currentLevel){
case 1:
for( i = 1; i<yPos_level1.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level1[i]);
}
break;
case 2:
for( i = 1; i<yPos_level2.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level2[i]);
}
break;
case 3:
for( i = 1; i<yPos_level3.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level3[i]);
}
break;
case 4:
for( i = 1; i<yPos_level4.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level4[i]);
}
break;
case 5:
for( i = 1; i<yPos_finalLevel.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_finalLevel[i]);
}
break;
}
}
}
}

@ -0,0 +1,95 @@
package Main;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.geom.Rectangle;
public class Player {
SpriteSheet robot;
Animation walk_right,walk_left,jump_left,jump_right,stand;
int xPos,yPos;
float xSpd,ySpd;
private State state;
boolean isRunningRight, isRunningLeft,isStandingRight, hasFloorContact, isLanded, ballhit;//checks
char move;//Bewegungsanimationswähler
Rectangle collisionarea;//Kollisionsviereck an den Füßen des Roboters
void init(GameContainer gc, State gameState , int yPos) throws SlickException{
this.yPos = yPos;
this.state = gameState;
robot = new SpriteSheet("Main/robot_sheet_good.png",50,100);
walk_right = new Animation(robot,0,0,6,0,true,200,true);
walk_left = new Animation(robot,0,1,6,1,true,200,true);
jump_right = new Animation(robot,0,2,5,2,true,200,true);
jump_right.setLooping(false);
jump_left = new Animation(robot,0,3,5,3,true,200,true);
jump_left.setLooping(false);
stand = new Animation(robot,0,4,2,4,true,200,true);
xPos = 400;
ySpd = 0;
xSpd = 0;
collisionarea = new Rectangle(xPos-15, yPos+20, 35, 20);
ballhit = false;
}
void render(GameContainer gc, Graphics g)throws SlickException{
switch(state.currentState){
case "titel": break;
case "start": case "paused":
//Auswahl der zu rendernden Animation
switch(move){
case 0: stand.draw(xPos-24,yPos-50);break;
case 1:/*Run right*/walk_right.draw(xPos-25, yPos-50); break;
case 2:/*Run left*/walk_left.draw(xPos-25, yPos-50); break;
case 3:/*jump right*/jump_right.draw(xPos-25, yPos-50);break;
case 4:/*jump left*/jump_left.draw(xPos-25, yPos-50);break;
}
break;
}
}
void update(GameContainer gc, float _delta)throws SlickException{
//update der Position des Quadrates
collisionarea = new Rectangle(xPos-15, yPos+20, 35, 20);
switch(state.currentState){
case "paused":break;
case "start":
this.xPos += this.xSpd * _delta;
this.yPos += this.ySpd * _delta;
if(!hasFloorContact)//Gravitation
this.ySpd += 750.0f * _delta;
break;
}
}
void setFloorContact(boolean status){
this.hasFloorContact=status;
}
Rectangle getCollisionarea(){
return collisionarea;
}
}

@ -0,0 +1,34 @@
package Main;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
public class State {
int stateId;
String currentState;
public void init(GameContainer gc) {
// TODO Auto-generated method stub
stateId = 0;
currentState ="titel";
}
public void update(GameContainer gc, float _delta) {
// TODO Auto-generated method stub
switch(stateId){//definierung der States
case 0 : currentState = "titel";break;
case 1 : currentState = "start";break;
case 2 : currentState = "paused";break;
case 4 : currentState = "menu";break;
case 5 : currentState = "level_intro";break;
case 6 : currentState = "controlInstructions";break;
case 7 : currentState = "gameOver";break;
case 8 : currentState = "win";break;
}
}
public void render(GameContainer gc, Graphics g) {
// TODO Auto-generated method stub
}
}

@ -0,0 +1,64 @@
package Main;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
public class UserInterface {
Image destructionBar;
Image emptyBar;
Image shieldBar;
int dbar_width, sbar_width;
private State state;
public void init(GameContainer gc, State gameState) throws SlickException {
// TODO Auto-generated method stub
this.state = gameState;
destructionBar = new Image("Main/destruction_bar.png");
shieldBar = new Image("Main/shield_bar.png");
emptyBar = new Image("Main/empty_bar.png");
dbar_width = 100;
sbar_width = 0;
}
public void render(GameContainer gc, Graphics g){
switch(state.currentState){
case "titel":break;
case "start": case "paused":
g.scale(2, 2);
emptyBar.draw(290, 25, 100, 12);
emptyBar.draw(290, 286, 100, 12);
shieldBar.draw(290, 25, sbar_width, 12);
destructionBar.draw(290, 286, dbar_width, 12);
g.scale(0.5f, 0.5f);
g.setColor(Color.blue);
g.drawString("Eject Progress", 625, 27);
g.setColor(Color.magenta);
g.drawString("System Stability", 600 ,555 );
/*
* Item Slots
g.setColor(Color.darkGray);
g.fillRect(480, 570, 30, 30, 15);
g.fillRect(520, 570, 30, 30, 15);
*/
break;
}
}
}

@ -0,0 +1,3 @@
Dieses Projekt war eine Modul-Arbeit im Studium.
Ziel des Projektes war eine vollständige Prototyp-Adaption des
Spiele-Klassikers Pong in der Programmiersprache Java im Slick2D Framework.

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="ext/lwjgl/AppleJavaExtensions.jar"/>
<classpathentry kind="lib" path="ext/lwjgl/asm-debug-all.jar"/>
<classpathentry kind="lib" path="ext/lwjgl/jinput.jar"/>
<classpathentry kind="lib" path="ext/lwjgl/lwjgl_test.jar"/>
<classpathentry kind="lib" path="ext/lwjgl/lwjgl_util_applet.jar"/>
<classpathentry kind="lib" path="ext/lwjgl/lwjgl_util.jar"/>
<classpathentry kind="lib" path="ext/lwjgl/lwjgl-debug.jar"/>
<classpathentry kind="lib" path="ext/lwjgl/lwjgl.jar"/>
<classpathentry kind="lib" path="ext/lwjgl/lzma.jar"/>
<classpathentry kind="lib" path="ext/slick/hiero.jar"/>
<classpathentry kind="lib" path="ext/slick/ibxm.jar"/>
<classpathentry kind="lib" path="ext/slick/jinput.jar"/>
<classpathentry kind="lib" path="ext/slick/jnlp.jar"/>
<classpathentry kind="lib" path="ext/slick/jogg-0.0.7.jar"/>
<classpathentry kind="lib" path="ext/slick/jorbis-0.0.15.jar"/>
<classpathentry kind="lib" path="ext/slick/lwjgl.jar"/>
<classpathentry kind="lib" path="ext/slick/natives-linux.jar"/>
<classpathentry kind="lib" path="ext/slick/natives-mac.jar"/>
<classpathentry kind="lib" path="ext/slick/natives-win32.jar"/>
<classpathentry kind="lib" path="ext/slick/packulike.jar"/>
<classpathentry kind="lib" path="ext/slick/pedigree.jar"/>
<classpathentry kind="lib" path="ext/slick/scalar.jar"/>
<classpathentry kind="lib" path="ext/slick/slick-examples.jar"/>
<classpathentry kind="lib" path="ext/slick/slick-sources.jar"/>
<classpathentry kind="lib" path="ext/slick/slick-util.jar"/>
<classpathentry kind="lib" path="ext/slick/slick.jar"/>
<classpathentry kind="lib" path="ext/slick/tinylinepp.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Snake</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save