Compare commits

...

3 Commits
1.0 ... master

Author SHA1 Message Date
Jeasonfire
b466dd8cc5 Added jumping "animation". 2015-05-27 13:47:52 +03:00
Jeasonfire
1ab50f7f33 Renamed icon_128.png. 2015-05-18 05:14:18 +03:00
Jeasonfire
e27cfc71b6 Added next-level button for emergency situations. 2015-05-18 05:12:33 +03:00
8 changed files with 62 additions and 6 deletions

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,38 @@
/**
* GladiatorBrawler is a 2D swordfighting game.
* Copyright (C) 2015 Jeasonfire/Allexit
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.saltosion.gladiator.input;
import com.saltosion.gladiator.GladiatorBrawler;
import com.saltosion.gladiator.state.InGameState;
public class IRNextLevel implements InputReceiver {
@Override
public boolean pressed() {
if (GladiatorBrawler.currentState instanceof InGameState) {
((InGameState) GladiatorBrawler.currentState).nextLevel();
}
return true;
}
@Override
public boolean released() {
return false;
}
}

View File

@ -49,6 +49,7 @@ public class InputHandler implements InputProcessor {
addInput(Keys.DOWN, Name.SWING_DOWN, false); addInput(Keys.DOWN, Name.SWING_DOWN, false);
addInput(Keys.F2, Name.DEBUG, true); addInput(Keys.F2, Name.DEBUG, true);
addInput(Keys.ESCAPE, Name.SKIP_INTRO, false); addInput(Keys.ESCAPE, Name.SKIP_INTRO, false);
addInput(Keys.F3, Name.NEXT_LEVEL, false);
} }
private void addInput(int key, String action, boolean activated) { private void addInput(int key, String action, boolean activated) {

View File

@ -36,6 +36,7 @@ public class InputReceivers {
inputreceivers.put(Name.SWING_DOWN, new IRSwing(Direction.DOWN)); inputreceivers.put(Name.SWING_DOWN, new IRSwing(Direction.DOWN));
inputreceivers.put(Name.DEBUG, new IRDebugToggle()); inputreceivers.put(Name.DEBUG, new IRDebugToggle());
inputreceivers.put(Name.SKIP_INTRO, new IRSkipIntros()); inputreceivers.put(Name.SKIP_INTRO, new IRSkipIntros());
inputreceivers.put(Name.NEXT_LEVEL, new IRNextLevel());
} }
public static InputReceiver getReceiver(String key) { public static InputReceiver getReceiver(String key) {

View File

@ -141,6 +141,12 @@ public class EntityFactory {
.addSprite(playerSprites[1][9][1]); .addSprite(playerSprites[1][9][1]);
renderedObject.addSequence("Legs-Run-Left", legsRunLeftSequence); renderedObject.addSequence("Legs-Run-Left", legsRunLeftSequence);
// Jumping animation
SpriteSequence legsJumpRightSequence = new SpriteSequence(SWING_ANIMATION_SPEED).addSprite(playerSprites[1][8][0]);
renderedObject.addSequence("Legs-Jump-Right", legsJumpRightSequence);
SpriteSequence legsJumpLeftSequence = new SpriteSequence(SWING_ANIMATION_SPEED).addSprite(playerSprites[1][8][1]);
renderedObject.addSequence("Legs-Jump-Left", legsJumpLeftSequence);
// Combat animations // Combat animations
SpriteSequence torsoCombatRightSequence = new SpriteSequence(SWING_ANIMATION_SPEED).addSprite(playerSprites[0][7][0]) SpriteSequence torsoCombatRightSequence = new SpriteSequence(SWING_ANIMATION_SPEED).addSprite(playerSprites[0][7][0])
.addSprite(playerSprites[0][8][0]).addSprite(playerSprites[0][9][0]).addSprite(playerSprites[0][10][0]); .addSprite(playerSprites[0][8][0]).addSprite(playerSprites[0][9][0]).addSprite(playerSprites[0][10][0]);

View File

@ -81,6 +81,7 @@ public class InGameState extends BaseState {
AppUtil.inputHandler.setInputEnabled(Name.SWING_LEFT, true); AppUtil.inputHandler.setInputEnabled(Name.SWING_LEFT, true);
AppUtil.inputHandler.setInputEnabled(Name.SWING_RIGHT, true); AppUtil.inputHandler.setInputEnabled(Name.SWING_RIGHT, true);
AppUtil.inputHandler.setInputEnabled(Name.SWING_UP, true); AppUtil.inputHandler.setInputEnabled(Name.SWING_UP, true);
AppUtil.inputHandler.setInputEnabled(Name.NEXT_LEVEL, true);
} }
@Override @Override
@ -100,13 +101,8 @@ public class InGameState extends BaseState {
if (level.levelCleared()) { if (level.levelCleared()) {
timeSinceLevelWon += deltaTime; timeSinceLevelWon += deltaTime;
if (timeSinceLevelWon > levelWonDelay) { if (timeSinceLevelWon > levelWonDelay) {
currentLevel++;
timeSinceLevelWon = 0; timeSinceLevelWon = 0;
if (currentLevel >= levels.length) { nextLevel();
setState(new WinState());
} else {
changeLevel(levels[currentLevel]);
}
} }
} }
@ -118,6 +114,15 @@ public class InGameState extends BaseState {
} }
} }
public void nextLevel() {
currentLevel++;
if (currentLevel >= levels.length) {
setState(new WinState());
} else {
changeLevel(levels[currentLevel]);
}
}
public void changeLevel(Level level) { public void changeLevel(Level level) {
AppUtil.engine.removeAllEntities(); AppUtil.engine.removeAllEntities();
this.level = level; this.level = level;
@ -136,6 +141,7 @@ public class InGameState extends BaseState {
AppUtil.inputHandler.setInputEnabled(Name.SWING_LEFT, false); AppUtil.inputHandler.setInputEnabled(Name.SWING_LEFT, false);
AppUtil.inputHandler.setInputEnabled(Name.SWING_RIGHT, false); AppUtil.inputHandler.setInputEnabled(Name.SWING_RIGHT, false);
AppUtil.inputHandler.setInputEnabled(Name.SWING_UP, false); AppUtil.inputHandler.setInputEnabled(Name.SWING_UP, false);
AppUtil.inputHandler.setInputEnabled(Name.NEXT_LEVEL, false);
// Clear all entities that are left as they are no longer needed // Clear all entities that are left as they are no longer needed
AppUtil.engine.removeAllEntities(); AppUtil.engine.removeAllEntities();

View File

@ -222,6 +222,9 @@ public class RenderingSystem extends EntitySystem {
ro.playAnimation("torso", "Torso-Idle-" + dirMove); ro.playAnimation("torso", "Torso-Idle-" + dirMove);
ro.playAnimation("legs", "Legs-Idle-" + dirMove); ro.playAnimation("legs", "Legs-Idle-" + dirMove);
} }
if (!po.isGrounded()) {
ro.playAnimation("legs", "Legs-Jump-" + dirMove);
}
} }
private void tryToMakeStepSound(CPhysics po) { private void tryToMakeStepSound(CPhysics po) {

View File

@ -51,6 +51,7 @@ public class Name {
public static final String SWING_UP = "SWING_UP"; public static final String SWING_UP = "SWING_UP";
public static final String SWING_DOWN = "SWING_DOWN"; public static final String SWING_DOWN = "SWING_DOWN";
public static final String SKIP_INTRO = "SKIP_INTRO"; public static final String SKIP_INTRO = "SKIP_INTRO";
public static final String NEXT_LEVEL = "NEXT_LEVEL";
public static final String DEBUG = "DEBUG"; public static final String DEBUG = "DEBUG";
public static final String MUSIC_THEME = "MUSIC_THEME"; public static final String MUSIC_THEME = "MUSIC_THEME";