Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b466dd8cc5 | ||
|
1ab50f7f33 | ||
|
e27cfc71b6 |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
38
core/src/com/saltosion/gladiator/input/IRNextLevel.java
Normal file
38
core/src/com/saltosion/gladiator/input/IRNextLevel.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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) {
|
||||||
|
@ -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) {
|
||||||
|
@ -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]);
|
||||||
|
@ -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();
|
||||||
|
@ -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) {
|
||||||
|
@ -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";
|
||||||
|
Loading…
Reference in New Issue
Block a user