();
syncController = new SyncController();
@@ -287,6 +343,7 @@ protected GameController(Rectangle bounds, Vector2 gravity) {
failed = false;
debug = false;
active = false;
+ paused = false;
countdown = -1;
}
@@ -312,12 +369,11 @@ public void dispose() {
}
- // TODO: Adjust to the correct assets after assets have been added
/**
* Gather the assets for this controller.
- *
- * This method extracts the asset variables from the given asset directory. It
- * should only be called after the asset directory is completed.
+ *
+ * This method extracts the asset variables from the given asset directory. It should only be
+ * called after the asset directory is completed.
*
* @param directory Reference to global asset manager.
*/
@@ -325,6 +381,8 @@ public void gatherAssets(AssetDirectory directory) {
objectController.gatherAssets(directory);
// set the soundtrack
setSoundtrack(directory);
+ // set the sound effects
+ initializeSFX(directory);
}
/**
@@ -339,6 +397,15 @@ public void setSoundtrack(AssetDirectory directory) {
jazzSoundtrack = directory.getEntry("music:jazz1", Music.class);
soundController.setSynthTrack(synthSoundtrack);
soundController.setJazzTrack(jazzSoundtrack);
+ soundController.setGlobalMusicVolume(musicVolume / 10f);
+ soundController.setGlobalSFXVolume(SFXVolume / 10f);
+ }
+
+ /** Initializes the sound effects, which are stored in the sound controller.
+ * @param directory Reference to global asset manager.
+ */
+ public void initializeSFX(AssetDirectory directory) {
+ soundController.addSound("genreSwitch", directory.getEntry("sfx:genreSwitch", Sound.class));
}
public Vector2 getScale() {
@@ -367,7 +434,7 @@ public void instantiateQueue(GameObject obj) {
/**
* If the object is implements {@link ISynced}, add
* to the sync. If it is a {@link IGenreObject}, add to genreObstacles.
- *
+ *
* @param object: The object you are instantiating
*
*/
@@ -383,6 +450,18 @@ protected void instantiate(GameObject object) {
object.activatePhysics(world);
}
+ /**
+ * If the object is implements {@link ISynced}, add
+ * to the sync. If it is a {@link IGenreObject}, add to genreObstacles.
+ *
+ * @param gui: The GUI element you are instantiating
+ *
+ */
+ protected void instantiate(GenreUI gui) {
+ syncController.addSync(gui);
+ objectController.genreObjects.add(gui);
+ }
+
/**
* Returns true if the object is in bounds.
*
@@ -406,8 +485,8 @@ public void initialize() {
Vector2 gravity = new Vector2(world.getGravity());
world = new World(gravity, false);
- worldWidth = DEFAULT_WIDTH * objectController.backgroundTexture.getRegionWidth() / 1920;
- worldHeight = DEFAULT_HEIGHT * objectController.backgroundTexture.getRegionHeight() / 1080;
+ worldWidth = DEFAULT_WIDTH * objectController.backgroundTexture.getRegionWidth() / getCanvas().getWidth();
+ worldHeight = DEFAULT_HEIGHT * objectController.backgroundTexture.getRegionHeight() / getCanvas().getHeight();
world.setContactListener(this);
setComplete(false);
setFailure(false);
@@ -417,7 +496,6 @@ public void initialize() {
soundController.playMusic(Genre.SYNTH);
}
- // TODO: Reset to SYNTH defaults
/**
* Resets the status of the game so that we can play again.
*
@@ -442,25 +520,21 @@ public void reset() {
syncController = new SyncController();
populateLevel();
objectController.player.setPosition(respawnPoint);
- syncController.setSync(synthSoundtrack, jazzSoundtrack);
soundController.resetMusic();
}
- // TODO: Will use level data json to populate
/**
* Lays out the game geography.
*/
private void populateLevel() {
// world starts with Synth gravity
- world.setGravity(new Vector2(0, objectController.defaultConstants.get("genre_gravity").getFloat("synth", 0)));
- // TODO This volume constant is never used
- float volume = objectController.defaultConstants.getFloat("volume", 1.0f);
+ world.setGravity(new Vector2(0, objectController.defaultConstants.get("defaults").getFloat("gravity", 0)));
syncController.addSync(new BeatTest());
syncController.setSync(synthSoundtrack, jazzSoundtrack);
objectController.populateObjects(scale);
- ;
+
}
@@ -472,12 +546,13 @@ private void populateLevel() {
* normally.
*
* @param dt Number of seconds since last animation frame
- *
+ *
* @return whether to process the update loop
*/
public boolean preUpdate(float dt) {
InputController input = InputController.getInstance();
input.readInput(bounds, scale);
+
if (listener != null) {
// Toggle debug
if (input.didDebug()) {
@@ -490,11 +565,54 @@ public boolean preUpdate(float dt) {
}
// Now it is time to maybe switch screens.
- if (input.didExit()) {
- pause();
- listener.exitScreen(this, EXIT_QUIT);
- return false;
- } else if (countdown > 0) {
+ if (input.didExit() || input.didPressLevelSelect()) {
+ exitLevel();
+ }
+
+ else if (input.didPause()) {
+ // If game is already paused, hitting pause again will unpause it.
+ paused = !paused;
+ if (paused) {
+ pause();
+ }
+ else {
+ resume();
+ // Make sure that genre doesn't get switched while game is paused
+ }
+ }
+ else if (paused) {
+ // If game is currently in the middle of the paused state, do all this. It won't work the first frame of pausing but that should be fine
+ if (input.didPressDownWhilePaused()) {
+ pauseItemSelected = (pauseItemSelected + 1) % 5;
+ }
+ if (input.didPressUpWhilePaused()) { // not using else if on purpose
+ pauseItemSelected--;
+ if (pauseItemSelected == -1) pauseItemSelected = 4;
+ }
+ if (pauseItemSelected == 3) {
+ if (input.didPressLeftWhilePaused() && musicVolume > 0) { // change this to 1 if it causes bugs
+ musicVolume--;
+ }
+ if (input.didPressRightWhilePaused() && musicVolume < 10) {
+ musicVolume++;
+ }
+ }
+ else if (pauseItemSelected == 4) {
+ if (input.didPressLeftWhilePaused() && SFXVolume > 0) { // again, change this to 1 if it causes bugs
+ SFXVolume--;
+ }
+ if (input.didPressRightWhilePaused() && SFXVolume < 10) {
+ SFXVolume++;
+ }
+ }
+ else {
+ if (input.didPressEnter()) {
+ pauseAction(pauseItemSelected);
+ }
+ }
+ }
+
+ else if (countdown > 0) {
countdown--;
} else if (countdown == 0) {
if (failed) {
@@ -502,7 +620,6 @@ public boolean preUpdate(float dt) {
} else if (complete) {
pause();
// TODO: Make Win Condition
- System.out.println("You win the game");
return false;
}
}
@@ -514,7 +631,6 @@ public boolean preUpdate(float dt) {
return true;
}
- // TODO: Update physics based on genre
/**
* The core gameplay loop of this world.
*
@@ -529,9 +645,6 @@ public boolean preUpdate(float dt) {
* @param dt Number of seconds since last animation frame
*/
public void update(float dt) {
- // TODO: bullet stuff needs to go and make the update in the object itself, not
- // here
-
if (InputController.getInstance().getSwitchGenre()) {
switchGenre();
InputController.getInstance().setSwitchGenre(false);
@@ -551,6 +664,7 @@ public void update(float dt) {
Vector2 displace = lastMCollideWith.currentVelocity();
objectController.player.setDisplace(displace);
}
+
}
/**
@@ -587,55 +701,25 @@ public void beginContact(Contact contact) {
sensorFixtures.add(objectController.player == bd1 ? fix2 : fix1); // Could have more than one ground
}
}
-
// Check for win condition
if ((bd1 == objectController.player && bd2 == objectController.goalDoor) ||
(bd1 == objectController.goalDoor && bd2 == objectController.player)) {
setComplete(true);
}
- if ((bd1.equals(objectController.player) && bd2 instanceof Enemy)) {
- setFailure(true);
- }
-
- if (bd1 instanceof Bullet && !(bd2 instanceof Enemy) ) {
- bd1.markRemoved(true);
- }
-
- if (bd2 instanceof Bullet && !(bd1 instanceof Enemy) ) {
- bd2.markRemoved(true);
- }
-
- if ((bd1.equals(objectController.player) && bd2 instanceof Bullet)) {
- setFailure(true);
- }
-
- if (bd1 instanceof BeeEnemy && !(bd2 instanceof BeeHive) ) {
- bd1.markRemoved(true);
- }
-
- if (bd2 instanceof BeeEnemy && !(bd1 instanceof BeeHive) ) {
- bd2.markRemoved(true);
- }
-
- if ((bd1.equals(objectController.player) && bd2 instanceof Enemy)) {
- setFailure(true);
- }
-
- if ((bd1.equals(objectController.player) && bd2 instanceof BatEnemy)) {
- setFailure(true);
- }
-
- //TODO: implement lethal obstacle code which checks for the first obstacle being the player, then checking if the
- if ((bd2 instanceof Player && bd1 instanceof SimpleGameObject)){
- if (((SimpleGameObject) bd1).getType() == SimpleGameObject.ObjectType.LETHAL){
- setFailure(true);
+ //player collision checks
+ if (bd1.getType() == Type.Player){
+ if(bd2.getType() == Type.LETHAL){
+ getPlayer().isDying = true;
+ }
+ if(bd2 instanceof WeightedPlatform){
+ lastCollideWith = (WeightedPlatform) bd1;
}
}
- if ((bd1 instanceof WeightedPlatform) && (bd2 instanceof Player)){
+ if ((bd1 instanceof WeightedPlatform) && (bd2.getType() == Type.Player)){
lastCollideWith = (WeightedPlatform) bd1;
}
- if ((bd1 instanceof MovingPlatform) && (bd2 instanceof Player)){
+ if ((bd1 instanceof MovingPlatform) && (bd2.getType() == Type.Player)){
lastMCollideWith = (MovingPlatform) bd1;
}
// Check for collision with checkpoints and set new current checkpoint
@@ -710,14 +794,7 @@ public void preSolve(Contact contact, Manifold oldManifold) {
*/
public void updateGenreSwitch() {
soundController.setGenre(genre);
- // update to Synth
- if (genre == Genre.SYNTH) {
- world.setGravity(new Vector2(0, objectController.defaultConstants.get("genre_gravity").getFloat("synth", 0)));
- }
- // update to Jazz
- else {
- world.setGravity(new Vector2(0, objectController.defaultConstants.get("genre_gravity").getFloat("jazz", 0)));
- }
+ soundController.playSFX("genreSwitch");
for (IGenreObject g : objectController.genreObjects) {
g.genreUpdate(genre);
@@ -758,6 +835,14 @@ public void postUpdate(float dt) {
obj.update(dt);
}
}
+
+ // Update genre-dependent UI element
+ objectController.genreIndicator.update(dt);
+
+ // Update checkpoints
+ for (Checkpoint checkpoint : objectController.checkpoints) {
+ checkpoint.update(dt);
+ }
}
/**
@@ -774,11 +859,11 @@ public void draw(float dt) {
canvas.clear();
// Draw background unscaled.
- canvas.begin();
+ canvas.begin(false);
canvas.draw(objectController.backgroundTexture, 0, 0);
canvas.end();
- canvas.begin();
+ canvas.begin(false);
for (GameObject obj : objectController.objects) {
if (!objectController.foreground.contains(obj)){
obj.draw(canvas);
@@ -787,12 +872,12 @@ public void draw(float dt) {
canvas.end();
// Draw the player on top
- canvas.begin();
+ canvas.begin(false);
objectController.player.draw(canvas);
canvas.end();
// Draw the foreground on top of everything
- canvas.begin();
+ canvas.begin(false);
for (GameObject obj : objectController.foreground) {
obj.draw(canvas);
}
@@ -806,19 +891,90 @@ public void draw(float dt) {
canvas.endDebug();
}
- // Final message
+ // Draw genre indicator UI
+ canvas.begin(true);
+ canvas.draw(objectController.blackGradient, 0, 0);
+ objectController.genreIndicator.draw(canvas, 50, 50);
+ canvas.end();
+
+ // Victory Screen
if (complete && !failed) {
+ playerCompletedLevel = true;
objectController.displayFont.setColor(Color.YELLOW);
- canvas.begin(); // DO NOT SCALE
- canvas.drawTextCentered("VICTORY!", objectController.displayFont, 0.0f);
+
+ canvas.begin(true); // DO NOT SCALE
+ canvas.draw(objectController.pauseWhiteOverlayTexture.getTexture(), pauseTintSynthColor, 0, 0, 0, 0, 0, 1, 1);
+ canvas.draw(objectController.nextLevelText.getTexture(), Color.WHITE, 0, 0, 570, 370, 0, 0.5f, 0.5f);
+ canvas.draw(objectController.levelSelectText.getTexture(), Color.WHITE, 0, 0, 570, 310, 0, 0.5f, 0.5f);
+ canvas.draw(objectController.victoryLogo.getTexture(), Color.WHITE, 0, 0, 310, 220, 0, 0.5f, 0.5f);
+
+ switch (victoryScreenItemSelected) {
+ case 0: // Next Level
+ canvas.draw(objectController.indicatorStarTexture.getTexture(),
+ Color.WHITE, 0, 0, 520, 360, 0, 0.5f, 0.5f);
+ break;
+ case 1: // Level Select
+ canvas.draw(objectController.indicatorStarTexture.getTexture(),
+ Color.WHITE, 0, 0, 520, 300, 0, 0.5f, 0.5f);
+ break;
+ }
+
canvas.end();
+
+ incrementLevelsUnlocked();
} else if (failed) {
objectController.displayFont.setColor(Color.RED);
- canvas.begin(); // DO NOT SCALE
+ canvas.begin(true); // DO NOT SCALE
// TODO: Remove this failure text with something more appropriate for our game
// canvas.drawTextCentered("FAILURE!", objectController.displayFont, 0.0f);
canvas.end();
}
+
+ // Put pause screen UI in this if statement
+ if (paused) {
+ objectController.displayFont.setColor(Color.CYAN);
+ //canvas.begin(true); // DO NOT SCALE
+ //canvas.drawTextCentered("You paused the game!", objectController.displayFont, 0.0f);
+ //canvas.end();
+
+ canvas.begin(true);
+ canvas.draw(objectController.pauseWhiteOverlayTexture.getTexture(), (genre == Genre.SYNTH ? pauseTintSynthColor : pauseTintJazzColor), 0, 0, 0, 0, 0, 1, 1);
+ canvas.draw(objectController.overlayTexture.getTexture(), Color.WHITE, 0, 0, 0, -10, 0,1.05f, 1.05f);
+ canvas.draw(objectController.restartLevelTexture.getTexture(), Color.WHITE, 0, 0, 860, 370, 0, 0.5f, 0.5f);
+ canvas.draw(objectController.resumeTexture.getTexture(), Color.WHITE, 0, 0, 860, 310, 0, 0.5f, 0.5f);
+ canvas.draw(objectController.exitLevelTexture.getTexture(), Color.WHITE, 0, 0, 860, 250, 0, 0.5f, 0.5f);
+ canvas.draw(objectController.musicTexture.getTexture(), Color.WHITE, 0, 0, 800, 160, 0, 0.5f, 0.5f);
+ canvas.draw(objectController.SFXTexture.getTexture(), Color.WHITE, 0, 0, 850, 80, 0, 0.5f, 0.5f);
+ for (int i = 0; i < musicVolume; i++) {
+ canvas.draw(objectController.volumeBoxTexture.getTexture(), Color.WHITE, 0, 0, 970 + i * 20, 160, 0, 0.5f, 0.5f);
+ }
+ for (int i = 0; i < SFXVolume; i++) {
+ canvas.draw(objectController.volumeBoxTexture.getTexture(), Color.WHITE, 0, 0, 970 + i * 20, 80, 0, 0.5f, 0.5f);
+ }
+ canvas.draw(objectController.unhoverLowerSoundTexture.getTexture(), Color.WHITE, 0, 0, 935, 160, 0, 0.5f, 0.5f);
+ canvas.draw(objectController.unhoverLowerSoundTexture.getTexture(), Color.WHITE, 0, 0, 935, 80, 0, 0.5f, 0.5f);
+ canvas.draw(objectController.unhoverUpSoundTexture.getTexture(), Color.WHITE, 0, 0, 1175, 160, 0, 0.5f, 0.5f);
+ canvas.draw(objectController.unhoverUpSoundTexture.getTexture(), Color.WHITE, 0, 0, 1175, 80, 0, 0.5f, 0.5f);
+
+ switch (pauseItemSelected) {
+ case 0: // Restart Level
+ canvas.draw(objectController.indicatorStarTexture.getTexture(), Color.WHITE, 0, 0, 800, 370, 0, 0.5f, 0.5f);
+ break;
+ case 1: // Resume Level
+ canvas.draw(objectController.indicatorStarTexture.getTexture(), Color.WHITE, 0, 0, 800,310, 0, 0.5f, 0.5f);
+ break;
+ case 2: // Exit Level
+ canvas.draw(objectController.indicatorStarTexture.getTexture(), Color.WHITE, 0, 0, 800, 250,0, 0.5f, 0.5f);
+ break;
+ case 3: // Music
+ canvas.draw(objectController.indicatorStarTexture.getTexture(), Color.WHITE, 0, 0, 740,160, 0, 0.5f, 0.5f);
+ break;
+ case 4: // SFX
+ canvas.draw(objectController.indicatorStarTexture.getTexture(), Color.WHITE, 0, 0, 780,80, 0, 0.5f, 0.5f);
+ break;
+ }
+ canvas.end();
+ }
}
/**
@@ -845,11 +1001,13 @@ public void resize(int width, int height) {
*/
public void render(float delta) {
if (active) {
- if (preUpdate(delta)) {
+ if (preUpdate(delta) && !paused) {
update(delta); // This is the one that must be defined.
postUpdate(delta);
}
- canvas.updateCamera(objectController.player, worldWidth, worldHeight);
+ if (!paused) {
+ canvas.updateCamera(objectController.player, worldWidth, worldHeight);
+ }
draw(delta);
}
}
@@ -861,7 +1019,8 @@ public void render(float delta) {
* Pausing happens when we switch game modes.
*/
public void pause() {
- // TODO: Stop all sounds here
+ soundController.pauseMusic();
+ InputController.getInstance().setPaused(true);
}
/**
@@ -870,9 +1029,46 @@ public void pause() {
* This is usually when it regains focus.
*/
public void resume() {
- // TODO Auto-generated method stub
+ soundController.setGlobalMusicVolume(musicVolume / 10f);
+ soundController.setGlobalSFXVolume(SFXVolume / 10f);
+ soundController.resumeMusic();
+ InputController.getInstance().setPaused(false);
+ pauseItemSelected = 0; // delete this line if pause menu should "save" where you were last time
+ InputController.getInstance().setSwitchGenre(false);
}
+ public void pauseAction(int sel) {
+ switch (sel) {
+ case 0: // Restart Level
+ paused = false;
+ for (Checkpoint checkpoint : objectController.checkpoints) {
+ checkpoint.setActive(false);
+ }
+ if (objectController.checkpoints.size() > 0) {
+ objectController.checkpoints.get(0).setActive(true);
+ }
+ objectController.setFirstCheckpointAsSpawn(scale);
+ resume();
+ reset();
+ break;
+ case 1: // Resume Level
+ paused = false;
+ resume();
+ break;
+ case 2: // Exit Level
+ exitLevel();
+ break;
+ default: break;
+ }
+ }
+ /** Returns to the level select screen and resets the SoundController accordingly. */
+
+
+ public void exitLevel() {
+ soundController.resetMusic();
+ soundController.pauseMusic();
+ exitScreen(0);
+ }
/**
* Called when this screen becomes the current screen for a Game.
*/
@@ -920,27 +1116,71 @@ public Player getPlayer() {
return objectController.player;
}
- public void createJoint(GameObject bd1, GameObject bd2){
- Vector2 anchor1 = new Vector2();
- Vector2 anchor2 = new Vector2();
+ /** Return the currentLevel String variable */
+ public String getCurrentLevel() {
+ return currentLevel;
+ }
-// Vector2 anchor1 = bd1.getPosition();
-// Vector2 anchor2 = bd2.getPosition();
+ /** Set the currentLevel variable to the current level */
+ public void setCurrentlLevel(String currentLevel) {
+ this.currentLevel = currentLevel;
+ }
- // Definition for a revolute joint
- JointDef jointDef = new PrismaticJointDef();
+ public int getNumberOfLevels() {
+ return numberOfLevels;
+ }
- // Initial joint
- jointDef.bodyA = bd1.getBody();
- jointDef.bodyB = bd2.getBody();
+ /** Called when the game screen needs to be exited out of */
+ public void exitScreen(int exitCode) {
+ //pause();
+ listener.exitScreen(this, exitCode);
+ }
- jointDef.collideConnected = true;
- Joint joint = world.createJoint(jointDef);
+ /** Sets the currentLevelInt variable and concurrently change the currentLevel String*/
+ public void setCurrentLevelInt(int currentLevelInt) {
+ this.currentLevelInt = currentLevelInt;
+ currentLevel = "level" + currentLevelInt;
}
- //TODO: destroy joint!
-// public void breakJoint(Joint joint){
-// world.destroyJoint(joint);
-// }
+ /** Return the int variable currentLevelInt */
+ public int getCurrentLevelInt() {
+ return currentLevelInt;
+ }
+
+ /** Returns the number of levelsUnlocked */
+ public int getLevelsUnlocked() {
+ return levelsUnlocked;
+ }
+
+ /** Sets the integer levelsUnlocked */
+ public void setLevelsUnlocked(int levelsUnlocked) {
+ this.levelsUnlocked = levelsUnlocked;
+ }
+
+ /** Increments the integer levelsUnlocked if a player completes a level and the next level is locked*/
+ public void incrementLevelsUnlocked() {
+ if(currentLevelInt == levelsUnlocked) {
+ levelsUnlocked++;
+ }
+ }
+ /** Returns whether player has completed the level */
+ public boolean getPlayerCompletedLevel() {
+ return playerCompletedLevel;
+ }
+
+ /** Sets the boolean playerCompletedLevel */
+ public void setPlayerCompletedLevel(boolean playerCompletedLevel) {
+ this.playerCompletedLevel = playerCompletedLevel;
+ }
+
+ /** Sets the integer victoryScreenItemSelected */
+ public void setVictoryScreenItemSelected(int victoryScreenItemSelected) {
+ this.victoryScreenItemSelected = victoryScreenItemSelected;
+ }
+
+ /** Returns teh integer victoryScreenItemSelected */
+ public int getVictoryScreenItemSelected() {
+ return victoryScreenItemSelected;
+ }
}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/InputController.java b/core/src/edu/cornell/gdiac/rabbeat/InputController.java
index 39047617..3e314056 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/InputController.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/InputController.java
@@ -22,9 +22,9 @@
/**
- * Class for reading player input.
+ * Class for reading player input.
*
- * This supports both a keyboard and X-Box controller. In previous solutions, we only
+ * This supports both a keyboard and X-Box controller. In previous solutions, we only
* detected the X-Box controller on start-up. This class allows us to hot-swap in
* a controller via the new XBox360Controller class.
*/
@@ -37,8 +37,8 @@ public class InputController {
/** The singleton instance of the input controller */
private static InputController theController = null;
-
- /**
+
+ /**
* Return the singleton instance of the input controller
*
* @return the singleton instance of the input controller
@@ -49,7 +49,7 @@ public static InputController getInstance() {
}
return theController;
}
-
+
// Fields to manage buttons
/** Whether the reset button was pressed. */
private boolean resetPressed;
@@ -74,7 +74,32 @@ public static InputController getInstance() {
/** Whether the exit button was pressed. */
private boolean exitPressed;
private boolean exitPrevious;
-
+
+ /** Whether or not the pause button was pressed */
+ private boolean pausePressed;
+
+ private boolean enterPressed;
+
+ private boolean enterPrevious;
+
+ private boolean pausePrevious;
+
+ private boolean pauseUpPressed;
+ private boolean pauseUpPrevious;
+
+ private boolean pauseDownPressed;
+ private boolean pauseDownPrevious;
+
+ private boolean pauseRightPressed;
+ private boolean pauseRightPrevious;
+
+ private boolean pauseLeftPressed;
+ private boolean pauseLeftPrevious;
+
+ private boolean levelSelectPressed;
+
+ private boolean levelSelectPrevious;
+
/** How much did we move horizontally? */
private float horizontal;
/** How much did we move vertically? */
@@ -94,37 +119,40 @@ public static InputController getInstance() {
/** Whether the delay buttons have been pressed*/
private float delay;
-
+
+ /** Whether or not the game is paused. Set by GameController */
+ private boolean paused;
+
/** An X-Box controller (if it is connected) */
XBoxController xbox;
-
+
/**
- * Returns the amount of sideways movement.
+ * Returns the amount of sideways movement.
*
* -1 = left, 1 = right, 0 = still
*
- * @return the amount of sideways movement.
+ * @return the amount of sideways movement.
*/
public float getHorizontal() {
return horizontal;
}
-
+
/**
- * Returns the amount of vertical movement.
+ * Returns the amount of vertical movement.
*
* -1 = down, 1 = up, 0 = still
*
- * @return the amount of vertical movement.
+ * @return the amount of vertical movement.
*/
public float getVertical() {
return vertical;
}
-
+
/**
* Returns the current position of the crosshairs on the screen.
*
* This value does not return the actual reference to the crosshairs position.
- * That way this method can be called multiple times without any fair that
+ * That way this method can be called multiple times without any fair that
* the position has been corrupted. However, it does return the same object
* each time. So if you modify the object, the object will be reset in a
* subsequent call to this getter.
@@ -188,7 +216,17 @@ public boolean didReset() {
public boolean didAdvance() {
return nextPressed && !nextPrevious;
}
-
+
+ public boolean didPressRightWhilePaused() {return pauseRightPressed && !pauseRightPrevious;}
+
+ public boolean didPressLeftWhilePaused() {return pauseLeftPressed && !pauseLeftPrevious;}
+
+ public boolean didPressUpWhilePaused() {return pauseUpPressed && !pauseUpPrevious;}
+
+ public boolean didPressDownWhilePaused() {return pauseDownPressed && !pauseDownPrevious;}
+
+ public boolean didPressLevelSelect() {return levelSelectPressed && !levelSelectPrevious;}
+
/**
* Returns true if the player wants to go to the previous level.
*
@@ -197,7 +235,7 @@ public boolean didAdvance() {
public boolean didRetreat() {
return prevPressed && !prevPrevious;
}
-
+
/**
* Returns true if the player wants to go toggle the debug mode.
*
@@ -206,7 +244,7 @@ public boolean didRetreat() {
public boolean didDebug() {
return debugPressed && !debugPrevious;
}
-
+
/**
* Returns true if the exit button was pressed.
*
@@ -215,13 +253,28 @@ public boolean didDebug() {
public boolean didExit() {
return exitPressed && !exitPrevious;
}
-
+
/**
* Creates a new input controller
- *
+ *
* The input controller attempts to connect to the X-Box controller at device 0,
* if it exists. Otherwise, it falls back to the keyboard control.
*/
+
+ /**
+ * Returns true if the pause button was pressed.
+ * @return true if the pause button was pressed.
+ */
+ public boolean didPause() { return pausePressed && !pausePrevious; }
+
+ public boolean didPressEnter() { return enterPressed && !enterPrevious;}
+
+ /** Sets whether or not the game is currently paused.
+ *
+ * @param p whether or not the game is currently paused.
+ */
+ public void setPaused(boolean p) { paused = p;}
+
public InputController() {
// If we have a game-pad for id, then use it.
Array controllers = Controllers.get().getXBoxControllers();
@@ -241,7 +294,7 @@ public InputController() {
* the drawing scale to convert screen coordinates to world coordinates. The
* bounds are for the crosshair. They cannot go outside of this zone.
*
- * @param bounds The input bounds for the crosshair.
+ * @param bounds The input bounds for the crosshair.
* @param scale The drawing scale
*/
public void readInput(Rectangle bounds, Vector2 scale) {
@@ -254,7 +307,16 @@ public void readInput(Rectangle bounds, Vector2 scale) {
exitPrevious = exitPressed;
nextPrevious = nextPressed;
prevPrevious = prevPressed;
-
+ pausePrevious = pausePressed;
+ enterPrevious = enterPressed;
+ levelSelectPrevious = levelSelectPressed;
+ if (paused) {
+ pauseUpPrevious = pauseUpPressed;
+ pauseDownPrevious = pauseDownPressed;
+ pauseLeftPrevious = pauseLeftPressed;
+ pauseRightPrevious = pauseRightPressed;
+ }
+
// Check to see if a GamePad is connected
if (xbox != null && xbox.isConnected()) {
readGamepad(bounds, scale);
@@ -271,7 +333,7 @@ public void readInput(Rectangle bounds, Vector2 scale) {
* the drawing scale to convert screen coordinates to world coordinates. The
* bounds are for the crosshair. They cannot go outside of this zone.
*
- * @param bounds The input bounds for the crosshair.
+ * @param bounds The input bounds for the crosshair.
* @param scale The drawing scale
*/
private void readGamepad(Rectangle bounds, Vector2 scale) {
@@ -286,7 +348,7 @@ private void readGamepad(Rectangle bounds, Vector2 scale) {
horizontal = xbox.getLeftX();
vertical = xbox.getLeftY();
secondPressed = xbox.getRightTrigger() > 0.6f;
-
+
// Move the crosshairs with the right stick.
tertiaryPressed = xbox.getA();
crosscache.set(xbox.getLeftX(), xbox.getLeftY());
@@ -317,30 +379,83 @@ private void readKeyboard(Rectangle bounds, Vector2 scale, boolean secondary) {
debugPressed = (secondary && debugPressed) || (Gdx.input.isKeyPressed(Input.Keys.B));
primePressed = (secondary && primePressed) || (Gdx.input.isKeyPressed(Input.Keys.UP)
|| Gdx.input.isKeyPressed(Input.Keys.W));
- exitPressed = (secondary && exitPressed) || (Gdx.input.isKeyPressed(Input.Keys.ESCAPE));
-
+ exitPressed = (secondary && exitPressed) || (Gdx.input.isKeyPressed(Input.Keys.ESCAPE));
+ pausePressed = (secondary && pausePressed) || (Gdx.input.isKeyPressed(Input.Keys.P));
+ levelSelectPressed = (secondary && levelSelectPressed) || (Gdx.input.isKeyPressed(Input.Keys.L));
+
+
// Directional controls
- horizontal = (secondary ? horizontal : 0.0f);
- if (Gdx.input.isKeyPressed(Input.Keys.RIGHT) || Gdx.input.isKeyPressed(Input.Keys.D)) {
- horizontal += 1.0f;
- }
- if (Gdx.input.isKeyPressed(Input.Keys.LEFT) || Gdx.input.isKeyPressed(Input.Keys.A)) {
- horizontal -= 1.0f;
- }
-
- vertical = (secondary ? vertical : 0.0f);
- if (Gdx.input.isKeyPressed(Input.Keys.UP) || Gdx.input.isKeyPressed(Input.Keys.W)) {
- vertical += 1.0f;
- }
- if (Gdx.input.isKeyPressed(Input.Keys.DOWN) || Gdx.input.isKeyPressed(Input.Keys.S)) {
- vertical -= 1.0f;
+ if (!paused) {
+ horizontal = (secondary ? horizontal : 0.0f);
+ if (Gdx.input.isKeyPressed(Input.Keys.RIGHT) || Gdx.input.isKeyPressed(Input.Keys.D)) {
+ horizontal += 1.0f;
+ }
+ if (Gdx.input.isKeyPressed(Input.Keys.LEFT) || Gdx.input.isKeyPressed(Input.Keys.A)) {
+ horizontal -= 1.0f;
+ }
+
+ vertical = (secondary ? vertical : 0.0f);
+ if (Gdx.input.isKeyPressed(Input.Keys.UP) || Gdx.input.isKeyPressed(Input.Keys.W)) {
+ vertical += 1.0f;
+ }
+ if (Gdx.input.isKeyPressed(Input.Keys.DOWN) || Gdx.input.isKeyPressed(Input.Keys.S)) {
+ vertical -= 1.0f;
+ }
+
+ if (Gdx.input.isKeyJustPressed(Input.Keys.SHIFT_LEFT)
+ || Gdx.input.isKeyJustPressed(Keys.SHIFT_RIGHT) && !genreSwitched) {
+ genreSwitched = true;
+ switchGenre = true;
+ } else {
+ genreSwitched = false;
+ }
}
+ // When the game IS paused
+ else {
+ pauseRightPressed = Gdx.input.isKeyPressed(Input.Keys.RIGHT) || Gdx.input.isKeyPressed(Input.Keys.D);
+ pauseLeftPressed = Gdx.input.isKeyPressed(Input.Keys.LEFT) || Gdx.input.isKeyPressed(Input.Keys.A);
+ pauseUpPressed = Gdx.input.isKeyPressed(Input.Keys.UP) || Gdx.input.isKeyPressed(Input.Keys.W);
+ pauseDownPressed = Gdx.input.isKeyPressed(Input.Keys.DOWN) || Gdx.input.isKeyPressed(Input.Keys.S);
+ enterPressed = Gdx.input.isKeyPressed(Input.Keys.ENTER);
+
+ if (Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT) && !genreSwitched) {
+ genreSwitched = true;
+ switchGenre = true;
+ } else if (!Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT)) {
+ genreSwitched = false;
+ }
+ //TODO: This is temporary code to add artificial delay to the syncing
+ delay = 0;
+ if (Gdx.input.isKeyPressed(Keys.EQUALS)) {
+ delay = .05f;
+ } else if (Gdx.input.isKeyPressed(Keys.MINUS)) {
+ delay = -.05f;
+ }
+
+ if (Gdx.input.isKeyPressed(Input.Keys.L)) {
+ levelSelectPressed = true;
+ }
+
+ if (Gdx.input.isKeyPressed(Keys.TAB) && GameController.getInstance()
+ .getPlayerCompletedLevel()) {
+ GameController gc = GameController.getInstance();
+ gc.exitScreen(1);
+ gc.setPlayerCompletedLevel(false);
+ gc.setCurrentlLevel(gc.getCurrentLevel() + 1);
+ }
- if (Gdx.input.isKeyPressed(Input.Keys.SPACE) && !genreSwitched) {
- genreSwitched = true;
- switchGenre = true;
- } else if (!Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
- genreSwitched = false;
+ if (Gdx.input.isKeyPressed(Keys.C)) {
+ GameController.getInstance().setComplete(true);
+ GameController.getInstance().setPlayerCompletedLevel(false);
+ }
+
+
+ // Mouse results
+ tertiaryPressed = Gdx.input.isButtonPressed(Input.Buttons.LEFT);
+ crosshair.set(Gdx.input.getX(), Gdx.input.getY());
+ crosshair.scl(1 / scale.x, -1 / scale.y);
+ crosshair.y += bounds.height;
+ clampPosition(bounds);
}
//TODO: This is temporary code to add artificial delay to the syncing
delay = 0;
@@ -351,8 +466,50 @@ else if(Gdx.input.isKeyPressed(Keys.MINUS)){
delay = -.05f;
}
+ if(GameController.getInstance().getPlayerCompletedLevel()) {
+ GameController gc = GameController.getInstance();
+
+ //Press tab to go to the next level (only if level has been completed)
+ if (Gdx.input.isKeyPressed(Keys.TAB)) {
+ gc.exitScreen(1);
+ gc.setPlayerCompletedLevel(false);
+ gc.setCurrentLevelInt(gc.getCurrentLevelInt()+1);
+ }
+
+ //Switch between the texts nextLevel (0) and levelSelect (1)
+ if (Gdx.input.isKeyPressed(Keys.DOWN) || Gdx.input.isKeyPressed(Keys.S)) {
+ gc.setVictoryScreenItemSelected(1);
+ } else if (Gdx.input.isKeyPressed(Keys.UP) || Gdx.input.isKeyPressed(Keys.W)){
+ gc.setVictoryScreenItemSelected(0);
+ }
+
+ //Click enter/return once selection has been chosen
+ if(Gdx.input.isKeyPressed(Keys.ENTER)) {
+ gc.setPlayerCompletedLevel(false);
+ gc.setCurrentLevelInt(gc.getCurrentLevelInt()+1);
+
+ if(gc.getVictoryScreenItemSelected() == 0) {
+ //GO TO NEXT LEVEL
+ gc.exitScreen(1);
+ } else if(gc.getVictoryScreenItemSelected() == 1) {
+ //GO BACK TO LEVEL SELECT
+ gc.exitScreen(0);
+ }
+ }
+
+
+ }
+
+ //C = shortcut to complete the level
+ if (Gdx.input.isKeyPressed(Keys.C)) {
+ GameController.getInstance().setComplete(true);
+ GameController.getInstance().setPlayerCompletedLevel(false);
+ }
+
+
+
+
-
// Mouse results
tertiaryPressed = Gdx.input.isButtonPressed(Input.Buttons.LEFT);
crosshair.set(Gdx.input.getX(), Gdx.input.getY());
@@ -360,11 +517,11 @@ else if(Gdx.input.isKeyPressed(Keys.MINUS)){
crosshair.y += bounds.height;
clampPosition(bounds);
}
-
+
/**
* Clamp the cursor position so that it does not go outside the window
*
- * While this is not usually a problem with mouse control, this is critical
+ * While this is not usually a problem with mouse control, this is critical
* for the gamepad controls.
*/
private void clampPosition(Rectangle bounds) {
diff --git a/core/src/edu/cornell/gdiac/rabbeat/LoadingMode.java b/core/src/edu/cornell/gdiac/rabbeat/LoadingMode.java
index d5e333f0..0ccb92c1 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/LoadingMode.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/LoadingMode.java
@@ -265,7 +265,7 @@ private void update(float delta) {
* prefer this in lecture.
*/
private void draw() {
- canvas.begin();
+ canvas.begin(true);
canvas.draw(background, 0, 0);
if (playButton == null) {
drawProgress(canvas);
diff --git a/core/src/edu/cornell/gdiac/rabbeat/ObjectController.java b/core/src/edu/cornell/gdiac/rabbeat/ObjectController.java
index bf19af6c..63d167d0 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/ObjectController.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/ObjectController.java
@@ -1,15 +1,11 @@
package edu.cornell.gdiac.rabbeat;
-import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
-import com.badlogic.gdx.maps.Map;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.BodyDef;
-import com.badlogic.gdx.utils.Array;
-import com.badlogic.gdx.utils.Json;
import com.badlogic.gdx.utils.JsonValue;
import edu.cornell.gdiac.assets.AssetDirectory;
@@ -17,16 +13,27 @@
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
+import edu.cornell.gdiac.rabbeat.obstacles.enemies.BatEnemy;
import edu.cornell.gdiac.rabbeat.obstacles.enemies.BearEnemy;
import edu.cornell.gdiac.rabbeat.obstacles.enemies.BeeHive;
import edu.cornell.gdiac.rabbeat.obstacles.enemies.HedgehogEnemy;
import edu.cornell.gdiac.rabbeat.obstacles.platforms.MovingPlatform;
import edu.cornell.gdiac.rabbeat.obstacles.platforms.WeightedPlatform;
+import edu.cornell.gdiac.rabbeat.ui.GenreUI;
import edu.cornell.gdiac.util.PooledList;
import java.util.ArrayList;
import java.util.HashMap;
public class ObjectController {
+ /**
+ * The purpose of this class is to instantiate all {@link GameObject}s in our
+ * world and keep them in memory.
+ * When the world is loaded in from the json, all the objects are created here
+ * and placed into
+ * an object list. {@link GameController} will use this controller class to
+ * update the game logic of
+ * each GameObject in the game.
+ */
/** All the objects in the world. */
public PooledList objects = new PooledList<>();
/** All objects that are genre-dependent */
@@ -37,9 +44,11 @@ public class ObjectController {
/** Reference to the character avatar */
public Player player;
- /** Physics constants for initialization
- * TODO: constants has some relevant information for game controller and this class does not care
- * */
+ /**
+ * Physics constants for initialization
+ * TODO: constants has some relevant information for game controller and this
+ * class does not care
+ */
public JsonValue defaultConstants;
/** The Json data for the level, generated by Tiled */
public JsonValue levelJson;
@@ -56,6 +65,15 @@ public class ObjectController {
protected TextureRegion longLeft;
protected TextureRegion longMid;
protected TextureRegion longRight;
+ protected TextureRegion longLeftSquare;
+ protected TextureRegion longRightSquare;
+ protected TextureRegion longSingle;
+
+ protected TextureRegion laserTile;
+ /** Textures for laser stuff*/
+ protected TextureRegion laserMiddle;
+ protected TextureRegion laserTop;
+ protected TextureRegion laserBottom;
/** The texture for weighted platforms in Synth mode */
protected TextureRegion weightedSynth;
@@ -69,19 +87,93 @@ public class ObjectController {
/** The texture for bullets */
public TextureRegion bulletTexture;
+
+ /** The default texture for enemies */
+ private TextureRegion enemyDefaultTexture;
+ /** The texture for the bat enemy */
+ private TextureRegion batTexture;
+ /** The texture for the echo*/
+ public TextureRegion echoTexture;
+ /** The atlas for the echo animation*/
+ public TextureAtlas echoAtlas;
+ /** The echo animation*/
+ public Animation echoAnimation;
+ /** The texture for bees */
+ public TextureRegion beeTexture;
+ /** The texture for bees */
+ private TextureRegion bearTexture;
+ /** The texture for beehives */
+ private TextureRegion beehiveTexture;
+ /** The texture for hedgehogs */
+ private TextureRegion hedgehogTexture;
/** The texture for the exit condition */
+
+ /** The texture for the checkpoint */
+ private TextureRegion checkpointTexture;
+ /** The texture ofr the goal */
protected TextureRegion goalTile;
- /** The texture for the checkpoint when it is in default stage/has not been reached */
- protected TextureRegion checkpointDefault;
- /** The texture for the checkpoint when it is active has already been reached */
- protected TextureRegion checkpointActive;
+ /** The inactive atlas for a checkpoint */
+ protected TextureAtlas checkpointInactiveAtlas;
+ /** The inactive animation for a checkpoint */
+ protected Animation checkpointInactiveAnimation;
+ /** The active atlas for a checkpoint */
+ protected TextureAtlas checkpointActiveAtlas;
+ /** The active animation for a checkpoint */
+ protected Animation checkpointActiveAnimation;
+ /** The rise atlas for a checkpoint */
+ protected TextureAtlas checkpointRiseAtlas;
+ /** The rise animation for a checkpoint */
+ protected Animation checkpointRiseAnimation;
/** The texture for the background*/
public TextureRegion backgroundTexture;
- /** The texture for the background overlay*/
+
+ /** The texture for the next level text */
+ public TextureRegion nextLevelText;
+
+ /** The texture for the level select text */
+ public TextureRegion levelSelectText;
+
+ /** The texture for the victory logo */
+ public TextureRegion victoryLogo;
+
+ /** The texture for the background overlay */
public TextureRegion backgroundOverlayTexture;
- private TextureRegion enemyDefaultTexture;
+ /** The texture for tinting the pause screen overlay background */
+ public TextureRegion pauseWhiteOverlayTexture;
+
+ public TextureRegion exitLevelTexture;
+ public TextureRegion hoverLowerSoundTexture;
+ public TextureRegion hoverUpSoundTexture;
+ public TextureRegion indicatorStarTexture;
+ public TextureRegion musicTexture;
+ public TextureRegion overlayTexture;
+ public TextureRegion restartLevelTexture;
+ public TextureRegion resumeTexture;
+ public TextureRegion SFXTexture;
+ public TextureRegion unhoverLowerSoundTexture;
+ public TextureRegion unhoverUpSoundTexture;
+ public TextureRegion volumeBoxTexture;
+
+ /** The texture for the genre indicator in Synth mode */
+ private TextureRegion synthIndicatorTexture;
+ /** The texture for the genre indicator in Jazz mode */
+ private TextureRegion jazzIndicatorTexture;
+ /** The synth genre atlas for the genre indicator */
+ public TextureAtlas synthCDAtlas;
+ /** The synth animation for the genre indicator */
+ private Animation synthCDAnimation;
+ /** The jazz genre atlas for the genre indicator */
+ public TextureAtlas jazzCDAtlas;
+ /** The jazz animation for the genre indicator */
+ private Animation jazzCDAnimation;
+ /** The genre indicator UI */
+ public GenreUI genreIndicator;
+
+ public TextureRegion blackGradient;
private HashMap assets = new HashMap<>();
+ // Tilesets
+ private HashMap wallsTileset = new HashMap<>();
/** Reference to the goalDoor (for collision detection) */
public BoxGameObject goalDoor;
@@ -91,14 +183,14 @@ public class ObjectController {
public float[] firstCheckpoint = new float[2];
/** The player scale for synth */
- private float playerScale = 3/8f*2.5f;
+ private float playerScale = 1f;
private TextureRegion synthDefaultTexture;
private TextureRegion synthJazzTexture;
- // PLAYER ANIMATIONS
+ // PLAYER ANIMATIONS
- // SYNTH
+ // SYNTH
/** The synth genre idle atlas for the player */
public TextureAtlas synthIdleAtlas;
/** The synth genre idle animation for the player */
@@ -111,8 +203,16 @@ public class ObjectController {
public TextureAtlas synthJumpAtlas;
/** The synth genre jumping animation for the player */
public Animation synthJumpAnimation;
-
- // JAZZ
+ /** The synth genre fall atlas for the player */
+ public TextureAtlas synthFallAtlas;
+ /** The synth genre fall animation for the player */
+ public Animation synthFallAnimation;
+ /** The synth genre death atlas for the player */
+ public TextureAtlas synthDeathAtlas;
+ /** The synth genre death animation for the player */
+ public Animation synthDeathAnimation;
+
+ // JAZZ
/** The jazz genre idle atlas for the player */
public TextureAtlas jazzIdleAtlas;
/** The jazz genre idle animation for the player */
@@ -125,100 +225,192 @@ public class ObjectController {
public TextureAtlas jazzJumpAtlas;
/** The jazz genre jumping animation for the player */
public Animation jazzJumpAnimation;
-
- //ENEMY ANIMATIONS
+ /** The jazz genre fall atlas for the player */
+ public TextureAtlas jazzFallAtlas;
+ /** The jazz genre fall animation for the player */
+ public Animation jazzFallAnimation;
+ /** The jazz genre death atlas for the player */
+ public TextureAtlas jazzDeathAtlas;
+ /** The jazz genre death animation for the player */
+ public Animation jazzDeathAnimation;
+
+ // ENEMY ANIMATIONS
/** The idle atlas for the bear enemy */
public TextureAtlas bearIdleAtlas;
/** The idle animation for the bear enemy */
public Animation bearIdleAnimation;
- /** The idle atlas for the bat enemy */
- public TextureAtlas batIdleAtlas;
- /** The idle animation for the bat enemy */
- public Animation batIdleAnimation;
+ /** The idle atlas for jazz bullets */
+ public TextureAtlas bulletJazzAtlas;
+ /** The animation for jazz bullets */
+ public Animation bulletJazzAnimation;
+ /** The idle atlas for synth bullets */
+ public TextureAtlas bulletSynthAtlas;
+ /** The animation for synth bullets */
+ public Animation bulletSynthAnimation;
+ /** The attack atlas for the bear enemy */
+ public TextureAtlas bearAttackAtlas;
+ /** The attack animation for the bear enemy */
+ public Animation bearAttackAnimation;
+ /** The synth attack atlas for the bat enemy */
+ public TextureAtlas batAttackSynthAtlas;
+ /** The synth attack animation for the bat enemy */
+ public Animation batAttackSynthAnimation;
+ /** The jazz attack atlas for the bat enemy */
+ public TextureAtlas batAttackJazzAtlas;
+ /** The jazz attack animation for the bat enemy */
+ public Animation batAttackJazzAnimation;
/** The idle atlas for the bee enemy */
public TextureAtlas beeAttackAtlas;
/** The idle animation for the bee enemy */
public Animation beeAttackAnimation;
/** The idle atlas for the beehive */
- public TextureAtlas beehiveAtlas;
+ public TextureAtlas beehiveAttackAtlas;
/** The idle animation for the beehive */
- public Animation beehiveAnimation;
+ public Animation beehiveAttackAnimation;
/** The idle atlas for the hedgehog enemy */
public TextureAtlas hedgehogIdleAtlas;
/** The idle animation for the hedgehog enemy */
public Animation hedgehogIdleAnimation;
+ /** The attack atlas for the hedgehog enemy */
+ public TextureAtlas hedgehogAttackAtlas;
+ /** The attack animation for the hedgehog enemy */
+ public Animation hedgehogAttackAnimation;
private float synthSpeed;
private float jazzSpeed;
-
- //public BearEnemy enemy;
-
/** The enemy scale for the enemy */
- private float enemyScale = 3/8f*2;
+ private float enemyScale = 1f;
+
+ public int tileSize;
public ArrayList foreground = new ArrayList<>();
+ /** the default beat list is on the downbeats within 2 measures (beat 1 and beat 5)*/
+ public int[] defaultBeatList = { 1, 5 };
+ //public GameController gc = GameController.getInstance();
/**
* Gather the assets for this controller.
*
* This method extracts the asset variables from the given asset directory. It
* should only be called after the asset directory is completed.
*
- * @param directory Reference to global asset manager.
+ * @param directory Reference to global asset manager.
*/
public void gatherAssets(AssetDirectory directory) {
- levelJson = directory.getEntry("example", JsonValue.class);
+ levelJson = directory.getEntry(GameController.getInstance().getCurrentLevel(), JsonValue.class);
+ tileSize = levelJson.getInt("tileheight");
+
+ nextLevelText = new TextureRegion(directory.getEntry("ui:victory:nextLevelText",Texture.class));
+ levelSelectText = new TextureRegion(directory.getEntry("ui:victory:levelSelectText",Texture.class));
+ victoryLogo = new TextureRegion(directory.getEntry("ui:victory:victoryLogo",Texture.class));
backgroundTexture = new TextureRegion(directory.getEntry("backgrounds:test-bg",Texture.class));
backgroundOverlayTexture = new TextureRegion(directory.getEntry("backgrounds:overlay",Texture.class));
- enemyDefaultTexture = new TextureRegion(directory.getEntry("player:synth",Texture.class)); //CHANGE FOR ENEMY!
+ pauseWhiteOverlayTexture = new TextureRegion(directory.getEntry("backgrounds:pauseTint", Texture.class));
+ exitLevelTexture = new TextureRegion(directory.getEntry("ui:pause:exitLevel",Texture.class));
+ hoverLowerSoundTexture = new TextureRegion(directory.getEntry("ui:pause:hoverLowerSound",Texture.class));
+ hoverUpSoundTexture = new TextureRegion(directory.getEntry("ui:pause:hoverUpSound",Texture.class));
+ indicatorStarTexture = new TextureRegion(directory.getEntry("ui:pause:indicatorStar",Texture.class));
+ musicTexture = new TextureRegion(directory.getEntry("ui:pause:music",Texture.class));
+ overlayTexture = new TextureRegion(directory.getEntry("ui:pause:overlay",Texture.class));
+ restartLevelTexture = new TextureRegion(directory.getEntry("ui:pause:restartLevel",Texture.class));
+ resumeTexture = new TextureRegion(directory.getEntry("ui:pause:resume",Texture.class));
+ SFXTexture = new TextureRegion(directory.getEntry("ui:pause:SFX",Texture.class));
+ unhoverLowerSoundTexture = new TextureRegion(directory.getEntry("ui:pause:unhoverLowerSound",Texture.class));
+ unhoverUpSoundTexture = new TextureRegion(directory.getEntry("ui:pause:unhoverUpSound",Texture.class));
+ volumeBoxTexture = new TextureRegion(directory.getEntry("ui:pause:volumeBox",Texture.class));
- defaultConstants = directory.getEntry( "defaultConstants", JsonValue.class );
- synthSpeed = defaultConstants.get("player").get("max_speed").getFloat("synth");
+ enemyDefaultTexture = new TextureRegion(directory.getEntry("player:synth",Texture.class)); //CHANGE FOR ENEMY!
+ batTexture = new TextureRegion(directory.getEntry("enemies:bat", Texture.class));
+ beeTexture = new TextureRegion(directory.getEntry("enemies:bee", Texture.class));
+ bearTexture = new TextureRegion(directory.getEntry("enemies:bear", Texture.class));
+ beehiveTexture = new TextureRegion(directory.getEntry("enemies:beehive", Texture.class));
+ hedgehogTexture = new TextureRegion(directory.getEntry("enemies:hedgehog", Texture.class));
+
+ // Allocate genre indicator UI
+ synthIndicatorTexture = new TextureRegion(directory.getEntry("ui:synthIndicator", Texture.class));
+ jazzIndicatorTexture = new TextureRegion(directory.getEntry("ui:jazzIndicator", Texture.class));
+ synthCDAtlas = new TextureAtlas(Gdx.files.internal("ui/synthCD.atlas"));
+ synthCDAnimation = new Animation(1f, synthCDAtlas.findRegions("synthCD"), Animation.PlayMode.LOOP);
+ jazzCDAtlas = new TextureAtlas(Gdx.files.internal("ui/jazzCD.atlas"));
+ jazzCDAnimation = new Animation(1f, jazzCDAtlas.findRegions("jazzCD"), Animation.PlayMode.LOOP);
+
+ // Bullet Animations
+ bulletJazzAtlas = new TextureAtlas(Gdx.files.internal("enemies/jazzBullet.atlas"));
+ bulletJazzAnimation = new Animation(1f, bulletJazzAtlas.findRegions("jazzBullet"), Animation.PlayMode.LOOP);
+ bulletSynthAtlas = new TextureAtlas(Gdx.files.internal("enemies/synthBullet.atlas"));
+ bulletSynthAnimation = new Animation(1f, bulletSynthAtlas.findRegions("synthBullet"), Animation.PlayMode.LOOP);
+ blackGradient = new TextureRegion(directory.getEntry("ui:blackGradient", Texture.class));
+
+ defaultConstants = directory.getEntry("defaultConstants", JsonValue.class);
+ synthSpeed = defaultConstants.get("player").get("max_speed").getFloat("synth");
jazzSpeed = defaultConstants.get("player").get("max_speed").getFloat("jazz");
- synthDefaultTexture = new TextureRegion(directory.getEntry("player:synth",Texture.class));
- synthJazzTexture = new TextureRegion(directory.getEntry("player:synth-jazz",Texture.class));
+ synthDefaultTexture = new TextureRegion(directory.getEntry("player:synth", Texture.class));
+ synthJazzTexture = new TextureRegion(directory.getEntry("player:synth-jazz", Texture.class));
// Allocating player animations
- // Synth
- //Note: For animations, frame durations must be 1 for AnimationSync to work
+ // Synth
+ // Note: For animations, frame durations must be 1 for AnimationSync to work
synthIdleAtlas = new TextureAtlas(Gdx.files.internal("player/synthIdle.atlas"));
- synthIdleAnimation = new Animation(4/3f, synthIdleAtlas.findRegions("synthIdle"), Animation.PlayMode.LOOP);
+ synthIdleAnimation = new Animation(1f, synthIdleAtlas.findRegions("synthIdle"), Animation.PlayMode.LOOP);
synthWalkAtlas = new TextureAtlas(Gdx.files.internal("player/synthWalk.atlas"));
- synthWalkAnimation = new Animation(1, synthWalkAtlas.findRegions("synthWalk"), Animation.PlayMode.LOOP);
+ synthWalkAnimation = new Animation(1f, synthWalkAtlas.findRegions("synthWalk"), Animation.PlayMode.LOOP);
synthJumpAtlas = new TextureAtlas(Gdx.files.internal("player/synthJump.atlas"));
- synthJumpAnimation = new Animation(1, synthJumpAtlas.findRegions("synthJump"), Animation.PlayMode.NORMAL);
+ synthJumpAnimation = new Animation(1f, synthJumpAtlas.findRegions("synthJump"), Animation.PlayMode.NORMAL);
- // Jazz
+ synthFallAtlas = new TextureAtlas(Gdx.files.internal("player/synthFall.atlas"));
+ synthFallAnimation = new Animation(1f, synthFallAtlas.findRegions("synthFall"), Animation.PlayMode.LOOP);
+
+ synthDeathAtlas = new TextureAtlas(Gdx.files.internal("player/synthDeath.atlas"));
+ synthDeathAnimation = new Animation(1f, synthDeathAtlas.findRegions("synthDeath"), Animation.PlayMode.NORMAL);
+
+ // Jazz
jazzIdleAtlas = new TextureAtlas(Gdx.files.internal("player/jazzIdle.atlas"));
- jazzIdleAnimation = new Animation(4/3f, jazzIdleAtlas.findRegions("jazzIdle"), Animation.PlayMode.LOOP);
+ jazzIdleAnimation = new Animation(1f, jazzIdleAtlas.findRegions("jazzIdle"), Animation.PlayMode.LOOP);
jazzWalkAtlas = new TextureAtlas(Gdx.files.internal("player/jazzWalk.atlas"));
- jazzWalkAnimation = new Animation(1, jazzWalkAtlas.findRegions("jazzWalk"), Animation.PlayMode.LOOP);
+ jazzWalkAnimation = new Animation(1f, jazzWalkAtlas.findRegions("jazzWalk"), Animation.PlayMode.LOOP);
jazzJumpAtlas = new TextureAtlas(Gdx.files.internal("player/jazzJump.atlas"));
- jazzJumpAnimation = new Animation(1, jazzJumpAtlas.findRegions("jazzJump"), Animation.PlayMode.NORMAL);
+ jazzJumpAnimation = new Animation(1f, jazzJumpAtlas.findRegions("jazzJump"), Animation.PlayMode.NORMAL);
+
+ jazzFallAtlas = new TextureAtlas(Gdx.files.internal("player/jazzFall.atlas"));
+ jazzFallAnimation = new Animation(1f, jazzFallAtlas.findRegions("jazzFall"), Animation.PlayMode.LOOP);
+
+ jazzDeathAtlas = new TextureAtlas(Gdx.files.internal("player/jazzDeath.atlas"));
+ jazzDeathAnimation = new Animation(1f, jazzDeathAtlas.findRegions("jazzDeath"), Animation.PlayMode.NORMAL);
- // Allocating enemy animations
- // Bear
+ // Allocating enemy animations
+ // Bear
bearIdleAtlas = new TextureAtlas(Gdx.files.internal("enemies/bearIdle.atlas"));
- bearIdleAnimation = new Animation(1, bearIdleAtlas.findRegions("bearIdle"), Animation.PlayMode.LOOP);
+ bearIdleAnimation = new Animation(1f, bearIdleAtlas.findRegions("bearIdle"), Animation.PlayMode.LOOP);
+ bearAttackAtlas = new TextureAtlas(Gdx.files.internal("enemies/bearAttack.atlas"));
+ bearAttackAnimation = new Animation(1f, bearAttackAtlas.findRegions("bearAttack"), Animation.PlayMode.LOOP);
// Bat
- batIdleAtlas = new TextureAtlas(Gdx.files.internal("enemies/bearIdle.atlas"));
- batIdleAnimation = new Animation(1, bearIdleAtlas.findRegions("bearIdle"), Animation.PlayMode.LOOP);
+ batAttackJazzAtlas = new TextureAtlas(Gdx.files.internal("enemies/batAttackJazz.atlas"));
+ batAttackJazzAnimation = new Animation(1f, batAttackJazzAtlas.findRegions("batAttackJazz"), Animation.PlayMode.LOOP);
+ batAttackSynthAtlas = new TextureAtlas(Gdx.files.internal("enemies/batAttackSynth.atlas"));
+ batAttackSynthAnimation = new Animation(1f, batAttackSynthAtlas.findRegions("batAttackSynth"), Animation.PlayMode.LOOP);
+ echoAtlas = new TextureAtlas(Gdx.files.internal("atlas/echo.atlas"));
+ echoAnimation = new Animation(1f, echoAtlas.findRegions("echo"));
+ echoTexture = new TextureRegion(directory.getEntry("enemies:echoStill", Texture.class));
// Bee
beeAttackAtlas = new TextureAtlas(Gdx.files.internal("enemies/beeAttack.atlas"));
- beeAttackAnimation = new Animation(0.25f, beeAttackAtlas.findRegions("beeAttack"), Animation.PlayMode.LOOP);
+ beeAttackAnimation = new Animation(0.25f, beeAttackAtlas.findRegions("beeAttack"),
+ Animation.PlayMode.LOOP);
- beehiveAtlas = new TextureAtlas(Gdx.files.internal("enemies/beehive.atlas"));
- beehiveAnimation = new Animation(1, beehiveAtlas.findRegions("beehive"), Animation.PlayMode.LOOP);
- // Hedgehog
+ beehiveAttackAtlas = new TextureAtlas(Gdx.files.internal("enemies/beehiveAttack.atlas"));
+ beehiveAttackAnimation = new Animation(1, beehiveAttackAtlas.findRegions("beehiveAttack"),
+ Animation.PlayMode.LOOP);
+ // Hedgehog
hedgehogIdleAtlas = new TextureAtlas(Gdx.files.internal("enemies/bearIdle.atlas"));
- hedgehogIdleAnimation = new Animation(4/3f, bearIdleAtlas.findRegions("bearIdle"), Animation.PlayMode.LOOP);
+ hedgehogIdleAnimation = new Animation(5/3f, bearIdleAtlas.findRegions("bearIdle"), Animation.PlayMode.LOOP);
+ hedgehogAttackAtlas = new TextureAtlas(Gdx.files.internal("enemies/hedgehogAttack.atlas"));
+ hedgehogAttackAnimation = new Animation(1.5f, hedgehogAttackAtlas.findRegions("hedgehogAttack"), Animation.PlayMode.LOOP);
// Allocate the tiles
@@ -228,6 +420,13 @@ public void gatherAssets(AssetDirectory directory) {
longLeft = new TextureRegion(directory.getEntry("world:platforms:longPlatform:left", Texture.class ));
longMid = new TextureRegion(directory.getEntry( "world:platforms:longPlatform:mid", Texture.class ));
longRight = new TextureRegion(directory.getEntry( "world:platforms:longPlatform:right", Texture.class ));
+ longLeftSquare = new TextureRegion(directory.getEntry( "world:platforms:longPlatform:leftSquare", Texture.class ));
+ longRightSquare = new TextureRegion(directory.getEntry( "world:platforms:longPlatform:rightSquare", Texture.class ));
+ longSingle = new TextureRegion(directory.getEntry( "world:platforms:longPlatform:single", Texture.class ));
+ laserTile = new TextureRegion(directory.getEntry("world:laser", Texture.class));
+ laserMiddle = new TextureRegion(directory.getEntry("world:laserMiddle", Texture.class));
+ laserTop = new TextureRegion(directory.getEntry("world:laserTop", Texture.class));
+ laserBottom = new TextureRegion(directory.getEntry("world:laserBottom", Texture.class));
weightedSynth = new TextureRegion((directory.getEntry("world:platforms:weightedSynth", Texture.class)));
weightedJazz = new TextureRegion((directory.getEntry("world:platforms:weightedJazz", Texture.class)));
@@ -235,39 +434,75 @@ public void gatherAssets(AssetDirectory directory) {
movingSynth = new TextureRegion((directory.getEntry("world:platforms:movingSynth", Texture.class)));
movingJazz = new TextureRegion((directory.getEntry("world:platforms:movingJazz", Texture.class)));
- assets.put("bearpod1", new TextureRegion(directory.getEntry( "world:pods:bearpod1", Texture.class )));
- assets.put("bearpod2", new TextureRegion(directory.getEntry( "world:pods:bearpod2", Texture.class )));
- assets.put("bgpod1", new TextureRegion(directory.getEntry( "world:pods:bgpod1", Texture.class )));
- assets.put("bgpod2", new TextureRegion(directory.getEntry( "world:pods:bgpod2", Texture.class )));
- assets.put("dolpod1", new TextureRegion(directory.getEntry( "world:pods:dolpod1", Texture.class )));
- assets.put("dolpod2", new TextureRegion(directory.getEntry( "world:pods:dolpod2", Texture.class )));
- assets.put("octpod1", new TextureRegion(directory.getEntry( "world:pods:octpod1", Texture.class )));
- assets.put("emptypod4", new TextureRegion(directory.getEntry( "world:pods:emptypod4", Texture.class )));
- assets.put("wolfpod1", new TextureRegion(directory.getEntry( "world:pods:wolfpod1", Texture.class )));
- assets.put("shelf1",new TextureRegion(directory.getEntry( "world:shelves:shelf1", Texture.class )));
- assets.put("shelf2",new TextureRegion(directory.getEntry( "world:shelves:shelf2", Texture.class )));
- assets.put("shelf3",new TextureRegion(directory.getEntry( "world:shelves:shelf3", Texture.class )));
- assets.put("shelf4",new TextureRegion(directory.getEntry( "world:shelves:shelf4", Texture.class )));
- assets.put("shelf5",new TextureRegion(directory.getEntry( "world:shelves:shelf5", Texture.class )));
- assets.put("light", new TextureRegion(directory.getEntry( "world:other:light", Texture.class )));
- assets.put("pipeposter", new TextureRegion(directory.getEntry( "world:pipes:pipeposter", Texture.class )));
- assets.put("piperight", new TextureRegion(directory.getEntry( "world:pipes:piperight", Texture.class )));
- assets.put("piperightskinny", new TextureRegion(directory.getEntry( "world:pipes:piperightskinny", Texture.class )));
- assets.put("pipestraight", new TextureRegion(directory.getEntry( "world:pipes:pipestraight", Texture.class )));
- assets.put("pipestraightskinny", new TextureRegion(directory.getEntry( "world:pipes:pipestraightskinny", Texture.class )));
- assets.put("pipeleftskinny", new TextureRegion(directory.getEntry( "world:pipes:pipeleftskinny", Texture.class )));
- assets.put("bgpipe", new TextureRegion(directory.getEntry( "world:pipes:bgpipe", Texture.class )));
- assets.put("bigpipe", new TextureRegion(directory.getEntry( "world:pipes:bigpipe", Texture.class )));
- assets.put("bigpipetv", new TextureRegion(directory.getEntry( "world:pipes:bigpipetv", Texture.class )));
- assets.put("bigwire", new TextureRegion(directory.getEntry( "world:wires:bigwire", Texture.class )));
- assets.put("wires1", new TextureRegion(directory.getEntry( "world:wires:wires1", Texture.class )));
- assets.put("wires2", new TextureRegion(directory.getEntry( "world:wires:wires2", Texture.class )));
+ assets.put("bearpod1", new TextureRegion(directory.getEntry("world:pods:bearpod1", Texture.class)));
+ assets.put("bearpod2", new TextureRegion(directory.getEntry("world:pods:bearpod2", Texture.class)));
+ assets.put("bgpod1", new TextureRegion(directory.getEntry("world:pods:bgpod1", Texture.class)));
+ assets.put("bgpod2", new TextureRegion(directory.getEntry("world:pods:bgpod2", Texture.class)));
+ assets.put("dolpod1", new TextureRegion(directory.getEntry("world:pods:dolpod1", Texture.class)));
+ assets.put("dolpod2", new TextureRegion(directory.getEntry("world:pods:dolpod2", Texture.class)));
+ assets.put("octpod1", new TextureRegion(directory.getEntry("world:pods:octpod1", Texture.class)));
+ assets.put("emptypod4", new TextureRegion(directory.getEntry("world:pods:emptypod4", Texture.class)));
+ assets.put("wolfpod1", new TextureRegion(directory.getEntry("world:pods:wolfpod1", Texture.class)));
+ assets.put("shelf1", new TextureRegion(directory.getEntry("world:shelves:shelf1", Texture.class)));
+ assets.put("shelf2", new TextureRegion(directory.getEntry("world:shelves:shelf2", Texture.class)));
+ assets.put("shelf3", new TextureRegion(directory.getEntry("world:shelves:shelf3", Texture.class)));
+ assets.put("shelf4", new TextureRegion(directory.getEntry("world:shelves:shelf4", Texture.class)));
+ assets.put("shelf5", new TextureRegion(directory.getEntry("world:shelves:shelf5", Texture.class)));
+ assets.put("light", new TextureRegion(directory.getEntry("world:other:light", Texture.class)));
+ assets.put("pipeposter", new TextureRegion(directory.getEntry("world:pipes:pipeposter", Texture.class)));
+ assets.put("piperight", new TextureRegion(directory.getEntry("world:pipes:piperight", Texture.class)));
+ assets.put("piperightskinny",
+ new TextureRegion(directory.getEntry("world:pipes:piperightskinny", Texture.class)));
+ assets.put("pipestraight", new TextureRegion(directory.getEntry("world:pipes:pipestraight", Texture.class)));
+ assets.put("pipestraightskinny",
+ new TextureRegion(directory.getEntry("world:pipes:pipestraightskinny", Texture.class)));
+ assets.put("pipeleftskinny",
+ new TextureRegion(directory.getEntry("world:pipes:pipeleftskinny", Texture.class)));
+ assets.put("bgpipe", new TextureRegion(directory.getEntry("world:pipes:bgpipe", Texture.class)));
+ assets.put("bigpipe", new TextureRegion(directory.getEntry("world:pipes:bigpipe", Texture.class)));
+ assets.put("bigpipetv", new TextureRegion(directory.getEntry("world:pipes:bigpipetv", Texture.class)));
+ assets.put("bigwire", new TextureRegion(directory.getEntry("world:wires:bigwire", Texture.class)));
+ assets.put("wires1", new TextureRegion(directory.getEntry("world:wires:wires1", Texture.class)));
+ assets.put("wires2", new TextureRegion(directory.getEntry("world:wires:wires2", Texture.class)));
+ assets.put("emoji_0", new TextureRegion(directory.getEntry("world:graffiti:emoji_0", Texture.class)));
+ assets.put("emoji_1", new TextureRegion(directory.getEntry("world:graffiti:emoji_1", Texture.class)));
+ assets.put("emoji_2", new TextureRegion(directory.getEntry("world:graffiti:emoji_2", Texture.class)));
+ assets.put("graffiti_0", new TextureRegion(directory.getEntry("world:graffiti:graffiti_0", Texture.class)));
+ assets.put("graffiti_1", new TextureRegion(directory.getEntry("world:graffiti:graffiti_1", Texture.class)));
+ assets.put("graffiti_2", new TextureRegion(directory.getEntry("world:graffiti:graffiti_2", Texture.class)));
+ assets.put("graffiti_3", new TextureRegion(directory.getEntry("world:graffiti:graffiti_3", Texture.class)));
+ assets.put("caution_0", new TextureRegion(directory.getEntry("world:graffiti:caution_0", Texture.class)));
+ assets.put("tv", new TextureRegion(directory.getEntry("world:other:tv", Texture.class)));
+ assets.put("cam_0", new TextureRegion(directory.getEntry("world:other:tv", Texture.class)));
+ assets.put("cam_1", new TextureRegion(directory.getEntry("world:other:tv", Texture.class)));
+ assets.put("cam_2", new TextureRegion(directory.getEntry("world:other:tv", Texture.class)));
+ assets.put("ceilingCamera", new TextureRegion(directory.getEntry("world:other:ceilingCamera", Texture.class)));
+
+ wallsTileset.put(0, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:0", Texture.class)));
+ wallsTileset.put(1, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:1", Texture.class)));
+ wallsTileset.put(2, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:2", Texture.class)));
+ wallsTileset.put(3, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:3", Texture.class)));
+ wallsTileset.put(4, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:4", Texture.class)));
+ wallsTileset.put(5, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:5", Texture.class)));
+ wallsTileset.put(6, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:6", Texture.class)));
+ wallsTileset.put(7, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:7", Texture.class)));
+ wallsTileset.put(8, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:8", Texture.class)));
+ wallsTileset.put(9, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:9", Texture.class)));
+ wallsTileset.put(10, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:10", Texture.class)));
+ wallsTileset.put(11, new TextureRegion(directory.getEntry("world:tilesets:wallsTileset:11", Texture.class)));
bulletTexture = new TextureRegion(directory.getEntry("world:bullet", Texture.class));
+ checkpointTexture = new TextureRegion(directory.getEntry("world:checkpoints:checkpointInactive", Texture.class));
goalTile = new TextureRegion(directory.getEntry( "world:goal", Texture.class ));
- checkpointDefault = new TextureRegion(directory.getEntry( "checkpoint:checkDefault", Texture.class ));
- checkpointActive = new TextureRegion(directory.getEntry( "checkpoint:checkActive", Texture.class ));
displayFont = directory.getEntry( "fonts:retro" ,BitmapFont.class);
+
+ // Checkpoint
+ checkpointInactiveAtlas = new TextureAtlas(Gdx.files.internal("world/checkpoints/checkpointInactive.atlas"));
+ checkpointInactiveAnimation = new Animation(1f, checkpointInactiveAtlas.findRegions("checkpointInactive"), Animation.PlayMode.LOOP);
+ checkpointActiveAtlas = new TextureAtlas(Gdx.files.internal("world/checkpoints/checkpointActive.atlas"));
+ checkpointActiveAnimation = new Animation(1f, checkpointActiveAtlas.findRegions("checkpointActive"), Animation.PlayMode.LOOP);
+ checkpointRiseAtlas = new TextureAtlas(Gdx.files.internal("world/checkpoints/checkpointRise.atlas"));
+ checkpointRiseAnimation = new Animation(1f, checkpointRiseAtlas.findRegions("checkpointRise"), Animation.PlayMode.LOOP);
}
/**
@@ -275,161 +510,233 @@ public void gatherAssets(AssetDirectory directory) {
*
* @param scale The draw scale
*/
- public void populateObjects(Vector2 scale){
+ public void populateObjects(Vector2 scale) {
+ // Populate in-game UI elements
+ createGUI();
+
if (levelJson.has("layers")) {
+
+ // Get level height
int levelHeight = levelJson.getInt("height");
- int tileSize = levelJson.getInt("tileheight");
+
+ // Get first gid
+ int firstGid = 0;
+ for (JsonValue tileset : levelJson.get("tilesets")){
+ if (tileset.getString("source").contains("walls.tsx")){
+ firstGid = tileset.getInt("firstgid");
+ }
+ }
+
+ // Process layers
for (JsonValue layer : levelJson.get("layers")) {
String layerName = layer.getString("name", "");
- switch (layerName){
+ switch (layerName) {
case "background":
- //TODO: change background image depending on tiled info – may do this when we have more levels
+ // TODO: change background image depending on tiled info – may do this when we
+ // have more levels
break;
case "walls":
int[] data = layer.get("data").asIntArray();
int width = layer.getInt("width");
int height = layer.getInt("height");
- for (int i=0; i positionNodes = new HashMap<>();
- HashMap mpSpeed = new HashMap<>();
+ HashMap mpWait = new HashMap<>();
+ HashMap mpMove = new HashMap<>();
+ HashMap dimensions = new HashMap<>();
for (JsonValue mp : layer.get("objects")) {
int num = 0;
int pos = 0;
- float speed = 0;
- int totalPos = 1; //number of positions in this moving platform
- for (JsonValue prop : mp.get("properties")){
- switch(prop.getString("name")){
+ int wait = 1;
+ int move = 0;
+ int totalPos = 1; // number of positions in this moving platform
+ for (JsonValue prop : mp.get("properties")) {
+ switch (prop.getString("name")) {
case "num":
num = prop.getInt("value");
break;
case "pos":
pos = prop.getInt("value");
break;
- case "speed":
- speed = prop.getFloat("value");
+ case "waitTime":
+ wait = prop.getInt("value");
+ break;
+ case "moveTime":
+ move = prop.getInt("value");
break;
case "totalPos":
totalPos = prop.getInt("value");
break;
}
}
- // Store coordinates
- final int numOfNodes = totalPos; // need to be final to be used in computeIfAbsent
+ // Store coordinates
+ final int numOfNodes = totalPos; // need to be final to be used in computeIfAbsent
positionNodes.computeIfAbsent(num, key -> new Vector2[numOfNodes]);
Vector2 coord = new Vector2(mp.getFloat("x"), mp.getFloat("y"));
+ Vector2 dim = new Vector2(mp.getFloat("width"), mp.getFloat("height"));
positionNodes.get(num)[pos] = coord;
- // Store speed
- mpSpeed.put(num, speed);
+ // Store nodewaitTime
+ mpWait.put(num, wait);
+ // store Movespeed
+ mpMove.put(num, move);
+ // Store dimensions
+ dimensions.put(num, dim);
}
// Now actually create moving platforms
for (int i=0; i 0){
+ if (layer.get("objects").size > 0) {
JsonValue player = layer.get("objects").get(0);
float x = player.getInt("x");
float y = player.getInt("y");
- createPlayer(scale, x, y, levelHeight, tileSize);
+ Vector2 dim = new Vector2(player.getFloat("width"), player.getFloat("height"));
+ createPlayer(scale, x, y, dim, levelHeight, tileSize);
}
break;
case "enemies":
+ // TODO: Read the beatlist actions from Tiled
for (JsonValue enemy : layer.get("objects")) {
String enemyType = enemy.getString("type");
- switch (enemyType){
- case "bear":
+ String beatListString = "";
+ for (JsonValue prop : enemy.get("properties")) {
+ if (prop.getString("name").equals("beatList")) {
+ beatListString = prop.getString("value");
+ }
+ }
+ switch (enemyType) {
+ case "Bear":
float x = enemy.getFloat("x");
float y = enemy.getFloat("y");
- createEnemyBear(scale, x, y, levelHeight, tileSize);
+ Vector2 dim = new Vector2(enemy.getFloat("width"), enemy.getFloat("height"));
+ createEnemyBear(scale, x, y, dim, levelHeight, tileSize, convertTiledbeatList(beatListString));
break;
- case "beehive":
+ case "Beehive":
x = enemy.getFloat("x");
y = enemy.getFloat("y");
- createEnemyBeehive(scale, x, y, levelHeight, tileSize);
+ dim = new Vector2(enemy.getFloat("width"), enemy.getFloat("height"));
+ createEnemyBeehive(scale, x, y, dim, levelHeight, tileSize, convertTiledbeatList(beatListString));
break;
- case "hedgehog":
+ case "Hedgehog":
x = enemy.getFloat("x");
y = enemy.getFloat("y");
+ dim = new Vector2(enemy.getFloat("width"), enemy.getFloat("height"));
int rollingDistance = 0;
- for (JsonValue prop : enemy.get("properties")){
- if(prop.getString("name").equals("rollingDistance")){
+ for (JsonValue prop : enemy.get("properties")) {
+ if (prop.getString("name").equals("rollingDistance")) {
rollingDistance = prop.getInt("value");
}
}
- createEnemyHedgehog(scale, x, y, rollingDistance, levelHeight, tileSize);
+ createEnemyHedgehog(scale, x, y, dim, rollingDistance, levelHeight, tileSize, convertTiledbeatList(beatListString));
break;
- case "bat":
+ case "Bat":
+ x = enemy.getFloat("x");
+ y = enemy.getFloat("y");
+ dim = new Vector2(enemy.getFloat("width"), enemy.getFloat("height"));
+ createEnemyBat(scale, x, y, dim, levelHeight, tileSize,
+ convertTiledbeatList(beatListString));
break;
}
}
@@ -438,42 +745,39 @@ public void populateObjects(Vector2 scale){
for (JsonValue checkpoint : layer.get("objects")) {
float x = checkpoint.getFloat("x");
float y = checkpoint.getFloat("y");
+ Vector2 dim = new Vector2(checkpoint.getFloat("width"), checkpoint.getFloat("height"));
int id = 0;
- for (JsonValue prop : checkpoint.get("properties")){
+ for (JsonValue prop : checkpoint.get("properties")) {
if (prop.getString("name").equals("num")) {
id = prop.getInt("value");
}
}
- createCheckpoint(scale, x, y, id, levelHeight, tileSize);
+ createCheckpoint(scale, x, y, dim, id, levelHeight, tileSize);
}
break;
case "goal":
- if (layer.get("objects").size > 0){
+ if (layer.get("objects").size > 0) {
JsonValue goal = layer.get("objects").get(0);
float x = goal.getInt("x");
float y = goal.getInt("y");
- createGoal(scale, x, y, levelHeight, tileSize);
+ Vector2 dim = new Vector2(goal.getFloat("width"), goal.getFloat("height"));
+ createGoal(scale, x, y, dim, levelHeight, tileSize);
}
break;
case "foregroundArt":
for (JsonValue a : layer.get("objects")) {
float x = a.getFloat("x");
float y = a.getFloat("y");
- createGroundArt(scale, a.getString("type"), x, y, levelHeight, tileSize, "foreground");
+ Vector2 dim = new Vector2(a.getFloat("width"), a.getFloat("height"));
+ createGroundArt(scale, a.getString("type"), x, y, dim, levelHeight, tileSize, "foreground");
}
break;
case "backgroundArt":
for (JsonValue a : layer.get("objects")) {
float x = a.getFloat("x");
float y = a.getFloat("y");
- createGroundArt(scale, a.getString("type"), x, y, levelHeight, tileSize, "background");
- }
- break;
- case "hangingArt":
- for (JsonValue a : layer.get("objects")) {
- float x = a.getFloat("x");
- float y = a.getFloat("y");
- createHangingArt(scale, a.getString("type"), x, y, levelHeight, tileSize);
+ Vector2 dim = new Vector2(a.getFloat("width"), a.getFloat("height"));
+ createGroundArt(scale, a.getString("type"), x, y, dim, levelHeight, tileSize, "background");
}
break;
}
@@ -485,41 +789,62 @@ public void populateObjects(Vector2 scale){
/**
* Convert Tiled coordinates to world coordinates.
*
- * @param x The x Tiled coordinate.
- * @param y The y Tiled coordinate.
+ * @param x The x Tiled coordinate.
+ * @param y The y Tiled coordinate.
* @param levelHeight The height of the screen (in number of tiles).
- * @param tileSize The size of the tiles (in pixels).
- * @return A Vector2 object where the x and y attributes are the converted world coordinates.
+ * @param tileSize The size of the tiles (in pixels).
+ * @return A Vector2 object where the x and y attributes are the converted world
+ * coordinates.
+ */
+ private Vector2 convertTiledCoord(float x, float y, float width, float height, int levelHeight, int tileSize){
+ x = x / tileSize;
+ y = levelHeight - y / tileSize;
+ x = x + (width/(tileSize*2));
+ y = y + (height/ (tileSize*2));
+ return(new Vector2(x, y));
+ }
+
+ /**
+ * Converts Tiled beat list String into an int[] value
+ * @param beatListString the string representation of the beat list from Tiled
+ * @return
*/
- private Vector2 convertTiledCoord(float x, float y, int levelHeight, int tileSize){
- x += tileSize;
- return(new Vector2(x / tileSize, levelHeight - y / tileSize));
+ private int[] convertTiledbeatList(String beatListString){
+ int listLen = beatListString.length();
+ if(listLen == 0){
+ return defaultBeatList;
+ }
+ int[] result = new int[listLen];
+ for (int i = 0; i < beatListString.length(); i++) {
+ result[i] = Integer.parseInt(beatListString.substring(i, i+1));
+ }
+ return result;
}
+
/**
* Create a checkpoint
*/
- private void createCheckpoint(Vector2 scale, float x, float y, int id, int levelHeight, int tileSize) {
+ private void createCheckpoint(Vector2 scale, float x, float y, Vector2 dimensions, int id, int levelHeight, int tileSize) {
// Adjust and Convert coordinates to world coordinates
- y -= checkpointDefault.getRegionHeight()/2.5;
- Vector2 convertedCoord = convertTiledCoord(x, y, levelHeight, tileSize);
+ Vector2 convertedCoord = convertTiledCoord(x, y, dimensions.x, dimensions.y, levelHeight, tileSize);
- if (id == 0){
+ if (id == 0) {
// Set first checkpoint as spawn point
firstCheckpoint[0] = convertedCoord.x;
firstCheckpoint[1] = convertedCoord.y;
}
- float cWidth = checkpointDefault.getRegionWidth()/scale.x;
- float cHeight = checkpointDefault.getRegionHeight()/scale.y;
+ float cWidth = dimensions.x/scale.x;
+ float cHeight = dimensions.y/scale.y;
JsonValue defaults = defaultConstants.get("defaults");
- Checkpoint obj = new Checkpoint(id, checkpointActive, convertedCoord.x, convertedCoord.y, cWidth, cHeight);
+ Checkpoint obj = new Checkpoint(id, checkpointInactiveAnimation, checkpointActiveAnimation, checkpointRiseAnimation, convertedCoord.x, convertedCoord.y, cWidth, cHeight);
obj.setBodyType(BodyDef.BodyType.StaticBody);
obj.setDensity(defaults.getFloat("density", 0.0f));
obj.setFriction(defaults.getFloat("friction", 1.0f));
obj.setRestitution(defaults.getFloat("restitution", 0.0f));
obj.setSensor(true);
obj.setDrawScale(scale);
- obj.setTexture(checkpointDefault);
+ obj.setTexture(checkpointTexture);
GameController.getInstance().instantiate(obj);
checkpoints.add(obj);
}
@@ -529,90 +854,130 @@ private void createCheckpoint(Vector2 scale, float x, float y, int id, int level
*
* @param scale Vector 2 scale used to draw
*/
- public void setFirstCheckpointAsSpawn(Vector2 scale){
+ public void setFirstCheckpointAsSpawn(Vector2 scale) {
GameController.getInstance().setSpawn(new Vector2(firstCheckpoint[0], firstCheckpoint[1]));
}
/**
* Create wall tiles
+ *
* @param scale Scale to draw
- * @param x x coordinate (world coordinates) of tile
- * @param y y coordinate (world coordinates) of tile
+ * @param x x coordinate (world coordinates) of tile
+ * @param y y coordinate (world coordinates) of tile
*/
- private void createWall(Vector2 scale, float x, float y){
+ private void createWall(Vector2 scale, float x, float y, int tileId, int tileSize){
+ // Set texture
+ TextureRegion textureRegion = wallsTileset.get(tileId);
+
String wname = "wall";
JsonValue defaults = defaultConstants.get("defaults");
BoxGameObject obj;
- float dwidth = blackTile.getRegionWidth()/scale.x;
- float dheight = blackTile.getRegionHeight()/scale.y;
- obj = new BoxGameObject(x, y, dwidth, dheight);
+ float dwidth = textureRegion.getRegionWidth()/scale.x;
+ float dheight = textureRegion.getRegionHeight()/scale.y;
+
+ //Adjust coordinate to be center of tile
+ float convertedX = x + ((float) textureRegion.getRegionWidth()/(tileSize*2));
+ float convertedY = y + ((float) textureRegion.getRegionHeight()/(tileSize*2));
+
+ obj = new BoxGameObject(convertedX, convertedY, dwidth, dheight);
obj.setBodyType(BodyDef.BodyType.StaticBody);
- obj.setDensity(defaults.getFloat( "density", 0.0f ));
- obj.setFriction(defaults.getFloat( "friction", 0.0f ));
- obj.setRestitution(defaults.getFloat( "restitution", 0.0f ));
+ obj.setDensity(defaults.getFloat("density", 0.0f));
+ obj.setFriction(defaults.getFloat("friction", 0.0f));
+ obj.setRestitution(defaults.getFloat("restitution", 0.0f));
obj.setDrawScale(scale);
- obj.setTexture(blackTile);
+ obj.setTexture(textureRegion);
obj.setName(wname);
GameController.getInstance().instantiate(obj);
}
+
/**
* Create a platform.
*
- * @param scale The Vector2 draw scale
- * @param align A string used to determine the alignment (left, mid, right)
- * @param x x coordinate (pixels) for the platform
- * @param y y coordinate (pixels) for the platform
+ * @param scale The Vector2 draw scale
+ * @param align A string used to determine the alignment (left, mid,
+ * right)
+ * @param x x coordinate (pixels) for the platform
+ * @param y y coordinate (pixels) for the platform
* @param levelHeight Height of level in number of tiles
- * @param tileSize Height of tile in pixels
+ * @param tileSize Height of tile in pixels
*/
- private void createPlatform(Vector2 scale, String align, float x, float y, int levelHeight, int tileSize){
+ private void createPlatform(Vector2 scale, String align, float x, float y, Vector2 dimensions, int levelHeight, int tileSize, boolean lethal){
TextureRegion textureRegion;
- switch(align){
- default:
- textureRegion = longMid;
- break;
- case "mid":
- textureRegion = longMid;
- break;
+ switch (align) {
case "left":
textureRegion = longLeft;
break;
case "right":
textureRegion = longRight;
break;
+ case "mid":
+ textureRegion = longMid;
+ break;
+ case "leftSquare":
+ textureRegion = longLeftSquare;
+ break;
+ case "rightSquare":
+ textureRegion = longRightSquare;
+ break;
+ case "single":
+ textureRegion = longSingle;
+ break;
+ default:
+ textureRegion = platformTile;
}
- // Adjust coordinates + Convert coordinates to world coordinates
- y -= textureRegion.getRegionHeight()/2-4;
- Vector2 convertedCoord = convertTiledCoord(x, y, levelHeight, tileSize);
+ if (lethal){
+ if (align.equals("vertical") || align.equals("middle")){
+ textureRegion = laserMiddle;
+ }
+ else if (align.equals("top")){
+ textureRegion = laserTop;
+ }
+ else if (align.equals("bottom")){
+ textureRegion = laserBottom;
+ }
+ else{
+ textureRegion = laserTile;
+ }
+ }
+ // Convert coordinates to world coordinates
+ Vector2 convertedCoord = convertTiledCoord(x, y, dimensions.x, dimensions.y, levelHeight, tileSize);
convertedCoord.set(convertedCoord.x, convertedCoord.y);
JsonValue defaults = defaultConstants.get("defaults");
- float dwidth = textureRegion.getRegionWidth()/scale.x;
- float dheight = textureRegion.getRegionHeight()/scale.y;
+ float dwidth = textureRegion.getRegionWidth() / scale.x;
+ float dheight = textureRegion.getRegionHeight() / scale.y;
BoxGameObject platform;
platform = new BoxGameObject(convertedCoord.x, convertedCoord.y, dwidth, dheight);
platform.setBodyType(BodyDef.BodyType.StaticBody);
- platform.setDensity(defaults.getFloat( "density", 0.0f ));
- platform.setFriction(defaults.getFloat( "friction", 0.0f ));
- platform.setRestitution(defaults.getFloat( "restitution", 0.0f ));
+ platform.setDensity(defaults.getFloat("density", 0.0f));
+ platform.setFriction(defaults.getFloat("friction", 0.0f));
+ platform.setRestitution(defaults.getFloat("restitution", 0.0f));
platform.setDrawScale(scale);
platform.setTexture(textureRegion);
+ if (lethal){
+ platform.setType(Type.LETHAL);
+
+ }
+ else{
+ platform.setType(Type.NONE);
+ }
GameController.getInstance().instantiate(platform);
}
/**
* Create platform art which is not interact-able/collide-able with players.
*
- * @param scale The Vector2 draw scale
- * @param type A string used to determine the texture, either "default", or "radio"
- * @param x x coordinate (pixels) for the platform art
- * @param y y coordinate (pixels) for the platform art
+ * @param scale The Vector2 draw scale
+ * @param type A string used to determine the texture, either "default",
+ * or "radio"
+ * @param x x coordinate (pixels) for the platform art
+ * @param y y coordinate (pixels) for the platform art
* @param levelHeight Height of level in number of tiles
- * @param tileSize Height of tile in pixels
+ * @param tileSize Height of tile in pixels
*/
- private void createPlatformArt(Vector2 scale, String type, float x, float y, int levelHeight, int tileSize){
+ private void createPlatformArt(Vector2 scale, String type, float x, float y, Vector2 dimensions, int levelHeight, int tileSize){
TextureRegion textureRegion;
- switch(type){
+ switch (type) {
default:
textureRegion = platformTileArt;
break;
@@ -620,9 +985,8 @@ private void createPlatformArt(Vector2 scale, String type, float x, float y, int
textureRegion = platformTileArt;
break;
}
- // Adjust coordinates + Convert coordinates to world coordinates
- y -= textureRegion.getRegionHeight()/2;
- Vector2 convertedCoord = convertTiledCoord(x, y, levelHeight, tileSize);
+ // Convert coordinates to world coordinates
+ Vector2 convertedCoord = convertTiledCoord(x, y, dimensions.x, dimensions.y, levelHeight, tileSize);
convertedCoord.set(convertedCoord.x, convertedCoord.y);
ArtObject platformArt = new ArtObject(textureRegion, convertedCoord.x, convertedCoord.y);
@@ -634,55 +998,56 @@ private void createPlatformArt(Vector2 scale, String type, float x, float y, int
/**
* Create a weighted platform.
*
- * @param scale The Vector2 draw scale
- * @param synthCoord A float array which holds the weighted platform's x and y coordinates in synth mode
- * @param jazzCoord A float array which holds the weighted platform's x and y coordinates in jazz mode
- * @param speed The speed of the weighted platform
+ * @param scale The Vector2 draw scale
+ * @param synthCoord A float array which holds the weighted platform's x and y
+ * coordinates in synth mode
+ * @param jazzCoord A float array which holds the weighted platform's x and y
+ * coordinates in jazz mode
+ * @param intervals The speed of the weighted platform
* @param levelHeight Height of level in number of tiles
- * @param tileSize Height of tile in pixels
+ * @param tileSize Height of tile in pixels
*/
- private void createWeightedPlatform(Vector2 scale, float[] synthCoord, float[] jazzCoord, float speed, int levelHeight, int tileSize){
+ private void createWeightedPlatform(Vector2 scale, float[] synthCoord, float[] jazzCoord, int platformIntervals, int waitTime, int moveTime, Vector2 dimensions, int levelHeight, int tileSize){
// Adjust coordinates + Convert coordinates to world coordinates
- synthCoord[1] -= weightedSynth.getRegionHeight()/2-4;
- Vector2 convertedSynthCoord = convertTiledCoord(synthCoord[0], synthCoord[1], levelHeight, tileSize);
- convertedSynthCoord.set(convertedSynthCoord.x+1, convertedSynthCoord.y);
- jazzCoord[1] -= weightedSynth.getRegionHeight()/2-4;
- Vector2 convertedJazzCoord = convertTiledCoord(jazzCoord[0], jazzCoord[1], levelHeight, tileSize);
- convertedJazzCoord.set(convertedJazzCoord.x+1, convertedJazzCoord.y);
+// synthCoord[1] -= weightedSynth.getRegionHeight()/2-4;
+ Vector2 convertedSynthCoord = convertTiledCoord(synthCoord[0], synthCoord[1], dimensions.x, dimensions.y, levelHeight, tileSize);
+ convertedSynthCoord.set(convertedSynthCoord.x, convertedSynthCoord.y);
+// jazzCoord[1] -= weightedSynth.getRegionHeight()/2-4;
+ Vector2 convertedJazzCoord = convertTiledCoord(jazzCoord[0], jazzCoord[1], dimensions.x, dimensions.y, levelHeight, tileSize);
+ convertedJazzCoord.set(convertedJazzCoord.x, convertedJazzCoord.y);
JsonValue defaults = defaultConstants.get("defaults");
- float dwidth = weightedSynth.getRegionWidth()/scale.x;
- float dheight = weightedSynth.getRegionHeight()/scale.y;
+ float dwidth = weightedSynth.getRegionWidth() / scale.x;
+ float dheight = weightedSynth.getRegionHeight() / scale.y;
WeightedPlatform weightedPlatform;
weightedPlatform = new WeightedPlatform(dwidth, dheight,
- new float[] {convertedSynthCoord.x, convertedSynthCoord.y},
- new float[] {convertedJazzCoord.x, convertedJazzCoord.y},
- speed,
+ new float[] { convertedSynthCoord.x, convertedSynthCoord.y },
+ new float[] { convertedJazzCoord.x, convertedJazzCoord.y },
+ platformIntervals, waitTime, moveTime,
weightedSynth, weightedJazz);
weightedPlatform.setBodyType(BodyDef.BodyType.StaticBody);
weightedPlatform.setDensity(defaults.getFloat("density", 0.0f));
- weightedPlatform.setFriction(defaults.getFloat("friction", 1.0f));
+ weightedPlatform.setFriction(defaults.getFloat("friction", 0.0f));
weightedPlatform.setRestitution(defaults.getFloat("restitution", 0.0f));
weightedPlatform.setDrawScale(scale);
GameController.getInstance().instantiate(weightedPlatform);
}
- private void createMovingPlatform(Vector2 scale, Vector2[] positionNodes, float speed, int levelHeight, int tileSize){
- // Adjust coordinates + Convert coordinates to world coordinates
+ private void createMovingPlatform(Vector2 scale, Vector2[] positionNodes, int waitTime, int beatMoveTime, Vector2 dimensions, int levelHeight, int tileSize){
+ // Convert coordinates to world coordinates
Vector2[] convertedPos = new Vector2[positionNodes.length];
for(int i=0; i synthWalkAnimation;
/** The synth genre jumping animation for the player */
public Animation synthJumpAnimation;
+ /** The synth genre fall animation for the player */
+ public Animation synthFallAnimation;
+ /** The synth genre death animation for the player */
+ public Animation synthDeathAnimation;
/** The jazz genre idle animation for the player */
public Animation jazzIdleAnimation;
@@ -89,6 +100,10 @@ public class Player extends CapsuleGameObject implements ISyncedAnimated, IGenre
public Animation jazzWalkAnimation;
/** The jazz genre jumping animation for the player */
public Animation jazzJumpAnimation;
+ /** The jazz genre fall animation for the player */
+ public Animation jazzFallAnimation;
+ /** The jazz genre death animation for the player */
+ public Animation jazzDeathAnimation;
/** The player's current animation */
public Animation animation;
@@ -96,6 +111,8 @@ public class Player extends CapsuleGameObject implements ISyncedAnimated, IGenre
private float stateTime = 0;
/** A flag to check if the player's animation is jumping */
private boolean animationIsJumping = false;
+ /** A flag to check if the player's animation is dying */
+ private boolean animationIsDying = false;
/**
* Returns left/right movement of this character.
@@ -277,7 +294,8 @@ public Player(JsonValue data, float startX, float startY, float width, float hei
damping = data.getFloat("damping", 0);
force = data.getFloat("force", 0);
- jump_force = data.getFloat( "jump_force", 0 );
+ jumpForceSynth = data.getFloat( "synth_jump_force", 0 );
+ jumpForceJazz = data.getFloat( "jazz_jump_force", 0 );
jumpLimit = data.getInt( "jump_cool", 0 );
shotLimit = data.getInt( "shot_cool", 0 );
displacement = new Vector2(0,0);
@@ -290,10 +308,11 @@ public Player(JsonValue data, float startX, float startY, float width, float hei
isJumping = false;
faceRight = true;
+ jumpForce = jumpForceSynth;
animationGenre = Genre.SYNTH;
jumpCooldown = 0;
- setName("dude");
+ setType(Type.Player);
}
/**
@@ -366,7 +385,7 @@ public void applyForce() {
// Jump!
if (isJumping()) {
- forceCache.set(0, jump_force);
+ forceCache.set(0, jumpForce);
body.applyLinearImpulse(forceCache,getPosition(),true);
}
}
@@ -382,10 +401,12 @@ public void update(float dt) {
// Process actions in object model
setPosition(getPosition().x+ dt*displacement.x, getPosition().y+ dt*displacement.y);
- setWalking(InputController.getInstance().getHorizontal() != 0 && !isJumping);
- setMovement(InputController.getInstance().getHorizontal() * getForce());
- setJumping(InputController.getInstance().didPrimary());
- applyForce();
+ if (!isDying) {
+ setWalking(InputController.getInstance().getHorizontal() != 0 && !isJumping);
+ setMovement(InputController.getInstance().getHorizontal() * getForce());
+ setJumping(InputController.getInstance().didPrimary());
+ applyForce();
+ }
// Apply cooldowns
if (isJumping()) {
@@ -396,13 +417,7 @@ public void update(float dt) {
}
animationUpdate();
-
- try {
- //GameController.getInstance().createJoint(bodyCollidedWith, this);
- } catch (Exception ignored) {}
-
- animationUpdate();
-
+ setRestitution(0.0f);
super.update(dt);
}
@@ -439,9 +454,11 @@ public void genreUpdate(Genre genre) {
animationGenre = genre;
if (genre == Genre.SYNTH) {
maxspeed = synthSpeed;
+ jumpForce = jumpForceSynth;
}
else{
maxspeed = jazzSpeed;
+ jumpForce = jumpForceJazz;
}
}
@@ -449,7 +466,18 @@ public void genreUpdate(Genre genre) {
* Updates the animation based on the physics state.
*/
private void animationUpdate() {
- if (isJumping) {
+ if (isDying && !animationIsDying) {
+ stateTime = 0;
+ switch (animationGenre) {
+ case SYNTH:
+ setAnimation(synthDeathAnimation);
+ break;
+ case JAZZ:
+ setAnimation(jazzDeathAnimation);
+ break;
+ }
+ animationIsDying = true;
+ } else if (isJumping && !animationIsDying) {
animationIsJumping = true;
stateTime = 0;
switch (animationGenre) {
@@ -462,29 +490,51 @@ private void animationUpdate() {
}
}
- if (animationIsJumping){
- if (animation.isAnimationFinished(stateTime)) {
- animationIsJumping = false;
- } else{
- return;
+ if (animationIsDying) {
+ if (jazzDeathAnimation.isAnimationFinished(stateTime) || synthDeathAnimation.isAnimationFinished(stateTime)) {
+ GameController.getInstance().setFailure(true);
+ animationIsDying = false;
}
- } else if (isWalking()){
- switch (animationGenre){
- case SYNTH:
- setAnimation(synthWalkAnimation);
- break;
- case JAZZ:
- setAnimation(jazzWalkAnimation);
- break;
- }
- } else{
- switch (animationGenre){
- case SYNTH:
- setAnimation(synthIdleAnimation);
- break;
- case JAZZ:
- setAnimation(jazzIdleAnimation);
- break;
+ } else {
+ if (animationIsJumping) {
+ if (animation.isAnimationFinished(stateTime)) {
+ animationIsJumping = false;
+ switch (animationGenre) {
+ case SYNTH:
+ setAnimation(synthFallAnimation);
+ break;
+ case JAZZ:
+ setAnimation(jazzFallAnimation);
+ break;
+ }
+ }
+ } else if (!isGrounded) {
+ switch (animationGenre) {
+ case SYNTH:
+ setAnimation(synthFallAnimation);
+ break;
+ case JAZZ:
+ setAnimation(jazzFallAnimation);
+ break;
+ }
+ } else if (isWalking()) {
+ switch (animationGenre) {
+ case SYNTH:
+ setAnimation(synthWalkAnimation);
+ break;
+ case JAZZ:
+ setAnimation(jazzWalkAnimation);
+ break;
+ }
+ } else {
+ switch (animationGenre) {
+ case SYNTH:
+ setAnimation(synthIdleAnimation);
+ break;
+ case JAZZ:
+ setAnimation(jazzIdleAnimation);
+ break;
+ }
}
}
}
@@ -498,5 +548,5 @@ public void updateAnimationFrame(){
}
public float getBeat() {return 1;}
- public void beatAction(){}
+ public void beatAction(){ }
}
\ No newline at end of file
diff --git a/core/src/edu/cornell/gdiac/rabbeat/SoundController.java b/core/src/edu/cornell/gdiac/rabbeat/SoundController.java
index 53e3ae97..65324588 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/SoundController.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/SoundController.java
@@ -2,14 +2,28 @@
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
+import com.badlogic.gdx.utils.Array;
+import com.badlogic.gdx.utils.ObjectMap;
public class SoundController {
private Music synthTrack;
private Music jazzTrack;
+ private float globalMusicVolume = 1.0f;
+
+ private float globalSFXVolume = 1.0f;
+
private Genre currentGenre;
+ private float savedJazzVolume = 0;
+
+ private float savedSynthVolume = 0;
+
+ private float savedGlobalMusicTempVolume = 0;
+
+ private Sound tempSound;
+
/**
* Set this to true to make genre switches instantaneous / in one frame.
* Set this to false to make genre switches gradual / over several frames.
@@ -24,9 +38,15 @@ public class SoundController {
private boolean currentlyUpdating;
private int currentUpdateFrame = 0;
+ private ObjectMap soundNameMap;
+
+ private ObjectMap soundIDMap;
+
public SoundController() {
currentGenre = Genre.SYNTH;
currentlyUpdating = false;
+ soundNameMap = new ObjectMap();
+ soundIDMap = new ObjectMap();
}
public void playMusic() {
@@ -39,11 +59,11 @@ public void playMusic() {
public void playMusic(Genre genre) {
playMusic();
if (genre == Genre.SYNTH) {
- synthTrack.setVolume(1);
+ synthTrack.setVolume(globalMusicVolume);
jazzTrack.setVolume(0);
}
else {
- jazzTrack.setVolume(1);
+ jazzTrack.setVolume(globalMusicVolume);
synthTrack.setVolume(0);
}
}
@@ -54,16 +74,47 @@ public void playMusic(Genre genre) {
public void setJazzTrack(Music track) { jazzTrack = track;}
+ public void setGlobalMusicVolume(float vol) { globalMusicVolume = vol;}
+
+ public void setGlobalSFXVolume(float vol) { globalSFXVolume = vol;}
public void resetMusic() {
synthTrack.setPosition(1/44100f);
jazzTrack.setPosition(1/44100f);
- synthTrack.setVolume(1);
+ synthTrack.setVolume(globalMusicVolume);
jazzTrack.setVolume(0);
currentGenre = Genre.SYNTH;
currentlyUpdating = false;
currentUpdateFrame = 0;
}
+ public void pauseMusic() {
+ savedJazzVolume = jazzTrack.getVolume();
+ savedSynthVolume = synthTrack.getVolume();
+ savedGlobalMusicTempVolume = globalMusicVolume;
+ jazzTrack.pause();
+ synthTrack.pause();
+ }
+
+ public void resumeMusic() {
+ jazzTrack.play();
+ synthTrack.play();
+
+ if (savedGlobalMusicTempVolume == 0) {
+ jazzTrack.setVolume(globalMusicVolume * (currentGenre == Genre.JAZZ ? 1 : 0));
+ synthTrack.setVolume(globalMusicVolume * (currentGenre == Genre.SYNTH ? 1: 0));
+ }
+ else {
+ jazzTrack.setVolume(savedJazzVolume * globalMusicVolume / (savedGlobalMusicTempVolume == 0 ? 1 : savedGlobalMusicTempVolume));
+ synthTrack.setVolume(savedSynthVolume * globalMusicVolume / (savedGlobalMusicTempVolume == 0 ? 1 : savedGlobalMusicTempVolume));
+ }
+
+ if (jazzTrack.getVolume() > 1) jazzTrack.setVolume(1);
+ else if (jazzTrack.getVolume() < 0) jazzTrack.setVolume(0);
+ if (synthTrack.getVolume() > 1) synthTrack.setVolume(1);
+ else if (synthTrack.getVolume() < 0) synthTrack.setVolume(0);
+
+ }
+
/**
* Method to ensure that a sound asset is only played once.
*
@@ -79,7 +130,7 @@ public void resetMusic() {
* @return the new sound instance for this asset.
*/
public long replaySound(Sound sound, long soundId) {
- return replaySound( sound, soundId, 1.0f );
+ return replaySound( sound, soundId, globalSFXVolume );
}
@@ -102,9 +153,24 @@ public long replaySound(Sound sound, long soundId, float volume) {
if (soundId != -1) {
sound.stop( soundId );
}
- return sound.play(volume);
+ return sound.play(volume * globalSFXVolume);
+ }
+
+ /** This method sets the map that maps sound names (strings) to Sound objects (Sounds).
+ * It also automatically generates a second private map that maps each of these sounds to a unique ID.
+ * The first sound added is assigned ID 0, the second assigned ID 1, etc.
+ * @param map The String:Sound map to allow quick playback of a sound based on its name. This name is different from the assets.json entry name for the sound.
+ */
+
+ public void addSound(String name, Sound sound) {
+ soundNameMap.put(name, sound);
+ soundIDMap.put(sound, (long)soundIDMap.size);
}
+ public void playSFX(String soundName) {
+ tempSound = soundNameMap.get(soundName);
+ replaySound(tempSound, soundIDMap.get(tempSound));
+ }
/**
* This method sets the genre AND sets the currentlyUpdating flag to true.
@@ -131,12 +197,12 @@ public void setGenre(Genre genre) {
// The genre just changed from synth to jazz
if (genre == Genre.JAZZ) {
jazzTrack.setVolume(0);
- synthTrack.setVolume(1);
+ synthTrack.setVolume(globalMusicVolume);
}
// The genre just changed from jazz to synth
else {
synthTrack.setVolume(0);
- jazzTrack.setVolume(1);
+ jazzTrack.setVolume(globalMusicVolume);
}
}
@@ -158,8 +224,8 @@ public void update() {
* The switch has no delay.
*/
public void switchMusicGenreInstant() {
- synthTrack.setVolume(1 - synthTrack.getVolume());
- jazzTrack.setVolume(1 - jazzTrack.getVolume());
+ synthTrack.setVolume(globalMusicVolume - synthTrack.getVolume());
+ jazzTrack.setVolume(globalMusicVolume - jazzTrack.getVolume());
currentlyUpdating = false;
}
@@ -173,18 +239,22 @@ public void switchMusicGenreGradual(float frameCount) {
currentUpdateFrame++;
// The genre just switched from synth to jazz
if (currentGenre == Genre.JAZZ) {
- jazzTrack.setVolume(jazzTrack.getVolume() + 1/frameCount);
- synthTrack.setVolume(synthTrack.getVolume() - 1/frameCount);
+ jazzTrack.setVolume(jazzTrack.getVolume() + globalMusicVolume/frameCount);
+ synthTrack.setVolume(synthTrack.getVolume() - globalMusicVolume/frameCount);
}
// The genre just switched from jazz to synth
else {
- synthTrack.setVolume(synthTrack.getVolume() + 1/frameCount);
- jazzTrack.setVolume(jazzTrack.getVolume() - 1/frameCount);
+ synthTrack.setVolume(synthTrack.getVolume() + globalMusicVolume/frameCount);
+ jazzTrack.setVolume(jazzTrack.getVolume() - globalMusicVolume/frameCount);
}
if (currentUpdateFrame == frameCount) {
currentUpdateFrame = 0;
currentlyUpdating = false;
}
+ if (jazzTrack.getVolume() > 1) jazzTrack.setVolume(1);
+ else if (jazzTrack.getVolume() < 0) jazzTrack.setVolume(0);
+ if (synthTrack.getVolume() > 1) synthTrack.setVolume(1);
+ else if (synthTrack.getVolume() < 0) synthTrack.setVolume(0);
}
}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/levelSelect/LevelSelectorScreen.java b/core/src/edu/cornell/gdiac/rabbeat/levelSelect/LevelSelectorScreen.java
new file mode 100644
index 00000000..1b826506
--- /dev/null
+++ b/core/src/edu/cornell/gdiac/rabbeat/levelSelect/LevelSelectorScreen.java
@@ -0,0 +1,119 @@
+package edu.cornell.gdiac.rabbeat.levelSelect;
+
+import com.badlogic.gdx.Game;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.Screen;
+import com.badlogic.gdx.ScreenAdapter;
+import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.graphics.GL20;
+import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g2d.BitmapFont;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
+import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import com.badlogic.gdx.scenes.scene2d.InputEvent;
+import com.badlogic.gdx.scenes.scene2d.Stage;
+import com.badlogic.gdx.scenes.scene2d.ui.Image;
+import com.badlogic.gdx.scenes.scene2d.ui.Skin;
+import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
+import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
+import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
+import com.badlogic.gdx.utils.viewport.ScreenViewport;
+import edu.cornell.gdiac.rabbeat.GameController;
+import edu.cornell.gdiac.rabbeat.LoadingMode;
+import edu.cornell.gdiac.rabbeat.ObjectController;
+import edu.cornell.gdiac.util.ScreenListener;
+
+public class LevelSelectorScreen extends ScreenAdapter {
+ private Game game;
+ private Stage stage;
+ private Skin skin;
+ private Texture buttonTexture;
+
+ /** Reference to the numberOfLevels variable in GameController */
+ private int numberOfLevels = GameController.getInstance().getNumberOfLevels();
+
+ private ScreenListener listener;
+
+ public LevelSelectorScreen(Game game) {
+ this.game = game;
+ }
+
+ /** Displays the button UI for each level and adds a clickListener that detects whether
+ * the button has been clicked and takes the player to the desired level
+ */
+ @Override
+ public void show() {
+ stage = new Stage(new ScreenViewport());
+ Gdx.input.setInputProcessor(stage);
+
+ // Background
+ Texture background = new Texture(Gdx.files.internal("backgrounds/test-bg.png"));
+ TextureRegionDrawable backgroundDrawable = new TextureRegionDrawable(new TextureRegion(background));
+ Image bg = new Image(backgroundDrawable);
+ bg.setPosition(0, 0);
+ stage.addActor(bg);
+
+ /** Loops through all buttons */
+ for(int i=1; i<= numberOfLevels; i++) {
+ int finalI = i;
+ if(i <= GameController.getInstance().getLevelsUnlocked()) {
+// buttonTexture = new TextureRegion(directory.getEntry("backgrounds:pauseTint", Texture.class));
+ buttonTexture = new Texture(Gdx.files.internal("ui/unlockedLevels/unlockedLevel" + finalI + ".png"));
+ } else {
+ buttonTexture = new Texture(Gdx.files.internal("ui/lockedLevels/lockedLevel" + finalI + ".png"));
+ }
+
+ TextureRegionDrawable buttonDrawable = new TextureRegionDrawable(new TextureRegion(buttonTexture));
+ BitmapFont font = new BitmapFont();
+ TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
+ textButtonStyle.up = buttonDrawable;
+ textButtonStyle.font = font;
+ TextButton levelButton = new TextButton("", textButtonStyle);
+
+ float xPos = 100 + 300*((i-1)%4);
+ float yPos = 0;
+
+ if(i <= 4) {
+ yPos = 475;
+ } else if (i <= 8) {
+ yPos = 275;
+ } else if (i <= 12) {
+ yPos = 75;
+ }
+
+ levelButton.setPosition(xPos, yPos);
+
+ levelButton.addListener(new ClickListener() {
+ @Override
+ public void clicked(InputEvent event, float x, float y) {
+ if (finalI <= GameController.getInstance().getLevelsUnlocked()) {
+ listener.exitScreen(LevelSelectorScreen.this, 0);
+ GameController.getInstance().setCurrentLevelInt(finalI);
+ }
+ }
+ });
+ stage.addActor(levelButton);
+ }
+ }
+
+ public void render(float delta) {
+ Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
+ stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
+ stage.draw();
+ }
+
+ @Override
+ public void resize(int width, int height) {
+ stage.getViewport().update(width, height, true);
+ }
+
+ @Override
+ public void hide() {
+ stage.dispose();
+ }
+
+ public void setListener (ScreenListener listener) {
+ this.listener = listener;
+ }
+
+}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/CapsuleGameObject.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/CapsuleGameObject.java
index ac94416c..11c4b072 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/CapsuleGameObject.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/CapsuleGameObject.java
@@ -145,6 +145,13 @@ public void setHeight(float value) {
sizeCache.set(dimension.x,value);
setDimension(sizeCache);
}
+
+ public void setPlayer(){
+ end1.setRadius(0);
+ vertices[3] = center.y+center.height;
+ vertices[5] = center.y+center.height;
+ shape.set(vertices);
+ }
/**
* Returns the orientation of this capsule
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/Checkpoint.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/Checkpoint.java
index 038dfeff..da883f41 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/Checkpoint.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/Checkpoint.java
@@ -1,31 +1,80 @@
package edu.cornell.gdiac.rabbeat.obstacles;
+import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import edu.cornell.gdiac.rabbeat.GameCanvas;
+import edu.cornell.gdiac.rabbeat.Genre;
+import edu.cornell.gdiac.rabbeat.sync.ISyncedAnimated;
-public class Checkpoint extends BoxGameObject {
+/**
+ * Class for checkpoints, which determines if the player has reached a checkpoint and
+ * the spawn points of the player.
+ */
+public class Checkpoint extends BoxGameObject implements ISyncedAnimated {
/** Index of the checkpoint in the checkpoints json */
private final int index;
- /** The texture for the checkpoint when it is active has already been reached */
- private final TextureRegion activeTexture;
-
/** Indicates whether the checkpoint is active */
public boolean isActive;
+ /** The active animation */
+ private Animation activeAnimation;
+ /** The rise animation */
+ private Animation riseAnimation;
+ /** The inactive animation */
+ private Animation inactiveAnimation;
+ /** The current animation */
+ public Animation animation;
+ /** The elapsed time for animationUpdate */
+ private float stateTime = 0;
+
/**
* Creates a new checkpoint.
*
- * @param index The index of the checkpoint in the checkpoints json
- * @param activeTexture The texture for the checkpoint when it is active
- * @param x Initial x position of the box center in Box2D units
- * @param y Initial y position of the box center in Box2D units
- * @param width The width of the checkpoint
- * @param height The height of the checkpoint
+ * @param index The index of the checkpoint in the checkpoints json
+ * @param inactiveAnimation The inactive animation for checkpoints
+ * @param activeAnimation The active animation for checkpoints
+ * @param riseAnimation The rise animation for checkpoints
+ * @param x Initial x position of the box center in Box2D units
+ * @param y Initial y position of the box center in Box2D units
+ * @param width The width of the checkpoint
+ * @param height The height of the checkpoint
*/
- public Checkpoint(int index, TextureRegion activeTexture, float x, float y, float width, float height) {
+ public Checkpoint(int index, Animation inactiveAnimation, Animation activeAnimation, Animation riseAnimation, float x, float y, float width, float height) {
super(x, y, width, height);
this.index = index;
- this.activeTexture = activeTexture;
+ isActive = false;
+ this.inactiveAnimation = inactiveAnimation;
+ this.activeAnimation = activeAnimation;
+ this.riseAnimation = riseAnimation;
+ setAnimation(inactiveAnimation);
+ }
+
+ /**
+ * Updates the object's physics state.
+ *
+ * @param dt Number of seconds since last animation frame
+ */
+ public void update(float dt) {
+ if (isActive) {
+ if (animation.isAnimationFinished(stateTime)) {
+ stateTime = 0;
+ setAnimation(activeAnimation);
+ }
+ } else {
+ if (animation.isAnimationFinished(stateTime)) {
+ stateTime = 0;
+ setAnimation(inactiveAnimation);
+ }
+ }
+ super.update(dt);
+ }
+
+ public void draw(GameCanvas canvas) {
+ TextureRegion currentFrame = animation.getKeyFrame(stateTime, true);
+ canvas.draw(currentFrame, Color.WHITE,origin.x,origin.y,getX()*drawScale.x,getY()*drawScale.y,getAngle(),
+ 1,1);
}
/**
@@ -40,7 +89,25 @@ public int getIndex() {
*/
public void setActive() {
isActive = true;
- setTexture(activeTexture);
}
+ public void setActive(boolean act) { isActive = act;}
+
+ @Override
+ public float getBeat() {
+ return 1;
+ }
+
+ @Override
+ public void beatAction() { }
+
+ @Override
+ public void setAnimation(Animation animation) {
+ this.animation = animation;
+ }
+
+ @Override
+ public void updateAnimationFrame() {
+ stateTime++;
+ }
}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/ComplexGameObject.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/ComplexGameObject.java
deleted file mode 100644
index 1a48d8b9..00000000
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/ComplexGameObject.java
+++ /dev/null
@@ -1,1029 +0,0 @@
-/*
- * ComplexObstacle.java
- *
- * This class is a subclass of PhysicsObject that supports mutliple Bodies.
- * This is the base class for objects that are tied together with joints.
- *
- * This class does not provide Shape information, and cannot be instantiated
- * directly.
- *
- * Many of the method comments in this class are taken from the Box2d manual by
- * Erin Catto (2011).
- *
- * Author: Walker M. White
- * Based on original PhysicsDemo Lab by Don Holden, 2007
- * LibGDX version, 2/6/2015
- */
-package edu.cornell.gdiac.rabbeat.obstacles;
-
-import com.badlogic.gdx.utils.*;
-import com.badlogic.gdx.math.*;
-import com.badlogic.gdx.physics.box2d.*;
-import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
-
-import edu.cornell.gdiac.rabbeat.*; // For GameCanvas
-
-/**
- * Composite model class to support collisions.
- *
- * ComplexObstacle instances are built of many bodies, and are assumed to be connected
- * by joints (though this is not actually a requirement). This is the class to use for
- * chains, ropes, levers, and so on. This class does not provide Shape information, and
- * cannot be instantiated directly.
- *
- * ComplexObstacle is a hierarchical class. It groups children as Obstacles, not bodies.
- * So you could have a ComplexObstacle made up of other ComplexObstacles. However, it
- * also has a root body which may or may not be attached to the other bodies in the
- * hierarchy. All of the physics methods in the class apply to the root, not the body.
- * To move the other bodies, they should either be iterated over directly, or attached
- * to the root via a joint.
- */
-public abstract class ComplexGameObject extends GameObject {
- /** A root body for this box 2d. */
- protected Body body;
- /** A complex physics object has multiple bodies */
- protected Array bodies;
- /** Potential joints for connecting the multiple bodies */
- protected Array joints;
-
- /// BodyDef Methods
- /**
- * Returns the body type for Box2D physics
- *
- * If you want to lock a body in place (e.g. a platform) set this value to STATIC.
- * KINEMATIC allows the object to move (and some limited collisions), but ignores
- * external forces (e.g. gravity). DYNAMIC makes this is a full-blown physics object.
- *
- * This method returns the body type for the root object of this composite structure.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the body type for Box2D physics
- */
- public BodyType getBodyType() {
- return (body != null ? body.getType() : super.getBodyType());
- }
-
- /**
- * Returns the body type for Box2D physics
- *
- * If you want to lock a body in place (e.g. a platform) set this value to STATIC.
- * KINEMATIC allows the object to move (and some limited collisions), but ignores
- * external forces (e.g. gravity). DYNAMIC makes this is a full-blown physics object.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the body type for Box2D physics
- */
- public void setBodyType(BodyType value) {
- if (body != null) {
- body.setType(value);
- } else {
- super.setBodyType(value);
- }
- }
-
- /**
- * Returns the current position for this physics body
- *
- * This method does NOT return a reference to the position vector. Changes to this
- * vector will not affect the body. However, it returns the same vector each time
- * its is called, and so cannot be used as an allocator.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the current position for this physics body
- */
- public Vector2 getPosition() {
- return (body != null ? body.getPosition() : super.getPosition());
- }
-
- /**
- * Sets the current position for this physics body
- *
- * This method does not keep a reference to the parameter.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the current position for this physics body
- */
- public void setPosition(Vector2 value) {
- if (body != null) {
- body.setTransform(value,body.getAngle());
- } else {
- super.setPosition(value);
- }
- }
-
- /**
- * Sets the current position for this physics body
- *
- * This method does not keep a reference to the parameter.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param x the x-coordinate for this physics body
- * @param y the y-coordinate for this physics body
- */
- public void setPosition(float x, float y) {
- if (body != null) {
- positionCache.set(x,y);
- body.setTransform(positionCache,body.getAngle());
- } else {
- super.setPosition(x,y);
- }
- }
-
- /**
- * Returns the x-coordinate for this physics body
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the x-coordinate for this physics body
- */
- public float getX() {
- return (body != null ? body.getPosition().x : super.getX());
- }
-
- /**
- * Sets the x-coordinate for this physics body
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the x-coordinate for this physics body
- */
- public void setX(float value) {
- if (body != null) {
- positionCache.set(value,body.getPosition().y);
- body.setTransform(positionCache,body.getAngle());
- } else {
- super.setX(value);
- }
- }
-
- /**
- * Returns the y-coordinate for this physics body
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the y-coordinate for this physics body
- */
- public float getY() {
- return (body != null ? body.getPosition().y : super.getY());
- }
-
- /**
- * Sets the y-coordinate for this physics body
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the y-coordinate for this physics body
- */
- public void setY(float value) {
- if (body != null) {
- positionCache.set(body.getPosition().x,value);
- body.setTransform(positionCache,body.getAngle());
- } else {
- super.setY(value);
- }
- }
-
- /**
- * Returns the angle of rotation for this body (about the center).
- *
- * The value returned is in radians
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the angle of rotation for this body
- */
- public float getAngle() {
- return (body != null ? body.getAngle() : super.getAngle());
- }
-
- /**
- * Sets the angle of rotation for this body (about the center).
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the angle of rotation for this body (in radians)
- */
- public void setAngle(float value) {
- if (body != null) {
- body.setTransform(body.getPosition(),value);
- } else {
- super.setAngle(value);
- }
- }
-
- /**
- * Returns the linear velocity for this physics body
- *
- * This method does NOT return a reference to the velocity vector. Changes to this
- * vector will not affect the body. However, it returns the same vector each time
- * its is called, and so cannot be used as an allocator.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the linear velocity for this physics body
- */
- public Vector2 getLinearVelocity() {
- return (body != null ? body.getLinearVelocity() : super.getLinearVelocity());
- }
-
- /**
- * Sets the linear velocity for this physics body
- *
- * This method does not keep a reference to the parameter.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the linear velocity for this physics body
- */
- public void setLinearVelocity(Vector2 value) {
- if (body != null) {
- body.setLinearVelocity(value);
- } else {
- super.setLinearVelocity(value);
- }
- }
-
- /**
- * Returns the x-velocity for this physics body
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the x-velocity for this physics body
- */
- public float getVX() {
- return (body != null ? body.getLinearVelocity().x : super.getVX());
- }
-
- /**
- * Sets the x-velocity for this physics body
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the x-velocity for this physics body
- */
- public void setVX(float value) {
- if (body != null) {
- velocityCache.set(value,body.getLinearVelocity().y);
- body.setLinearVelocity(velocityCache);
- } else {
- super.setVX(value);
- }
- }
-
- /**
- * Returns the y-velocity for this physics body
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the y-velocity for this physics body
- */
- public float getVY() {
- return (body != null ? body.getLinearVelocity().y : super.getVY());
- }
-
- /**
- * Sets the y-velocity for this physics body
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the y-velocity for this physics body
- */
- public void setVY(float value) {
- if (body != null) {
- velocityCache.set(body.getLinearVelocity().x,value);
- body.setLinearVelocity(velocityCache);
- } else {
- super.setVY(value);
- }
- }
-
- /**
- * Returns the angular velocity for this physics body
- *
- * The rate of change is measured in radians per step
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the angular velocity for this physics body
- */
- public float getAngularVelocity() {
- return (body != null ? body.getAngularVelocity() : super.getAngularVelocity());
- }
-
- /**
- * Sets the angular velocity for this physics body
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the angular velocity for this physics body (in radians)
- */
- public void setAngularVelocity(float value) {
- if (body != null) {
- body.setAngularVelocity(value);
- } else {
- super.setAngularVelocity(value);
- }
- }
-
- /**
- * Returns true if the body is active
- *
- * An inactive body not participate in collision or dynamics. This state is similar
- * to sleeping except the body will not be woken by other bodies and the body's
- * fixtures will not be placed in the broad-phase. This means the body will not
- * participate in collisions, ray casts, etc.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return true if the body is active
- */
- public boolean isActive() {
- return (body != null ? body.isActive() : super.isActive());
- }
-
- /**
- * Sets whether the body is active
- *
- * An inactive body not participate in collision or dynamics. This state is similar
- * to sleeping except the body will not be woken by other bodies and the body's
- * fixtures will not be placed in the broad-phase. This means the body will not
- * participate in collisions, ray casts, etc.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value whether the body is active
- */
- public void setActive(boolean value) {
- if (body != null) {
- body.setActive(value);
- } else {
- super.setActive(value);
- }
- }
-
- /**
- * Returns true if the body is awake
- *
- * An sleeping body is one that has come to rest and the physics engine has decided
- * to stop simulating it to save CPU cycles. If a body is awake and collides with a
- * sleeping body, then the sleeping body wakes up. Bodies will also wake up if a
- * joint or contact attached to them is destroyed. You can also wake a body manually.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return true if the body is awake
- */
- public boolean isAwake() {
- return (body != null ? body.isAwake() : super.isAwake());
- }
-
- /**
- * Sets whether the body is awake
- *
- * An sleeping body is one that has come to rest and the physics engine has decided
- * to stop simulating it to save CPU cycles. If a body is awake and collides with a
- * sleeping body, then the sleeping body wakes up. Bodies will also wake up if a
- * joint or contact attached to them is destroyed. You can also wake a body manually.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value whether the body is awake
- */
- public void setAwake(boolean value) {
- if (body != null) {
- body.setAwake(value);
- } else {
- super.setAwake(value);
- }
- }
-
- /**
- * Returns false if this body should never fall asleep
- *
- * An sleeping body is one that has come to rest and the physics engine has decided
- * to stop simulating it to save CPU cycles. If a body is awake and collides with a
- * sleeping body, then the sleeping body wakes up. Bodies will also wake up if a
- * joint or contact attached to them is destroyed. You can also wake a body manually.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return false if this body should never fall asleep
- */
- public boolean isSleepingAllowed() {
- return (body != null ? body.isSleepingAllowed() : super.isSleepingAllowed());
- }
-
- /**
- * Sets whether the body should ever fall asleep
- *
- * An sleeping body is one that has come to rest and the physics engine has decided
- * to stop simulating it to save CPU cycles. If a body is awake and collides with a
- * sleeping body, then the sleeping body wakes up. Bodies will also wake up if a
- * joint or contact attached to them is destroyed. You can also wake a body manually.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value whether the body should ever fall asleep
- */
- public void setSleepingAllowed(boolean value) {
- if (body != null) {
- body.setSleepingAllowed(value);
- } else {
- super.setSleepingAllowed(value);
- }
- }
-
-
- /**
- * Returns true if this body be prevented from rotating
- *
- * This is very useful for characters that should remain upright.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return true if this body be prevented from rotating
- */
- public boolean isFixedRotation() {
- return (body != null ? body.isFixedRotation() : super.isFixedRotation());
- }
-
- /**
- * Sets whether this body be prevented from rotating
- *
- * This is very useful for characters that should remain upright.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value whether this body be prevented from rotating
- */
- public void setFixedRotation(boolean value) {
- if (body != null) {
- body.setFixedRotation(value);
- } else {
- super.setFixedRotation(value);
- }
- }
-
- /**
- * Returns the gravity scale to apply to this body
- *
- * This allows isolated objects to float. Be careful with this, since increased
- * gravity can decrease stability.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the gravity scale to apply to this body
- */
- public float getGravityScale() {
- return (body != null ? body.getGravityScale() : super.getGravityScale());
- }
-
- /**
- * Sets the gravity scale to apply to this body
- *
- * This allows isolated objects to float. Be careful with this, since increased
- * gravity can decrease stability.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the gravity scale to apply to this body
- */
- public void setGravityScale(float value) {
- if (body != null) {
- body.setGravityScale(value);
- } else {
- super.setGravityScale(value);
- }
- }
-
- /**
- * Returns the linear damping for this body.
- *
- * Linear damping is use to reduce the linear velocity. Damping is different than
- * friction because friction only occurs with contact. Damping is not a replacement
- * for friction and the two effects should be used together.
- *
- * Damping parameters should be between 0 and infinity, with 0 meaning no damping,
- * and infinity meaning full damping. Normally you will use a damping value between
- * 0 and 0.1. Most people avoid linear damping because it makes bodies look floaty.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the linear damping for this body.
- */
- public float getLinearDamping() {
- return (body != null ? body.getLinearDamping() : super.getLinearDamping());
- }
-
- /**
- * Sets the linear damping for this body.
- *
- * Linear damping is use to reduce the linear velocity. Damping is different than
- * friction because friction only occurs with contact. Damping is not a replacement
- * for friction and the two effects should be used together.
- *
- * Damping parameters should be between 0 and infinity, with 0 meaning no damping,
- * and infinity meaning full damping. Normally you will use a damping value between
- * 0 and 0.1. Most people avoid linear damping because it makes bodies look floaty.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the linear damping for this body.
- */
- public void setLinearDamping(float value) {
- if (body != null) {
- body.setLinearDamping(value);
- } else {
- super.setLinearDamping(value);
- }
- }
-
- /**
- * Returns the angular damping for this body.
- *
- * Angular damping is use to reduce the angular velocity. Damping is different than
- * friction because friction only occurs with contact. Damping is not a replacement
- * for friction and the two effects should be used together.
- *
- * Damping parameters should be between 0 and infinity, with 0 meaning no damping,
- * and infinity meaning full damping. Normally you will use a damping value between
- * 0 and 0.1.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the angular damping for this body.
- */
- public float getAngularDamping() {
- return (body != null ? body.getAngularDamping() : super.getAngularDamping());
- }
-
- /**
- * Sets the angular damping for this body.
- *
- * Angular damping is use to reduce the angular velocity. Damping is different than
- * friction because friction only occurs with contact. Damping is not a replacement
- * for friction and the two effects should be used together.
- *
- * Damping parameters should be between 0 and infinity, with 0 meaning no damping,
- * and infinity meaning full damping. Normally you will use a damping value between
- * 0 and 0.1.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the angular damping for this body.
- */
- public void setAngularDamping(float value) {
- if (body != null) {
- body.setAngularDamping(value);
- } else {
- super.setAngularDamping(value);
- }
- }
-
- /// FixtureDef Methods
- /**
- * Sets the density of this body
- *
- * The density is typically measured in usually in kg/m^2. The density can be zero or
- * positive. You should generally use similar densities for all your fixtures. This
- * will improve stacking stability.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the density of this body
- */
- public void setDensity(float value) {
- super.setDensity(value);
- if (body != null) {
- for(Fixture f : body.getFixtureList()) {
- f.setDensity(value);
- }
- }
- }
-
- /**
- * Sets the friction coefficient of this body
- *
- * The friction parameter is usually set between 0 and 1, but can be any non-negative
- * value. A friction value of 0 turns off friction and a value of 1 makes the friction
- * strong. When the friction force is computed between two shapes, Box2D must combine
- * the friction parameters of the two parent fixtures. This is done with the geometric
- * mean.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the friction coefficient of this body
- */
- public void setFriction(float value) {
- super.setFriction(value);
- if (body != null) {
- for(Fixture f : body.getFixtureList()) {
- f.setFriction(value);
- }
- }
- }
-
- /**
- * Sets the restitution of this body
- *
- * Restitution is used to make objects bounce. The restitution value is usually set
- * to be between 0 and 1. Consider dropping a ball on a table. A value of zero means
- * the ball won't bounce. This is called an inelastic collision. A value of one means
- * the ball's velocity will be exactly reflected. This is called a perfectly elastic
- * collision.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the restitution of this body
- */
- public void setRestitution(float value) {
- super.setRestitution(value);
- if (body != null) {
- for(Fixture f : body.getFixtureList()) {
- f.setRestitution(value);
- }
- }
- }
-
- /**
- * Sets whether this object is a sensor.
- *
- * Sometimes game logic needs to know when two entities overlap yet there should be
- * no collision response. This is done by using sensors. A sensor is an entity that
- * detects collision but does not produce a response.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value whether this object is a sensor.
- */
- public void setSensor(boolean value) {
- super.setSensor(value);
- if (body != null) {
- for(Fixture f : body.getFixtureList()) {
- f.setSensor(value);
- }
- }
- }
-
- /**
- * Sets the filter data for this object
- *
- * Collision filtering allows you to prevent collision between fixtures. For example,
- * say you make a character that rides a bicycle. You want the bicycle to collide
- * with the terrain and the character to collide with the terrain, but you don't want
- * the character to collide with the bicycle (because they must overlap). Box2D
- * supports such collision filtering using categories and groups.
- *
- * A value of null removes all collision filters.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the filter data for this object
- */
- public void setFilterData(Filter value) {
- super.setFilterData(value);
- if (body != null) {
- for(Fixture f : body.getFixtureList()) {
- f.setFilterData(value);
- }
- }
- }
-
- /// MassData Methods
- /**
- * Returns the center of mass of this body
- *
- * This method does NOT return a reference to the centroid position. Changes to this
- * vector will not affect the body. However, it returns the same vector each time
- * its is called, and so cannot be used as an allocator.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the center of mass for this physics body
- */
- public Vector2 getCentroid() {
- return (body != null ? body.getLocalCenter() : super.getCentroid());
- }
-
- /**
- * Sets the center of mass for this physics body
- *
- * This method does not keep a reference to the parameter.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the center of mass for this physics body
- */
- public void setCentroid(Vector2 value) {
- super.setCentroid(value);
- if (body != null) {
- body.setMassData(massdata); // Protected accessor?
- }
- }
-
- /**
- * Returns the rotational inertia of this body
- *
- * For static bodies, the mass and rotational inertia are set to zero. When
- * a body has fixed rotation, its rotational inertia is zero.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the rotational inertia of this body
- */
- public float getInertia() {
- return (body != null ? body.getInertia() : super.getInertia());
- }
-
- /**
- * Sets the rotational inertia of this body
- *
- * For static bodies, the mass and rotational inertia are set to zero. When
- * a body has fixed rotation, its rotational inertia is zero.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the rotational inertia of this body
- */
- public void setInertia(float value) {
- super.setInertia(value);
- if (body != null) {
- body.setMassData(massdata); // Protected accessor?
- }
- }
-
- /**
- * Returns the mass of this body
- *
- * The value is usually in kilograms.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @return the mass of this body
- */
- public float getMass() {
- return (body != null ? body.getMass() : super.getMass());
- }
-
- /**
- * Sets the mass of this body
- *
- * The value is usually in kilograms.
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- * @param value the mass of this body
- */
- public void setMass(float value) {
- super.setMass(value);
- if (body != null) {
- body.setMassData(massdata); // Protected accessor?
- }
- }
-
- /**
- * Resets this body to use the mass computed from the its shape and density
- *
- * This method affects the root body of this composite structure only. If you want
- * to set the value for any of the child obstacles, iterate over the children.
- *
- */
- public void resetMass() {
- super.resetMass();
- if (body != null) {
- body.resetMassData();
- }
- }
-
- /// Physics Bodies
- /**
- * Returns the Box2D body for this object.
- *
- * This method only returrns the root body in this composite structure. For more
- * fine-grain control, you should use the iterator methods.
- *
- * @return the Box2D body for this object.
- */
- public Body getBody() {
- return (bodies.size > 0 ? bodies.get(0).getBody() : null);
- }
-
- /**
- * Returns the collection of component physics objects.
- *
- * While the iterable does not allow you to modify the list, it is possible to
- * modify the individual objects.
- *
- * @return the collection of component physics objects.
- */
- public Iterable getBodies() {
- return bodies;
- }
-
- /**
- * Returns the collection of joints for this object (may be empty).
- *
- * While the iterable does not allow you to modify the list, it is possible to
- * modify the individual joints.
- *
- * @return the collection of joints for this object.
- */
- public Iterable getJoints() {
- return joints;
- }
-
- /**
- * Creates a new complex physics object at the origin.
- */
- protected ComplexGameObject() {
- this(0,0);
- }
-
- /**
- * Creates a new complex physics object
- *
- * The position is the position of the root object.
- *
- * @param x Initial x position in world coordinates
- * @param y Initial y position in world coordinates
- */
- protected ComplexGameObject(float x, float y) {
- super(x,y);
- bodies = new Array();
- joints = new Array();
- }
-
- /**
- * Creates the physics Body(s) for this object, adding them to the world.
- *
- * This method invokes ActivatePhysics for the individual PhysicsObjects
- * in the list. It also calls the internal method createJoints() to
- * link them all together. You should override that method, not this one,
- * for specific physics objects.
- *
- * @param world Box2D world to store body
- *
- * @return true if object allocation succeeded
- */
- public boolean activatePhysics(World world) {
- bodyinfo.active = true;
- boolean success = true;
-
- // Create all other bodies.
- for(GameObject obj : bodies) {
- success = success && obj.activatePhysics(world);
- }
- success = success && createJoints(world);
-
- // Clean up if we failed
- if (!success) {
- deactivatePhysics(world);
- }
- return success;
- }
-
- /**
- * Destroys the physics Body(s) of this object if applicable,
- * removing them from the world.
- *
- * @param world Box2D world that stores body
- */
- public void deactivatePhysics(World world) {
- if (bodyinfo.active) {
- // Should be good for most (simple) applications.
- for (Joint joint : joints) {
- world.destroyJoint(joint);
- }
- joints.clear();
- for (GameObject obj : bodies) {
- obj.deactivatePhysics(world);
- }
- bodyinfo.active = false;
- }
- }
-
- /**
- * Creates the joints for this object.
- *
- * This method is executed as part of activePhysics. This is the primary method to
- * override for custom physics objects.
- *
- * @param world Box2D world to store joints
- *
- * @return true if object allocation succeeded
- */
- protected abstract boolean createJoints(World world);
-
- /**
- * Updates the object's physics state (NOT GAME LOGIC).
- *
- * This method is called AFTER the collision resolution state. Therefore, it
- * should not be used to process actions or any other gameplay information. Its
- * primary purpose is to adjust changes to the fixture, which have to take place
- * after collision.
- *
- * @param dt Timing values from parent loop
- */
- public void update(float delta) {
- // Delegate to components
- for(GameObject obj : bodies) {
- obj.update(delta);
- }
- }
-
- /**
- * Sets the drawing scale for this physics object
- *
- * The drawing scale is the number of pixels to draw before Box2D unit. Because
- * mass is a function of area in Box2D, we typically want the physics objects
- * to be small. So we decouple that scale from the physics object. However,
- * we must track the scale difference to communicate with the scene graph.
- *
- * We allow for the scaling factor to be non-uniform.
- *
- * @param x the x-axis scale for this physics object
- * @param y the y-axis scale for this physics object
- */
- public void setDrawScale(float x, float y) {
- drawScale.set(x,y);
- for(GameObject obj : bodies) {
- obj.setDrawScale(x,y);
- }
- }
-
- /**
- * Draws the physics object.
- *
- * @param canvas Drawing context
- */
- public void draw(GameCanvas canvas) {
- // Delegate to components
- for(GameObject obj : bodies) {
- obj.draw(canvas);
- }
- }
-
- /**
- * Draws the outline of the physics body.
- *
- * This method can be helpful for understanding issues with collisions.
- *
- * @param canvas Drawing context
- */
- public void drawDebug(GameCanvas canvas) {
- // Delegate to components
- for(GameObject obj : bodies) {
- obj.drawDebug(canvas);
- }
- }
-
-}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/GameObject.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/GameObject.java
index 1598b6ef..7e437469 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/GameObject.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/GameObject.java
@@ -66,6 +66,8 @@ public abstract class GameObject {
protected Vector2 centroidCache = new Vector2();
/** A cache value for when the user wants to access the drawing scale */
protected Vector2 scaleCache = new Vector2();
+ /** The type the GameObject is*/
+ private Type type;
/// BodyDef Methods
@@ -908,6 +910,14 @@ protected GameObject(float x, float y) {
drawScale = new Vector2(1,1);
}
+ /** returns the type of the object*/
+ public Type getType() {
+ return type;
+ }
+ public void setType(Type _type){
+ type = _type;
+ }
+
/// Abstract Methods
/**
* Creates the physics Body(s) for this object, adding them to the world.
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/GameObjectSelector.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/GameObjectSelector.java
deleted file mode 100644
index d6fd8fae..00000000
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/GameObjectSelector.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * ObstacleSelector.java
- *
- * This class implements a selection tool for dragging physics objects with a mouse.
- * It is essentially an instance of MouseJoint, but with an API that makes it a lot
- * easier to use. As with all instances of MouseJoint, there will be some lag in
- * the drag (though this is true on touch devices in general). You can adjust the
- * degree of this lag by adjusting the force. However, larger forces can cause artifacts
- * when dragging an obstacle through other obstacles.
- *
- * Author: Walker M. White
- * Based on original PhysicsDemo Lab by Don Holden, 2007
- * LibGDX version, 2/6/2015
- */
-package edu.cornell.gdiac.rabbeat.obstacles;
-
-import com.badlogic.gdx.math.*;
-import com.badlogic.gdx.graphics.*;
-import com.badlogic.gdx.graphics.g2d.*;
-import com.badlogic.gdx.physics.box2d.*;
-import com.badlogic.gdx.physics.box2d.joints.*;
-
-import edu.cornell.gdiac.rabbeat.*; // For GameCanvas
-
-/**
- * Selection tool to move and drag physics obstacles
- *
- * This class is essentially an instance of MouseJoint, but with an API that makes
- * it a lot easier to use. It must be attached to a World on creation, and this
- * controller can never change. If you want a selector for a different World, make
- * a new instance.
- *
- * As with all instances of MouseJoint, there will be some lag in the drag (though
- * this is true on touch devices in general). You can adjust the degree of this lag
- * by adjusting the force. However, larger forces can cause artifacts when dragging
- * an obstacle through other obstacles.
- */
-public class GameObjectSelector implements QueryCallback {
- /** The default size of the mouse selector */
- private static float DEFAULT_MSIZE = 0.2f;
- /** The default update frequence (in Hz) of the joint */
- private static float DEFAULT_FREQUENCY = 10.0f;
- /** The default damping force of the joint */
- private static float DEFAULT_DAMPING = 0.7f;
- /** The default force multiplier of the selector */
- private static float DEFAULT_FORCE = 1000.0f;
-
- /** The World associated with this selection */
- private World world;
- /** The current fixture selected by this tool (may be nullptr) */
- private Fixture selection;
- /** A default body used as the other half of the mouse joint */
- private Body ground;
- /** The width and height of the box */
- private Vector2 dimension;
-
- /** The texture to display this selector on screen */
- private TextureRegion texture;
- /** The texture origin (in the center) */
- private Vector2 origin;
- /** The drawing scale for this selector */
- private Vector2 drawScale;
-
- /** A reusable definition for creating a mouse joint */
- private MouseJointDef mouseJointDef;
- /** The current mouse joint, if an item is selected */
- private MouseJoint mouseJoint;
-
- /** The region of world space to select an object from */
- private Rectangle pointer;
- /** The amount to multiply by the mass to move the object */
- private float force;
-
- /** Position cache for moving mouse */
- private Vector2 position = new Vector2();
- /** Size cache for the draw scale */
- private Vector2 scaleCache = new Vector2();
-
- /**
- * Returns the response speed of the mouse joint
- *
- * See the documentation of b2JointDef for more information on the response speed.
- *
- * @return the response speed of the mouse joint
- */
- public float getFrequency() {
- return mouseJointDef.frequencyHz;
- }
-
- /**
- * Sets the response speed of the mouse joint
- *
- * See the documentation of b2JointDef for more information on the response speed.
- *
- * @param speed the response speed of the mouse joint
- */
- public void setFrequency(float speed) {
- mouseJointDef.frequencyHz = speed;
- }
-
- /**
- * Returns the damping ratio of the mouse joint
- *
- * See the documentation of b2JointDef for more information on the damping ratio.
- *
- * @return the damping ratio of the mouse joint
- */
- public float getDamping() {
- return mouseJointDef.dampingRatio;
- }
-
- /**
- * Sets the damping ratio of the mouse joint
- *
- * See the documentation of b2JointDef for more information on the damping ratio.
- *
- * @param ration the damping ratio of the mouse joint
- */
- public void setDamping(float ratio) {
- mouseJointDef.dampingRatio = ratio;
- }
-
- /**
- * Returns the force multiplier of the mouse joint
- *
- * The mouse joint will move the attached fixture with a force of this value times
- * the object mass.
- *
- * @return the force multiplier of the mouse joint
- */
- public float getForce() {
- return force;
- }
-
- /**
- * Sets the force multiplier of the mouse joint
- *
- * The mouse joint will move the attached fixture with a force of this value times
- * the object mass.
- *
- * @param force the force multiplier of the mouse joint
- */
- public void setForce(float force) {
- this.force = force;
- }
-
- /**
- * Returns the size of the mouse pointer
- *
- * When a selection is made, this selector will create an axis-aligned bounding box
- * centered at the mouse position. Any fixture overlapping this box will be selected.
- * The size of this box is determined by this value.
- *
- * @return the size of the mouse pointer
- */
- public Vector2 getMouseSize() {
- dimension.set(pointer.width, pointer.height);
- return dimension;
- }
-
- /**
- * Sets the size of the mouse pointer
- *
- * When a selection is made, this selector will create an axis-aligned bounding box centered
- * at the mouse position. Any fixture overlapping this box will be selected. The size of
- * this box is determined by this value.
- *
- * @param width the width of the mouse pointer
- * @param height the height of the mouse pointer
- */
- public void setMouseSize(float width, float height) {
- pointer.width = width;
- pointer.height = height;
- }
-
- /**
- * Creates a new ObstacleSelector for the given World
- *
- * This world can never change. If you want a selector for a different world,
- * make a new instance.
- *
- * This constructor uses the default mouse size.
- *
- * @param world the physics world
- */
- public GameObjectSelector(World world) {
- this(world,DEFAULT_MSIZE,DEFAULT_MSIZE);
- }
-
- /**
- * Creates a new ObstacleSelector for the given World and mouse size.
- *
- * This world can never change. If you want a selector for a different world,
- * make a new instance. However, the mouse size can be changed at any time.
- *
- * @param world the physics world
- * @param width the width of the mouse pointer
- * @param height the height of the mouse pointer
- */
- public GameObjectSelector(World world, float width, float height) {
- this.world = world;
-
- pointer = new Rectangle();
- pointer.width = width;
- pointer.height = height;
-
- mouseJointDef = new MouseJointDef();
-
- mouseJointDef.frequencyHz = DEFAULT_FREQUENCY;
- mouseJointDef.dampingRatio = DEFAULT_DAMPING;
- force = DEFAULT_FORCE;
-
- BodyDef groundDef = new BodyDef();
- groundDef.type = BodyDef.BodyType.StaticBody;
- CircleShape groundShape = new CircleShape();
- groundShape.setRadius(pointer.width);
- ground = world.createBody(groundDef);
- ground.createFixture(groundShape,0);
-
- if (ground != null) {
- FixtureDef groundFixture = new FixtureDef();
- groundFixture.shape = groundShape;
- ground.createFixture(groundFixture);
- }
-
- drawScale = new Vector2(1,1);
- }
-
- /**
- * Returns true if a physics body is currently selected
- *
- * @return true if a physics body is currently selected
- */
- public boolean isSelected() {
- return selection != null;
- }
-
- /**
- * Returns the Obstacle selected (if any)
- *
- * Just because a physics body was selected does not mean that an Obstacle was
- * selected. The body could be a basic Box2d body generated by other means.
- * If the body is not an Obstacle, this method returns nullptr.
- *
- * @return the Obstacle selected (if any)
- */
- public GameObject getObstacle() {
- if (selection != null) {
- Object data = selection.getBody().getUserData();
- try {
- return (GameObject)data;
- } catch (Exception e) {
- }
- }
- return null;
- }
-
- /**
- * Returns true if a physics body was selected at the given position.
- *
- * This method contructs and AABB the size of the mouse pointer, centered at the
- * given position. If any part of the AABB overlaps a fixture, it is selected.
- *
- * @param x the x-coordinate (in physics space) to select
- * @param y the y-coordinate (in physics space) to select
- *
- * @return true if a physics body was selected at the given position.
- */
- public boolean select(float x, float y) {
- pointer.x = x-pointer.width/2.0f;
- pointer.y = y-pointer.height/2.0f;
- world.QueryAABB(this, pointer.x,pointer.y,pointer.x+pointer.width,pointer.y+pointer.height);
- if (selection != null) {
- Body body = selection.getBody();
- mouseJointDef.bodyA = ground;
- mouseJointDef.bodyB = body;
- mouseJointDef.target.set(x,y);
- mouseJointDef.frequencyHz = 5.0f;
- mouseJointDef.dampingRatio = 0.7f;
- mouseJointDef.maxForce = 1000 * body.getMass();
- mouseJoint = (MouseJoint)world.createJoint(mouseJointDef);
- body.setAwake(true);
- }
- return selection != null;
- }
-
- /**
- * Moves the selected body to the given position.
- *
- * @param x the x-coordinate (in physics space) to move to
- * @param y the y-coordinate (in physics space) to move to
- *
- * If nothing is selected, this method does nothing.
- */
- public void moveTo(float x, float y) {
- position.set(x,y);
- if (mouseJoint != null) {
- mouseJoint.setTarget(position);
- }
- }
-
- /**
- * Deselects the physics body, discontinuing any mouse movement.
- *
- * The body may still continue to move of its own accord.
- */
- public void deselect() {
- if (selection != null) {
- world.destroyJoint(mouseJoint);
- selection = null;
- mouseJoint = null;
- }
- }
-
- //// QueryCallback
- /**
- * Called for each fixture found in the query AABB.
- *
- * The AABB is good enough, so we buffere the fixture and stop the query.
- */
- public boolean reportFixture(Fixture fixture) {
- selection = fixture;
- return selection == null;
- }
-
- //// Drawing code
- /**
- * Sets the texture to display the selector on screen
- *
- * @param region the texture to display the selector on screen
- */
- public void setTexture(TextureRegion region) {
- texture = region;
- origin = new Vector2(texture.getRegionWidth()/2.0f,texture.getRegionHeight()/2.0f);
- }
-
- /**
- * Returns the texture to display the selector on screen
- *
- * @return the texture to display the selector on screen
- */
- public TextureRegion getTexture() {
- return texture;
- }
-
- /**
- * Returns the drawing scale for this obstacle selector
- *
- * The drawing scale is the number of pixels to draw before Box2D unit. Because
- * mass is a function of area in Box2D, we typically want the physics objects
- * to be small. So we decouple that scale from the physics object. However,
- * we must track the scale difference to communicate with the scene graph.
- *
- * This method does NOT return a reference to the drawing scale. Changes to this
- * vector will not affect the body. However, it returns the same vector each time
- * its is called, and so cannot be used as an allocator.
-
- * We allow for the scaling factor to be non-uniform.
- *
- * @return the drawing scale for this physics object
- */
- public Vector2 getDrawScale() {
- scaleCache.set(drawScale);
- return scaleCache;
- }
-
- /**
- * Sets the drawing scale for this obstacle selector
- *
- * The drawing scale is the number of pixels to draw before Box2D unit. Because
- * mass is a function of area in Box2D, we typically want the physics objects
- * to be small. So we decouple that scale from the physics object. However,
- * we must track the scale difference to communicate with the scene graph.
- *
- * We allow for the scaling factor to be non-uniform.
- *
- * @param value the drawing scale for this physics object
- */
- public void setDrawScale(Vector2 value) {
- setDrawScale(value.x,value.y);
- }
-
- /**
- * Sets the drawing scale for this physics object
- *
- * The drawing scale is the number of pixels to draw before Box2D unit. Because
- * mass is a function of area in Box2D, we typically want the physics objects
- * to be small. So we decouple that scale from the physics object. However,
- * we must track the scale difference to communicate with the scene graph.
- *
- * We allow for the scaling factor to be non-uniform.
- *
- * @param x the x-axis scale for this physics object
- * @param y the y-axis scale for this physics object
- */
- public void setDrawScale(float x, float y) {
- drawScale.set(x,y);
- }
-
- /**
- * Draws the obstacle selector.
- *
- * @param canvas Drawing context
- */
- public void draw(GameCanvas canvas) {
- if (texture != null) {
- canvas.draw(texture,Color.WHITE,origin.x,origin.y,position.x*drawScale.x,position.y*drawScale.x,0,1,1);
- }
- }
-
-
- }
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/PolygonGameObject.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/PolygonGameObject.java
deleted file mode 100644
index ed018d74..00000000
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/PolygonGameObject.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * PolygonObstacle.java
- *
- * Sometimes boxes and shapes do not cut it. In that case, you have to bring
- * out the polygons. This class is substantially more complex than the other
- * physics objects, but it will allow you to draw arbitrary shapes.
- *
- * Be careful with modifying this file. Even if you have had computer
- * graphics, there are A LOT of subtleties in handling the physics of
- * polygons.
- *
- * Author: Walker M. White
- * Based on original PhysicsDemo Lab by Don Holden, 2007
- * LibGDX version, 2/6/2015
- */
-package edu.cornell.gdiac.rabbeat.obstacles;
-
-import com.badlogic.gdx.utils.*;
-import com.badlogic.gdx.math.*;
-import com.badlogic.gdx.graphics.*;
-import com.badlogic.gdx.graphics.g2d.*;
-import com.badlogic.gdx.physics.box2d.*;
-
-import edu.cornell.gdiac.rabbeat.*; // For GameCanvas
-
-
-/**
- * Arbitrary polygonal-shaped model to support collisions.
- *
- * The polygon coordinates are all in local space, relative to the object
- * center. In addition the texture coordinates are computed automatically
- * from the texture size, using the same policy as PolygonSpriteBatch.
- */
-public class PolygonGameObject extends SimpleGameObject {
- /** An earclipping triangular to make sure we work with convex shapes */
- private static final EarClippingTriangulator TRIANGULATOR = new EarClippingTriangulator();
-
- /** Shape information for this physics object */
- protected PolygonShape[] shapes;
- /** Texture information for this object */
- protected PolygonRegion region;
-
- /** The polygon vertices, scaled for drawing */
- private float[] scaled;
- /** The triangle indices, used for drawing */
- private short[] tridx;
-
- /** A cache value for the fixtures (for resizing) */
- private Fixture[] geoms;
- /** The polygon bounding box (for resizing purposes) */
- private Vector2 dimension;
- /** A cache value for when the user wants to access the dimensions */
- private Vector2 sizeCache;
- /** Cache of the polygon vertices (for resizing) */
- private float[] vertices;
- /** Determines whether the obstacles kills the player on contact*/
- /**
- * Returns the dimensions of this box
- *
- * This method does NOT return a reference to the dimension vector. Changes to
- * this
- * vector will not affect the shape. However, it returns the same vector each
- * time
- * its is called, and so cannot be used as an allocator.
- *
- * @return the dimensions of this box
- */
- public Vector2 getDimension() {
- return sizeCache.set(dimension);
- }
-
- /**
- * Sets the dimensions of this box
- *
- * This method does not keep a reference to the parameter.
- *
- * @param value the dimensions of this box
- */
- public void setDimension(Vector2 value) {
- setDimension(value.x, value.y);
- }
-
- /**
- * Sets the dimensions of this box
- *
- * @param width The width of this box
- * @param height The height of this box
- */
- public void setDimension(float width, float height) {
- resize(width, height);
- markDirty(true);
- }
-
- /**
- * Returns the box width
- *
- * @return the box width
- */
- public float getWidth() {
- return dimension.x;
- }
-
- /**
- * Sets the box width
- *
- * @param value the box width
- */
- public void setWidth(float value) {
- sizeCache.set(value, dimension.y);
- setDimension(sizeCache);
- }
-
- /**
- * Returns the box height
- *
- * @return the box height
- */
- public float getHeight() {
- return dimension.y;
- }
-
- /**
- * Sets the box height
- *
- * @param value the box height
- */
- public void setHeight(float value) {
- sizeCache.set(dimension.x, value);
- setDimension(sizeCache);
- }
-
- /** Getter and setter for the lethal variable, determining whether the obstacle is lethal or not */
-
- /**
- * Creates a (not necessarily convex) polygon at the origin.
- *
- * The points given are relative to the polygon's origin. They
- * are measured in physics units. They tile the image according
- * to the drawScale (which must be set for drawing to work
- * properly).
- *
- * @param points The polygon vertices
- */
- public PolygonGameObject(float[] points) {
- this(points, 0, 0);
- }
-
- /**
- * Creates a (not necessarily convex) polygon
- *
- * The points given are relative to the polygon's origin. They
- * are measured in physics units. They tile the image according
- * to the drawScale (which must be set for drawing to work
- * properly).
- *
- * @param points The polygon vertices
- * @param x Initial x position of the polygon center
- * @param y Initial y position of the polygon center
- */
- public PolygonGameObject(float[] points, float x, float y) {
- super(x, y);
- assert points.length % 2 == 0;
-
- // Compute the bounds.
- initShapes(points);
- initBounds();
-
- }
-
- /**
- * Initializes the bounding box (and drawing scale) for this polygon
- */
- private void initBounds() {
- float minx = vertices[0];
- float maxx = vertices[0];
- float miny = vertices[1];
- float maxy = vertices[1];
-
- for (int ii = 2; ii < vertices.length; ii += 2) {
- if (vertices[ii] < minx) {
- minx = vertices[ii];
- } else if (vertices[ii] > maxx) {
- maxx = vertices[ii];
- }
- if (vertices[ii + 1] < miny) {
- miny = vertices[ii + 1];
- } else if (vertices[ii + 1] > maxy) {
- maxy = vertices[ii + 1];
- }
- }
- dimension = new Vector2((maxx - minx), (maxy - miny));
- sizeCache = new Vector2(dimension);
- }
-
- /**
- * Initializes the Box2d shapes for this polygon
- *
- * If the texture is not null, this method also allocates the PolygonRegion
- * for drawing. However, the points in the polygon region may be rescaled
- * later.
- *
- * @param points The polygon vertices
- */
- private void initShapes(float[] points) {
- // Triangulate
- ShortArray array = TRIANGULATOR.computeTriangles(points);
- trimColinear(points, array);
-
- tridx = new short[array.items.length];
- System.arraycopy(array.items, 0, tridx, 0, tridx.length);
-
- // Allocate space for physics triangles.
- int tris = array.items.length / 3;
- vertices = new float[tris * 6];
- shapes = new PolygonShape[tris];
- geoms = new Fixture[tris];
- for (int ii = 0; ii < tris; ii++) {
- for (int jj = 0; jj < 3; jj++) {
- vertices[6 * ii + 2 * jj] = points[2 * array.items[3 * ii + jj]];
- vertices[6 * ii + 2 * jj + 1] = points[2 * array.items[3 * ii + jj] + 1];
- }
- shapes[ii] = new PolygonShape();
- shapes[ii].set(vertices, 6 * ii, 6);
- }
-
- // Draw the shape with the appropriate scaling factor
- scaled = new float[points.length];
- for (int ii = 0; ii < points.length; ii += 2) {
- scaled[ii] = points[ii] * drawScale.x;
- scaled[ii + 1] = points[ii + 1] * drawScale.y;
- }
- if (texture != null) {
- // WARNING: PolygonRegion constructor by REFERENCE
- region = new PolygonRegion(texture, scaled, tridx);
- }
-
- }
-
- /**
- * Removes colinear vertices from the given triangulation.
- *
- * For some reason, the LibGDX triangulator will occasionally return colinear
- * vertices.
- *
- * @param points The polygon vertices
- * @param indices The triangulation indices
- */
- private void trimColinear(float[] points, ShortArray indices) {
- int colinear = 0;
- for (int ii = 0; ii < indices.size / 3 - colinear; ii++) {
- float t1 = points[2 * indices.items[3 * ii]]
- * (points[2 * indices.items[3 * ii + 1] + 1] - points[2 * indices.items[3 * ii + 2] + 1]);
- float t2 = points[2 * indices.items[3 * ii + 1]]
- * (points[2 * indices.items[3 * ii + 2] + 1] - points[2 * indices.items[3 * ii] + 1]);
- float t3 = points[2 * indices.items[3 * ii + 2]]
- * (points[2 * indices.items[3 * ii] + 1] - points[2 * indices.items[3 * ii + 1] + 1]);
- if (Math.abs(t1 + t2 + t3) < 0.0000001f) {
- indices.swap(3 * ii, indices.size - 3 * colinear - 3);
- indices.swap(3 * ii + 1, indices.size - 3 * colinear - 2);
- indices.swap(3 * ii + 2, indices.size - 3 * colinear - 1);
- colinear++;
- }
- }
- indices.size -= 3 * colinear;
- indices.shrink();
- }
-
- /**
- * Resize this polygon (stretching uniformly out from origin)
- *
- * @param width The new width
- * @param height The new height
- */
- private void resize(float width, float height) {
- float scalex = width / dimension.x;
- float scaley = height / dimension.y;
-
- for (int ii = 0; ii < shapes.length; ii++) {
- for (int jj = 0; jj < 3; jj++) {
- vertices[6 * ii + 2 * jj] *= scalex;
- vertices[6 * ii + 2 * jj + 1] *= scaley;
- }
- shapes[ii].set(vertices, 6 * ii, 6);
- }
-
- // Reset the drawing shape as well
- for (int ii = 0; ii < scaled.length; ii += 2) {
- scaled[ii] *= scalex;
- scaled[ii + 1] *= scaley;
- }
-
- dimension.set(width, height);
- }
-
- /**
- * Create new fixtures for this body, defining the shape
- *
- * This is the primary method to override for custom physics objects
- */
- protected void createFixtures() {
- if (body == null) {
- return;
- }
-
- releaseFixtures();
-
- // Create the fixtures
- for (int ii = 0; ii < shapes.length; ii++) {
- fixture.shape = shapes[ii];
- geoms[ii] = body.createFixture(fixture);
- }
- markDirty(false);
- }
-
- /**
- * Release the fixtures for this body, reseting the shape
- *
- * This is the primary method to override for custom physics objects
- */
- protected void releaseFixtures() {
- if (geoms[0] != null) {
- for (Fixture fix : geoms) {
- body.destroyFixture(fix);
- }
- }
- }
-
- /**
- * Sets the object texture for drawing purposes.
- *
- * In order for drawing to work properly, you MUST set the drawScale.
- * The drawScale converts the physics units to pixels.
- *
- * @param value the object texture for drawing purposes.
- */
- public void setTexture(TextureRegion value) {
- texture = value;
- region = new PolygonRegion(texture, scaled, tridx);
- }
-
- /**
- * Sets the drawing scale for this physics object
- *
- * The drawing scale is the number of pixels to draw before Box2D unit. Because
- * mass is a function of area in Box2D, we typically want the physics objects
- * to be small. So we decouple that scale from the physics object. However,
- * we must track the scale difference to communicate with the scene graph.
- *
- * We allow for the scaling factor to be non-uniform.
- *
- * @param x the x-axis scale for this physics object
- * @param y the y-axis scale for this physics object
- */
- public void setDrawScale(float x, float y) {
- assert x != 0 && y != 0 : "Scale cannot be 0";
- float dx = x / drawScale.x;
- float dy = y / drawScale.y;
- // Reset the drawing shape as well
- for (int ii = 0; ii < scaled.length; ii += 2) {
- scaled[ii] *= dx;
- scaled[ii + 1] *= dy;
- }
- if (texture != null) {
- region = new PolygonRegion(texture, scaled, tridx);
- }
- drawScale.set(x, y);
- }
-
- /**
- * Draws the physics object.
- *
- * @param canvas Drawing context
- */
- public void draw(GameCanvas canvas) {
- if (region != null) {
- canvas.draw(region, Color.WHITE, 0, 0, getX() * drawScale.x, getY() * drawScale.y, getAngle(), 1, 1);
- }
- }
-
- /**
- * Draws the outline of the physics body.
- *
- * This method can be helpful for understanding issues with collisions.
- *
- * @param canvas Drawing context
- */
- public void drawDebug(GameCanvas canvas) {
- for (PolygonShape tri : shapes) {
- canvas.drawPhysics(tri, Color.YELLOW, getX(), getY(), getAngle(), drawScale.x, drawScale.y);
- }
- }
-
-}
\ No newline at end of file
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/SimpleGameObject.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/SimpleGameObject.java
index bf19565d..d7e9a3c2 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/SimpleGameObject.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/SimpleGameObject.java
@@ -34,18 +34,6 @@
*/
public abstract class SimpleGameObject extends GameObject {
- /** Enum type that determines what happens when the player collides with the object*/
- public enum ObjectType {
- /** An obstacle will result in the player slipping and sliding */
- SLIPPERY,
- /** A obstacle that kills the player on contact */
- LETHAL,
- /** An obstacle with no exceptional properties */
- NONE,
-
- }
- private ObjectType type;
-
/** The physics body for Box2D. */
protected Body body;
@@ -68,22 +56,6 @@ public enum ObjectType {
public BodyType getBodyType() {
return (body != null ? body.getType() : super.getBodyType());
}
-
- /** returns the type of the object*/
- public ObjectType getType() {
- return type;
- }
- public void setType(int x){
- if (x==0){
- type = ObjectType.NONE;
- }
- else if (x==1){
- type = ObjectType.LETHAL;
- }
- else if (x==2){
- type = ObjectType.SLIPPERY;
- }
- }
/**
* Returns the body type for Box2D physics
*
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/Type.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/Type.java
new file mode 100644
index 00000000..47a5bf8f
--- /dev/null
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/Type.java
@@ -0,0 +1,11 @@
+package edu.cornell.gdiac.rabbeat.obstacles;
+
+public enum Type {
+ /** Enum type that determines what happens when the player collides with the object*/
+ /** The player*/
+ Player,
+ /** An obstacle that kills the player*/
+ LETHAL,
+ /** An obstacle with no exceptional properties */
+ NONE,
+}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BatEnemy.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BatEnemy.java
index e3a3b832..9cb8ccf8 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BatEnemy.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BatEnemy.java
@@ -1,254 +1,131 @@
package edu.cornell.gdiac.rabbeat.obstacles.enemies;
-import com.badlogic.gdx.ApplicationAdapter;
-import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Animation;
-import com.badlogic.gdx.graphics.g2d.PolygonRegion;
+import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
-import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
-import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
-import com.badlogic.gdx.math.Circle;
-import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.JsonValue;
-import edu.cornell.gdiac.math.Path2;
-import edu.cornell.gdiac.math.Poly2;
-import edu.cornell.gdiac.rabbeat.GameCanvas;
import edu.cornell.gdiac.rabbeat.GameController;
import edu.cornell.gdiac.rabbeat.Genre;
import edu.cornell.gdiac.rabbeat.ObjectController;
-import edu.cornell.gdiac.rabbeat.obstacles.IGenreObject;
-import edu.cornell.gdiac.rabbeat.obstacles.WheelGameObject;
-import edu.cornell.gdiac.rabbeat.sync.Bullet;
-import edu.cornell.gdiac.rabbeat.sync.ISynced;
+import edu.cornell.gdiac.rabbeat.obstacles.projectiles.Bullet;
+import edu.cornell.gdiac.rabbeat.obstacles.projectiles.Echo;
/**
* Bat enemy avatar for the platform game.
- * Bats send echos synced to the beat and players will be hurt if they enter its radius.
+ * Bats send echos synced to the beat and players will be hurt if they enter its
+ * radius.
*/
-public class BatEnemy extends Enemy implements ISynced, IGenreObject {
- private ShapeRenderer shapeRenderer = new ShapeRenderer();
+public class BatEnemy extends Enemy {
+ /** The echo attack the bat will be shooting */
+ public Echo echo;
- /** the radius of attack of the bat's echo */
- private float echoRadius;
+ /** Number of beats the bullet exists in synth */
+ private int synthBulletTime = 3;
+ /** Number of beats the bullet exists in jazz */
+ private int jazzBulletTime = 8;
- /** The idle animation for the bat */
- public Animation batIdleAnimation;
+ /** Scale of the world */
+ private Vector2 scale = GameController.getInstance().getScale();
+
+
+ /** The attack animation in synth for the bear */
+ public Animation attackSynthAnimation;
+ /** The attack animation in jazz for the bear */
+ public Animation attackJazzAnimation;
+
+ /** The echo animation for the bat*/
+ public Animation echoAnimation;
/**
* Creates a bat enemy avatar with the given physics data
*
- * @param data The JsonValue storing information about the bat
- * @param startX The starting x position of the bat
- * @param startY The starting y position of the bat
- * @param width The object width in physics units
- * @param height The object width in physics units
- * @param enemyScale The scale of the bat
- * @param faceRight The direction the bat is facing in
- * @param batIdleAnimation The idle animation for the bat
+ * @param data The physics constants for this enemy
+ * @param width The object width in physics units
+ * @param height The object width in physics units
+ * @param startX The starting x position of the enemy
+ * @param startY The starting y position of the enemy
+ * @param enemyScale The scale of the enemy
+ * @param faceRight The direction the enemy is facing in
+ * @param beatList The list of beats that the enemy reacts to
*/
public BatEnemy(JsonValue data, float startX, float startY, float width, float height, float enemyScale,
- boolean faceRight, Animation batIdleAnimation) {
- super(data, startX, startY, width, height, enemyScale, faceRight, batIdleAnimation);
- setAnimation(batIdleAnimation);
- }
-
- /** Updates the variable curGenre to the current genre of the game */
- public void genreUpdate(Genre genre) {
- curGenre = genre;
+ boolean faceRight, int[] beatList) {
+ super(data, startX, startY, width, height, enemyScale, faceRight, beatList);
+ isFlippable = false;
}
/**
- * Switches the attack state of the bat depending on the beat count.
+ * Switches the attack state of the bear depending on the player's position.
*/
- @Override
public void switchState() {
- switch(enemyState) {
+ switch (enemyState) {
case IDLE:
- if(curGenre.equals(Genre.JAZZ)) {
- if(beatCount == 4) {
- enemyState = EnemyState.ATTACKING;
- }
- } else if(curGenre.equals(Genre.SYNTH)) {
- if(beatCount == 4 || beatCount == 2) {
- enemyState = EnemyState.ATTACKING;
- }
+ if (horizontalDistanceBetweenEnemyAndPlayer() < 16) {
+ enemyState = EnemyState.ATTACKING;
}
break;
case ATTACKING:
- if(curGenre.equals(Genre.JAZZ)) {
- if(beatCount != 4) {
- enemyState = EnemyState.IDLE;
- }
- } else if(curGenre.equals(Genre.SYNTH)) {
- if(beatCount != 4 && beatCount != 2) {
- enemyState = EnemyState.IDLE;
- }
+ if (horizontalDistanceBetweenEnemyAndPlayer() > 16) {
+ enemyState = EnemyState.IDLE;
}
-
break;
}
}
- private int beatCount = 1;
- private float beat = 1;
-
@Override
- public float getBeat() {
- return beat;
+ public void update(float dt) {
+ super.update(dt);
+ animationUpdate();
}
- @Override
- public void beatAction() {
- beatCount++;
- if(beatCount >= 5){
- beatCount = 1;
+ /** Creates a bullet in front of the bear */
+ public void makeEcho() {
+
+ ObjectController oc = GameController.getInstance().objectController;
+ float offset = oc.defaultConstants.get("echo").getFloat("offset", 0);
+ offset *= (isFaceRight() ? 1 : -1);
+ for(int i = 0; i < 2; i++){
+ if(GameController.getInstance().genre == Genre.SYNTH){
+ echo = new Echo(getX() + offset, getY(),
+ 3, .75f, echoAnimation);
+ }
+ else{
+ echo = new Echo(getX(), getY()+ offset,
+ .75f, 2.5f, echoAnimation);
+ echo.vertical = true;
+ }
+ if(i == 1) echo.flipX = !echo.flipX;
+ echo.setSensor(true);
+ echo.setDensity(oc.defaultConstants.get("echo").getFloat("density", 0));
+ echo.setDrawScale(scale);
+ echo.setTexture(oc.echoTexture);
+ echo.setGravityScale(0);
+ GameController.getInstance().instantiateQueue(echo);
+ offset *= -1;
}
- if(enemyState.equals(EnemyState.ATTACKING)) {
- sendEcho();
- }
}
-
- ObjectController oc = GameController.getInstance().objectController;
- /** Scale of the world */
- private Vector2 scale = GameController.getInstance().getScale();
-
- private Bullet bullet;
- /** Tells whether the bear was facing right or not when they shot */
- private boolean shotDirection;
-
-
-
- /** Checks whether the player is within the echo radius */
- public void sendEcho() {
- if(Math.sqrt(Math.pow(horizontalDistanceBetweenEnemyAndPlayer(),2) + Math.pow(verticalDistanceBetweenEnemyAndPlayer(),2)) <= echoRadius) {
- GameController.getInstance().setFailure(true);
- }
- //TODO: visualize the echo
-
-// WheelGameObject w = new WheelGameObject(getX(), getY(), (float) 0.06);
-// GameController.getInstance().instantiateQueue(w);
-
-// ObjectController oc = GameController.getInstance().objectController;
-// float offset = oc.defaultConstants.get("bullet").getFloat("offset",0);
-// offset *= (isFaceRight() ? 1 : -1);
-//
-// float radius = oc.bulletTexture.getRegionWidth()/(2.0f*scale.x);
-// System.out.println("RADIUS: " + radius);
-// System.out.println("ECHORADIUS: " + echoRadius);
-// bullet = new Bullet(getX()+offset, getY(), radius, oc.defaultConstants.get("bullet").getFloat("synth speed", 0),
-// oc.defaultConstants.get("bullet").getFloat("jazz speed", 0), isFaceRight());
-//
-// bullet.setName(getName() + "_bullet");
-// bullet.setDensity(oc.defaultConstants.get("bullet").getFloat("density", 0));
-// bullet.setDrawScale(scale);
-// bullet.setTexture(oc.bulletTexture);
-// bullet.setGravityScale(0);
-// shotDirection = isFaceRight();
-//
-// //Compute position and velocity
-// float speed;
-// int beatcount;
-// if (curGenre == Genre.SYNTH){
-// speed = oc.defaultConstants.get("bullet").getFloat("synth speed", 0);
-// beatcount = 3;
-// }
-// else {
-// speed = oc.defaultConstants.get("bullet").getFloat("jazz speed", 0);
-// beatcount = 8;
-// }
-// speed *= (isFaceRight() ? 1 : -1);
-// bullet.setVX(speed);
-// bullet.beatCount = beatcount;
-// GameController.getInstance().instantiateQueue(bullet);
-//
+ @Override
+ public void Attack() {
+ makeEcho();
}
/**
- * Returns the number of segments necessary for the given tolerance
- *
- * This function is used to compute the number of segments to approximate
- * a radial curve at the given level of tolerance.
- *
- * @param rad The circle radius
- * @param arc The arc in radians
- * @param tol The error tolerance
- *
- * @return the number of segments necessary for the given tolerance
+ * Updates the animation based on the physics state.
*/
- private int curveSegs(float rad, float arc, float tol) {
- float da = (float) (Math.acos(rad / (rad + tol)) * 2.0f);
- return Math.max(2,(int)(Math.ceil(arc/da)));
- }
-
- /** The curve tolerance for rounded shapes */
- private float tolerance = 0.5f;
-
-
- public Poly2 makeEllipse(Poly2 poly, float cx, float cy, float sx, float sy) {
- int segments = curveSegs(Math.max(sx/2.0f,sy/2.0f),2.0f*(float)Math.PI, tolerance);
- float coef = 2.0f * (float)Math.PI/segments;
- int offset = poly.vertices.length/2;
-
- float[] copy = new float[poly.vertices.length+segments*2+2];
- System.arraycopy(poly.vertices, 0, copy, 0, poly.vertices.length);
- for (int i=0; i bearIdleAnimation;
+ /** The attack animation in synth for the bear */
+ public Animation attackSynthAnimation;
+ /** The attack animation in jazz for the bear */
+ public Animation attackJazzAnimation;
/**
* Creates a bear enemy avatar with the given physics data
*
- * @param data The physics constants for this enemy
- * @param width The object width in physics units
- * @param height The object width in physics units
- * @param startX The starting x position of the enemy
- * @param startY The starting y position of the enemy
- * @param enemyScale The scale of the enemy
- * @param faceRight The direction the enemy is facing in
+ * @param data The physics constants for this enemy
+ * @param width The object width in physics units
+ * @param height The object width in physics units
+ * @param startX The starting x position of the enemy
+ * @param startY The starting y position of the enemy
+ * @param enemyScale The scale of the enemy
+ * @param faceRight The direction the enemy is facing in
+ * @param beatList The list of beats that the enemy reacts to
*/
public BearEnemy(JsonValue data, float startX, float startY, float width, float height, float enemyScale,
- boolean faceRight, Animation bearIdleAnimation) {
- super(data, startX, startY, width, height, enemyScale, faceRight, bearIdleAnimation);
- setAnimation(bearIdleAnimation);
+ boolean faceRight, int[] beatList) {
+ super(data, startX, startY, width, height, enemyScale, faceRight, beatList);
}
/**
* Switches the attack state of the bear depending on the player's position.
*/
public void switchState() {
- switch(enemyState) {
+ switch (enemyState) {
case IDLE:
- if(horizontalDistanceBetweenEnemyAndPlayer()<8) {
+ if (horizontalDistanceBetweenEnemyAndPlayer() < 20) {
enemyState = EnemyState.ATTACKING;
}
break;
case ATTACKING:
- if(horizontalDistanceBetweenEnemyAndPlayer()>8) {
+ if (horizontalDistanceBetweenEnemyAndPlayer() > 20) {
enemyState = EnemyState.IDLE;
}
- //TODO: make bear shoot
+ // TODO: make bear shoot
break;
}
}
+ @Override
+ public void update(float dt) {
+ super.update(dt);
+ animationUpdate();
+ }
+
/** Creates a bullet in front of the bear */
- public void makeBullet(){
- //TODO: create a bullet using object controller default values. instantiate the copy using gamecontroller
+ public void makeBullet() {
+ // TODO: create a bullet using object controller default values. instantiate the
+ // copy using gamecontroller
ObjectController oc = GameController.getInstance().objectController;
- float offset = oc.defaultConstants.get("bullet").getFloat("offset",0);
+ float offset = oc.defaultConstants.get("bullet").getFloat("offset", 0);
offset *= (isFaceRight() ? 1 : -1);
- float radius = oc.bulletTexture.getRegionWidth()/(2.0f*scale.x);
- bullet = new Bullet(getX()+offset, getY(), radius, oc.defaultConstants.get("bullet").getFloat("synth speed", 0),
- oc.defaultConstants.get("bullet").getFloat("jazz speed", 0), isFaceRight());
+ float radius = (animationGenre == Genre.SYNTH ?
+ (oc.bulletTexture.getRegionWidth() / (0.3f * scale.x)) :
+ (oc.bulletTexture.getRegionWidth() / (0.24f * scale.x)));
+ bullet = new Bullet(getX() + offset, getY(), radius,
+ oc.defaultConstants.get("bullet").getFloat("synth speed", 0),
+ oc.defaultConstants.get("bullet").getFloat("jazz speed", 0), isFaceRight(),
+ animationGenre);
- bullet.setName(getName() + "_bullet");
bullet.setDensity(oc.defaultConstants.get("bullet").getFloat("density", 0));
bullet.setDrawScale(scale);
- bullet.setTexture(oc.bulletTexture);
+ //bullet.setTexture(oc.bulletTexture);
bullet.setGravityScale(0);
+ bullet.setAnimation(animationGenre == Genre.SYNTH ? oc.bulletSynthAnimation : oc.bulletJazzAnimation);
shotDirection = isFaceRight();
+ int beatcount;
- //Compute position and velocity
+ // Compute position and velocity
float speed;
- int beatcount;
- if (curGenre == Genre.SYNTH){
+ if (GameController.getInstance().genre == Genre.SYNTH) {
speed = oc.defaultConstants.get("bullet").getFloat("synth speed", 0);
- beatcount = synthBulletTime;
- }
- else {
+ beatcount = oc.defaultConstants.get("bullet").getInt("synth bullet time", 0);
+ } else {
speed = oc.defaultConstants.get("bullet").getFloat("jazz speed", 0);
- beatcount = jazzBulletTime;
+ beatcount = oc.defaultConstants.get("bullet").getInt("jazz bullet time", 0);
}
speed *= (isFaceRight() ? 1 : -1);
bullet.setVX(speed);
bullet.beatCount = beatcount;
GameController.getInstance().instantiateQueue(bullet);
}
- public float getBeat() {
- return beat;
- }
public void beatAction() {
- if (enemyState == EnemyState.ATTACKING) {
- makeBullet();
- }
-
+ super.beatAction();
flipEnemy();
}
- /** Updates the variable curGenre to the current genre of the game */
- public void genreUpdate(Genre genre) {
- curGenre = genre;
+ @Override
+ public void Attack() {
+ makeBullet();
}
-
+ /**
+ * Updates the animation based on the physics state.
+ */
+ private void animationUpdate() {
+ if (animation.isAnimationFinished(stateTime)) {
+ stateTime = 0;
+ }
+ switch (animationGenre) {
+ case SYNTH:
+ setAnimation(attackSynthAnimation);
+ break;
+ case JAZZ:
+ setAnimation(attackJazzAnimation);
+ break;
+ }
+ }
}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BeeHive.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BeeHive.java
index feaf15ec..d2cb3723 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BeeHive.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BeeHive.java
@@ -7,16 +7,13 @@
import edu.cornell.gdiac.rabbeat.GameController;
import edu.cornell.gdiac.rabbeat.Genre;
import edu.cornell.gdiac.rabbeat.ObjectController;
-import edu.cornell.gdiac.rabbeat.obstacles.IGenreObject;
-import edu.cornell.gdiac.rabbeat.sync.ISynced;
+import edu.cornell.gdiac.rabbeat.obstacles.projectiles.Bee;
-public class BeeHive extends Enemy implements ISynced, IGenreObject {
-
- public ObjectController objectController;
+public class BeeHive extends Enemy {
ObjectController oc = GameController.getInstance().objectController;
- /** Number of beats the bee exists in synth*/
+ /** Number of beats the bee exists in synth */
private int synthBeeTime = 1;
/** Number of beats the bee exists in jazz */
@@ -28,52 +25,57 @@ public class BeeHive extends Enemy implements ISynced, IGenreObject {
/** Tells whether the hive should shoot bees to the left or right */
private boolean shotDirection;
- public Animation beeAttackAnimation;
-
+ /** The attack animation for the bee */
+ public Animation attackAnimation;
+ /** The attack animation in synth for the bee */
+ public Animation beeAttackSynthAnimation;
/**
* Creates a new bee hive avatar with the given physics data
*
- * @param data The JsonValue storing information about the beehive
- * @param startX The starting x position of the enemy
- * @param startY The starting y position of the enemy
- * @param width The object width in physics units
- * @param height The object width in physics units
- * @param enemyScale The scale of the beehive
- * @param faceRight The direction the beehive is facing in
- * @param animation The idle animation for the beehive
+ * @param data The JsonValue storing information about the beehive
+ * @param startX The starting x position of the enemy
+ * @param startY The starting y position of the enemy
+ * @param width The object width in physics units
+ * @param height The object width in physics units
+ * @param enemyScale The scale of the beehive
+ * @param faceRight The direction the beehive is facing in
+ * @param beatList The list of beats that the enemy reacts to
*/
- public BeeHive(JsonValue data, float startX, float startY, float width, float height, float enemyScale, boolean faceRight, Animation animation, Animation beeAnimation) {
- super(data, startX, startY, width, height, enemyScale, faceRight, animation);
- beeAttackAnimation = beeAnimation;
- setAnimation(animation);
+ public BeeHive(JsonValue data, float startX, float startY, float width, float height, float enemyScale,
+ boolean faceRight, int[] beatList) {
+ super(data, startX, startY, width, height, enemyScale, faceRight, beatList);
+ enemyState = EnemyState.ATTACKING;
+ isFlippable = false;
}
/** Creates a bee in front of the hive */
- public void makeBee(){
- //TODO: create a bullet using object controller default values. instantiate the copy using gamecontroller
+ public void makeBee() {
+ // TODO: create a bullet using object controller default values. instantiate the
+ // copy using gamecontroller
- float offset = oc.defaultConstants.get("bullet").getFloat("offset",0);
+ float offset = oc.defaultConstants.get("bullet").getFloat("offset", 0);
offset *= (isFaceRight() ? 1 : -1);
- float radius = oc.bulletTexture.getRegionWidth()/(2.0f*scale.x);
- BeeEnemy bee = new BeeEnemy(getX()+offset, getY(), radius, beeAttackAnimation);
+ float radius = oc.beeTexture.getRegionWidth() / (5.0f * scale.x);
+ Bee bee = new Bee(getX() + offset, getY(), radius, beeAttackSynthAnimation);
bee.setName(getName() + "_bee");
bee.setDensity(oc.defaultConstants.get("bullet").getFloat("density", 0));
bee.setDrawScale(scale);
- bee.setTexture(oc.bulletTexture);
+
+ bee.setSensor(true);
+ bee.setTexture(oc.beeTexture);
bee.setGravityScale(0);
shotDirection = isFaceRight();
- //Compute position and velocity
+ // Compute position and velocity
float speed = 2.5f;
int beatcount;
- if (curGenre == Genre.SYNTH){
+ if (GameController.getInstance().genre == Genre.SYNTH) {
beatcount = synthBeeTime;
- bee.setVY(2);
- }
- else {
+ bee.setVY(4);
+ } else {
beatcount = jazzBeeTime;
- bee.setVY(1);
+ bee.setVY(2);
}
speed *= (isFaceRight() ? 1 : -1);
bee.setVX(speed);
@@ -82,23 +84,28 @@ public void makeBee(){
}
@Override
- public void genreUpdate(Genre genre) {
- curGenre = genre;
+ public void update(float dt) {
+ super.update(dt);
+ animationUpdate();
}
@Override
public void switchState() {
-
}
@Override
- public float getBeat() {
- return 0.25f;
+ public void Attack() {
+ makeBee();
+ //setFaceRight(playerXPosition() - getPosition().x > 0);
}
- @Override
- public void beatAction() {
- makeBee();
- setFaceRight(playerXPosition() - getPosition().x > 0);
+ /**
+ * Updates the animation based on the physics state.
+ */
+ private void animationUpdate() {
+ setAnimation(attackAnimation);
+ if (animation.isAnimationFinished(stateTime)) {
+ stateTime = 0;
+ }
}
}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/Enemy.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/Enemy.java
index 2cc42c80..3560f650 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/Enemy.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/Enemy.java
@@ -2,38 +2,32 @@
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import com.badlogic.gdx.utils.Array;
import edu.cornell.gdiac.rabbeat.GameCanvas;
import edu.cornell.gdiac.rabbeat.GameController;
import edu.cornell.gdiac.rabbeat.Genre;
import edu.cornell.gdiac.rabbeat.obstacles.CapsuleGameObject;
-import com.badlogic.gdx.math.*;
import com.badlogic.gdx.graphics.*;
-import com.badlogic.gdx.physics.box2d.*;
-//package edu.cornell.gdiac.physics.platform;
import com.badlogic.gdx.utils.JsonValue;
+import edu.cornell.gdiac.rabbeat.obstacles.IGenreObject;
+import edu.cornell.gdiac.rabbeat.obstacles.Type;
import edu.cornell.gdiac.rabbeat.sync.ISyncedAnimated;
/**
* Enemy parent class for the platform game.
*/
-public abstract class Enemy extends CapsuleGameObject implements ISyncedAnimated {
+public abstract class Enemy extends CapsuleGameObject implements ISyncedAnimated, IGenreObject {
/** Enum containing the state of the enemy */
- protected enum EnemyState{
+ protected enum EnemyState {
IDLE,
ATTACKING
}
- /** Current genre that the game is on */
- public Genre curGenre = Genre.SYNTH;
-
/** The scale of the enemy */
private float enemyScale;
- /** The physics shape of this object */
- private PolygonShape sensorShape;
-
/** Whether the enemy is facing right */
private boolean faceRight;
@@ -42,41 +36,65 @@ protected enum EnemyState{
/** The enemy's current animation */
public Animation animation;
-
/** The elapsed time for animationUpdate */
- private float stateTime = 0;
+ protected float stateTime = 0;
+ /** Holds the genre of the ANIMATION. Doesn't specifically detect genre. */
+ protected Genre animationGenre;
+
+ /** Whether the enemy is flippable */
+ protected boolean isFlippable = true;
+
+ /**
+ * The beat counter for an enemy. The beat counter cycles integers values
+ * starting from 1
+ * and incrementing to 8 (2 measures)
+ */
+ private float beat = 1;
+ public int beatCount = 1;
+ /**
+ * A list of beats in which the enemies act when called in beatAction. Default
+ * for enemies is
+ * acting on the downbeat (beatCount counts to 8 so the downbeats are 1 and 5)
+ */
+ public int[] beatList;
- //range: how far away player is --> beat action called whenever an action is supposed to hapepn on beat
- //create switch states (wandering, shooting, etc). ENUM
+ /** The index to cycle through beatList */
+ public int beatListIndex;
+ // range: how far away player is --> beat action called whenever an action is
+ // supposed to hapepn on beat
+ // create switch states (wandering, shooting, etc). ENUM
/**
* Creates a new enemy avatar with the given physics data
*
- * @param data The physics constants for this enemy
- * @param startX The starting x position of the enemy
- * @param startY The starting y position of the enemy
- * @param width The object width in physics units
- * @param height The object width in physics units
- * @param enemyScale The scale of the enemy
- * @param faceRight The direction the enemy is facing in
- * @param animation The animation texture for the enemy
+ * @param data The physics constants for this enemy
+ * @param startX The starting x position of the enemy
+ * @param startY The starting y position of the enemy
+ * @param width The object width in physics units
+ * @param height The object width in physics units
+ * @param enemyScale The scale of the enemy
+ * @param faceRight The direction the enemy is facing in
+ * @param beatList The list of beats that the enemy reacts to
*/
- public Enemy(JsonValue data, float startX, float startY, float width, float height, float enemyScale, boolean faceRight, Animation animation) {
+ public Enemy(JsonValue data, float startX, float startY,
+ float width, float height, float enemyScale, boolean faceRight, int[] beatList) {
// The shrink factors fit the image to a tigher hitbox
super(startX, startY,
- width*data.get("shrink").getFloat( 0 ),
- height*data.get("shrink").getFloat( 1 ));
+ width * data.get("shrink").getFloat(0),
+ height * data.get("shrink").getFloat(1));
setDensity(data.getFloat("density", 0));
setFriction(data.getFloat("friction", 0));
setFixedRotation(true);
- //setType(data.getString("type"));
+ // setType(data.getString("type"));
+ animationGenre = Genre.SYNTH;
this.faceRight = faceRight; // should face the direction player is in?
this.enemyScale = enemyScale;
-
+ this.beatList = beatList;
+ setType(Type.LETHAL);
setName("enemy");
}
@@ -87,21 +105,15 @@ public boolean isFaceRight() {
return faceRight;
}
- /**
- * Implement this with any updates necessary after the genre switches.
- */
- public abstract void genreUpdate(Genre genre);
-
/**
* Updates the object's physics state (NOT GAME LOGIC).
*
* We use this method to reset cooldowns.
*
- * @param dt Number of seconds since last animation frame
+ * @param dt Number of seconds since last animation frame
*/
public void update(float dt) {
switchState();
- stateTime += dt;
super.update(dt);
}
@@ -111,10 +123,10 @@ public void update(float dt) {
* @param canvas Drawing context
*/
public void draw(GameCanvas canvas) {
- float effect = faceRight ? -1.0f : 1.0f;
+ float effect = (faceRight && isFlippable) ? -1.0f : 1.0f;
TextureRegion currentFrame = animation.getKeyFrame(stateTime, true);
- canvas.draw(currentFrame, Color.WHITE,origin.x,origin.y,getX()*drawScale.x,getY()*drawScale.y,getAngle(),
- enemyScale*effect,enemyScale);
+ canvas.draw(currentFrame, Color.WHITE, origin.x, origin.y, getX() * drawScale.x, getY() * drawScale.y,
+ getAngle(), enemyScale * effect, enemyScale);
}
/**
@@ -126,7 +138,7 @@ public void draw(GameCanvas canvas) {
*/
public void drawDebug(GameCanvas canvas) {
super.drawDebug(canvas);
- //canvas.drawPhysics(sensorShape,Color.RED,getX(),getY(),getAngle(),drawScale.x,drawScale.y);
+ // canvas.drawPhysics(sensorShape,Color.RED,getX(),getY(),getAngle(),drawScale.x,drawScale.y);
}
/** Sets the direction that the enemy is facing in */
@@ -140,22 +152,21 @@ public boolean getFaceRight() {
}
/** Returns the horizontal distance between the enemy and the player */
- public float horizontalDistanceBetweenEnemyAndPlayer(){
+ public float horizontalDistanceBetweenEnemyAndPlayer() {
return Math.abs(playerXPosition() - getPosition().x);
}
/** Returns the vertical distance between the enemy and the player */
- public float verticalDistanceBetweenEnemyAndPlayer(){
+ public float verticalDistanceBetweenEnemyAndPlayer() {
return Math.abs(playerYPosition() - getPosition().y);
}
/** Switches enemy attacking state depending on its current state */
public abstract void switchState();
-
/** Returns the x position of the player */
- public float playerXPosition(){
- if(GameController.getInstance() != null) {
+ public float playerXPosition() {
+ if (GameController.getInstance() != null) {
return GameController.getInstance().getPlayer().getPosition().x;
}
@@ -163,39 +174,65 @@ public float playerXPosition(){
}
/** Returns the y position of the player */
- public float playerYPosition(){
- if(GameController.getInstance() != null) {
+ public float playerYPosition() {
+ if (GameController.getInstance() != null) {
return GameController.getInstance().getPlayer().getPosition().y;
}
return 0;
}
-
/** Flips the direction the enemy is facing based on the player's position */
public void flipEnemy() {
- if( playerXPosition() - getPosition().x > 0 && !faceRight) {
+ if (playerXPosition() - getPosition().x > 0 && !faceRight) {
setFaceRight(true);
- setPosition(getX()+1, getY());
- } else if( playerXPosition() - getPosition().x < 0 && faceRight) {
+ setPosition(getX() + 1, getY());
+ } else if (playerXPosition() - getPosition().x < 0 && faceRight) {
setFaceRight(false);
- setPosition(getX()-1, getY());
+ setPosition(getX() - 1, getY());
}
}
- private String type;
- public void setType (String type) {
- this.type = type;
- }
-
- public void setAnimation(Animation animation){
+ public void setAnimation(Animation animation) {
this.animation = animation;
}
- public void updateAnimationFrame(){
+ public void updateAnimationFrame() {
stateTime++;
}
- public float getBeat() {return 1;}
- public void beatAction(){}
+ public void genreUpdate(Genre genre) {
+ // TODO: Change sprites to reflect the genre
+ animationGenre = genre;
+ if (GameController.getInstance().genre == Genre.SYNTH) {
+ // change to synth sprite
+ } else {
+ // change to jazz sprite
+ }
+ }
+
+ @Override
+ public float getBeat() {
+ return beat;
+ }
+
+ public void beatAction() {
+ beatCount++;
+ if (beatCount >= 9) {
+ beatCount = 1;
+ }
+ if (beatList[beatListIndex] == beatCount) {
+ if (enemyState == EnemyState.ATTACKING) {
+ Attack();
+ beatListIndex++;
+ if (beatListIndex >= beatList.length) {
+ beatListIndex = 0;
+ }
+ }
+ }
+
+ }
+
+ /** The function called whenever the enemy is supposed to attack */
+ public abstract void Attack();
}
\ No newline at end of file
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/HedgehogEnemy.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/HedgehogEnemy.java
index c984b9ce..3f78425c 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/HedgehogEnemy.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/HedgehogEnemy.java
@@ -3,19 +3,18 @@
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.JsonValue;
+import edu.cornell.gdiac.rabbeat.GameController;
import edu.cornell.gdiac.rabbeat.Genre;
import edu.cornell.gdiac.rabbeat.obstacles.IGenreObject;
import edu.cornell.gdiac.rabbeat.sync.ISynced;
/**
* Hedgehog enemy avatar for the platform game.
- * Hedgehogs roll back and forth along a platform and are lethal if they collide with the player.
+ * Hedgehogs roll back and forth along a platform and are lethal if they collide
+ * with the player.
*/
public class HedgehogEnemy extends Enemy implements ISynced, IGenreObject {
- /** The distance that the hedgehog rolls */
- private final float rollingDistance;
-
/** The endpoint equivalent to the hedgehog's starting position */
private final float point1 = getX();
@@ -25,108 +24,66 @@ public class HedgehogEnemy extends Enemy implements ISynced, IGenreObject {
/** The distance the hedgehog moves every update frame */
private float distance = 0.1f;
- //TODO: delete?
- /** The angle orientation of the hedgehog */
- private float angle = 5;
-
/** The boolean that represents the direction that the hedgehog is rolling in */
private boolean rollingRight = false;
/** The boolean for whether the hedgehog is in rolling mode */
private boolean roll = false;
+ /** The attack animation in synth for the hedgehog */
+ public Animation attackSynthAnimation;
+
/**
* Creates a new enemy avatar with the given physics data
*
- * @param data The JsonValue storing information about the hedgehog
- * @param startX The starting x position of the enemy
- * @param startY The starting y position of the enemy
- * @param rollingDistance The distance which the hedgehog will roll
- * @param width The object width in physics units
- * @param height The object width in physics units
- * @param enemyScale The scale of the hedgehog
- * @param faceRight The direction the hedgehog is facing in
- * @param hedgehogIdleAnimation The idle animation for the hedgehog
+ * @param data The JsonValue storing information about the
+ * hedgehog
+ * @param startX The starting x position of the enemy
+ * @param startY The starting y position of the enemy
+ * @param rollingDistance The distance which the hedgehog will roll
+ * @param width The object width in physics units
+ * @param height The object width in physics units
+ * @param enemyScale The scale of the hedgehog
+ * @param faceRight The direction the hedgehog is facing in
+ * @param beatList The list of beats that the enemy reacts to
*/
public HedgehogEnemy(JsonValue data, float startX, float startY, int rollingDistance, float width, float height,
- float enemyScale, boolean faceRight,
- Animation hedgehogIdleAnimation) {
- super(data, startX, startY, width, height, enemyScale, faceRight, hedgehogIdleAnimation);
- setAnimation(hedgehogIdleAnimation);
- this.rollingDistance = rollingDistance;
+ float enemyScale, boolean faceRight, int[] beatList) {
+ super(data, startX, startY, width, height, enemyScale, faceRight, beatList);
point2 = getX() - rollingDistance;
}
-
- /** Updates the variable curGenre to the current genre of the game */
- public void genreUpdate(Genre genre) {
- curGenre = genre;
- }
-
- @Override
+
public void switchState() {
- switch(enemyState) {
+ switch (enemyState) {
case IDLE:
- if(curGenre.equals(Genre.JAZZ)) {
- if(beatCount == 4) {
- enemyState = EnemyState.ATTACKING;
- }
- } else if(curGenre.equals(Genre.SYNTH)) {
- if(beatCount == 4 || beatCount == 2) {
- enemyState = EnemyState.ATTACKING;
- }
+ if (horizontalDistanceBetweenEnemyAndPlayer() < 8) {
+ enemyState = EnemyState.ATTACKING;
}
break;
case ATTACKING:
- if(curGenre.equals(Genre.JAZZ)) {
- if(beatCount != 4) {
- enemyState = EnemyState.IDLE;
- }
- } else if(curGenre.equals(Genre.SYNTH)) {
- if(beatCount != 4 && beatCount != 2) {
- enemyState = EnemyState.IDLE;
- }
+ if (horizontalDistanceBetweenEnemyAndPlayer() > 8) {
+ enemyState = EnemyState.IDLE;
}
+ // TODO: make bear shoot
break;
}
}
- private int beatCount = 1;
- private float beat = 1;
-
- @Override
- public float getBeat() {
- return beat;
- }
-
- @Override
- public void beatAction() {
- beatCount++;
- if(beatCount >= 5){
- beatCount = 1;
- }
-
- if(enemyState.equals(EnemyState.ATTACKING)) {
- roll = true;
- }
- }
-
@Override
public void update(float dt) {
super.update(dt);
- //setVX(-1);
-
- if(roll) {
- if(rollingRight) {
- setPosition(getX()+distance, getY());
- //setAngle(angle);
+ if (roll) {
+ if (rollingRight) {
+ setPosition(getX() + distance, getY());
+ // setAngle(angle);
} else {
- setPosition(getX()-distance, getY());
- //setAngle(angle);
+ setPosition(getX() - distance, getY());
+ // setAngle(angle);
}
}
+ if (getX() >= point1) {
- if(getX() >= point1) {
rollingRight = false;
roll = false;
} else if (getX() <= point2) {
@@ -134,10 +91,34 @@ public void update(float dt) {
roll = false;
}
- if(curGenre == Genre.SYNTH) {
+ if (GameController.getInstance().genre == Genre.SYNTH) {
distance = 0.1f;
} else {
distance = 0.05f;
}
+ animationUpdate();
+ }
+
+ @Override
+ public void Attack() {
+ roll = true;
}
+
+ /**
+ * Updates the animation based on the physics state.
+ */
+ private void animationUpdate() {
+ if (animation.isAnimationFinished(stateTime)) {
+ stateTime = 0;
+ }
+ switch (animationGenre) {
+ case SYNTH:
+ setAnimation(attackSynthAnimation);
+ break;
+ case JAZZ:
+ setAnimation(attackSynthAnimation);
+ break;
+ }
+ }
+
}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/SyncedProjectile.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/SyncedProjectile.java
deleted file mode 100644
index 89eb38dd..00000000
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/SyncedProjectile.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package edu.cornell.gdiac.rabbeat.obstacles.enemies;
-
-import edu.cornell.gdiac.rabbeat.Genre;
-import edu.cornell.gdiac.rabbeat.obstacles.WheelGameObject;
-
-abstract public class SyncedProjectile extends WheelGameObject {
- public SyncedProjectile(float x, float y, float radius){
- super(x, y, radius);
- }
-
- public abstract void genreUpdate(Genre genre);
-}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/platforms/MovingPlatform.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/platforms/MovingPlatform.java
index ce2b0794..a54503d9 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/platforms/MovingPlatform.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/platforms/MovingPlatform.java
@@ -1,11 +1,11 @@
package edu.cornell.gdiac.rabbeat.obstacles.platforms;
-import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import edu.cornell.gdiac.rabbeat.Genre;
import edu.cornell.gdiac.rabbeat.obstacles.BoxGameObject;
import edu.cornell.gdiac.rabbeat.obstacles.IGenreObject;
+import edu.cornell.gdiac.rabbeat.sync.ISynced;
/**
* WeightedPlatform.java
@@ -13,11 +13,13 @@
* This class provides a weighted platform which changes location depending on the genre.
*/
-public class MovingPlatform extends BoxGameObject implements IGenreObject {
+public class MovingPlatform extends BoxGameObject implements IGenreObject, ISynced {
/** Position for the weighted platform when the game is in Synth mode **/
private Vector2[] positionNodes;
- /** The speed at which the platform moves at**/
- private float platformSpeed;
+ /** How many 4 beat intervals the platform waits at each node**/
+ private int beatWait;
+ /**How long it takes the platform to move from node to node, changing the */
+ private int moveTime = 1;
/** the direction the platform is moving in*/
private Vector2 velocity;
/**The next platform in positionNodes that the platform is moving to*/
@@ -28,7 +30,19 @@ public class MovingPlatform extends BoxGameObject implements IGenreObject {
boolean moving;
/**The distance the platform should 'lock on' to its destination */
- private float LOCKDIST = 0.1f;
+ private float LOCKDIST = 0.05f;
+ /**Keeps track of the which beat the platform is on*/
+ private int beat = 0;
+ /**How fast the platform should be currently moving*/
+ private float currentSpeed=1.0f;
+ /**Stores the BPM of the current level*/
+ private int BPM = 180;
+
+ /**Determines the speed of the platform on each frame */
+ private float SPEEDBEAT6 = (float) 3*1 /10;
+ private float SPEEDBEAT7 = (float) 2*3 /10;
+ private float SPEEDBEAT8 = (float) 2*6 /10;
+
/**
* Creates a new moving platform with the given physics data and current genre.
@@ -36,25 +50,32 @@ public class MovingPlatform extends BoxGameObject implements IGenreObject {
* @param width The width of the moving platform
* @param height The height of the moving platform
* @param nodes The points where the platform goes to, must be of even length
- * @param speed The speed of the platform
+ * @param beatWaitTime The number of 4 beat intervals the platform waits at each position
* @param texture The texture region for the platform
*/
- public MovingPlatform(float width, float height, Vector2[] nodes, float speed, TextureRegion texture) {
+ public MovingPlatform(float width, float height, Vector2[] nodes, int beatWaitTime, int beatMoveTime, TextureRegion texture) {
super(nodes[0].x, nodes[0].y, width, height);
- platformSpeed = speed;
+ beatWait = beatWaitTime;
positionNodes = nodes;
destination = 1;
home = 0;
setTexture(texture);
setPosition(positionNodes[0]);
- velocity = direction(positionNodes[home], positionNodes[destination], platformSpeed);
+ velocity = direction(positionNodes[home], positionNodes[destination], 2);
+ System.out.println("beatMovTime is");
+ System.out.println(beatMoveTime);
moving = true;
+ moveTime = (int) Math.pow(2, beatMoveTime);
+ System.out.println("movtime is");
+ System.out.println(moveTime);
}
/** updates the platform to determine what direction it should be moving in */
public void update(float delta){
if(moving){
- if ((magnitude(getPosition(), positionNodes[destination])0){
+ currentSpeed = (magnitude(jazzPosition, synthPosition)*(1/BeatLength)*SPEEDBEAT7*((float) 1 /(1+ (float) platformIntervals /2)));
+ }
+ else if (beat == (4+4* waitTime)){
+ if (currentSpeed>0){
+ currentSpeed = (magnitude(jazzPosition, synthPosition)*(1/BeatLength)*SPEEDBEAT8*((float) 1 /(1+ (float) platformIntervals /2)));
+ }
+ beat = 0;
+ }
+ }
@Override
public void genreUpdate(Genre genre) {
move(genre);
@@ -128,15 +191,4 @@ public void move(Genre genre) {
break;
}
}
- public float magnitude(Vector2 pos1, Vector2 pos2){
- double magnitude = Math.sqrt(Math.pow((pos1.x - pos2.x),2)+
- Math.pow((pos1.y-pos2.y),2));
- return (float) magnitude;
- }
-
- public Vector2 direction(Vector2 pos1, Vector2 pos2, float speed){
- float magnitude = magnitude(pos1, pos2);
- return new Vector2((pos1.x - pos2.x)*speed/magnitude,
- (pos1.y-pos2.y)*speed/magnitude);
- }
}
\ No newline at end of file
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BeeEnemy.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/projectiles/Bee.java
similarity index 62%
rename from core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BeeEnemy.java
rename to core/src/edu/cornell/gdiac/rabbeat/obstacles/projectiles/Bee.java
index 16074e6c..87913ba9 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/obstacles/enemies/BeeEnemy.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/projectiles/Bee.java
@@ -1,4 +1,4 @@
-package edu.cornell.gdiac.rabbeat.obstacles.enemies;
+package edu.cornell.gdiac.rabbeat.obstacles.projectiles;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Animation;
@@ -6,24 +6,51 @@
import edu.cornell.gdiac.rabbeat.GameCanvas;
import edu.cornell.gdiac.rabbeat.Genre;
import edu.cornell.gdiac.rabbeat.obstacles.IGenreObject;
+import edu.cornell.gdiac.rabbeat.obstacles.Type;
import edu.cornell.gdiac.rabbeat.obstacles.WheelGameObject;
import edu.cornell.gdiac.rabbeat.sync.ISynced;
+import edu.cornell.gdiac.rabbeat.sync.ISyncedAnimated;
-public class BeeEnemy extends WheelGameObject implements ISynced, IGenreObject {
+
+public class Bee extends WheelGameObject implements ISynced, IGenreObject {
public int beatCount = 0;
+ private float hiveY;
+ private boolean switched = false;
public Animation animation;
public Genre curGenre = Genre.SYNTH;
/** The elapsed time for animationUpdate */
private float stateTime = 0;
- public BeeEnemy(float x, float y, float radius, Animation beeAttackAnimation) {
-
+ public Bee(float x, float y, float radius, Animation beeAttackAnimation) {
super(x, y, radius);
+ hiveY = y;
setAnimation(beeAttackAnimation);
+ setType(Type.LETHAL);
+ setSensor(true);
}
public void update(float dt) {
stateTime += dt;
+ if (getY() == hiveY){
+ if (switched == true){
+ if (curGenre == Genre.SYNTH){
+ if (getVY() < 0){
+ setVY(-4);
+ }
+ else{
+ setVY(4);
+ }
+ }
+ else{
+ if (getVY() < 0){
+ setVY(-2);
+ }
+ else{
+ setVY(2);
+ }
+ }
+ }
+ }
super.update(dt);
}
@@ -34,33 +61,14 @@ public float getBeat() {
@Override
public void beatAction() {
-
beatCount++;
- if (curGenre == Genre.SYNTH) {
- if (getVY() < 0){
- setVY(2);
- }
- else{
- setVY(-2);
- }
- //setVY(getVY() * -1);
- }
- else {
- if (getVY() < 0){
- setVY(1);
- }
- else{
- setVY(-1);
- }
-// if (beatCount % 2 == 0) {
-// setVY(getVY() * -1);
-// }
- }
+ setVY(getVY() * -1);
}
@Override
public void genreUpdate(Genre genre) {
-// curGenre = genre;
+ curGenre = genre;
+ switched = true;
// if (genre == Genre.SYNTH){
// if (getVY() < 0){
// setVY(-2);
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/projectiles/Bullet.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/projectiles/Bullet.java
new file mode 100644
index 00000000..41b95fb4
--- /dev/null
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/projectiles/Bullet.java
@@ -0,0 +1,59 @@
+package edu.cornell.gdiac.rabbeat.obstacles.projectiles;
+import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.graphics.g2d.Animation;
+import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import edu.cornell.gdiac.rabbeat.GameCanvas;
+import edu.cornell.gdiac.rabbeat.obstacles.Type;
+import edu.cornell.gdiac.rabbeat.obstacles.WheelGameObject;
+import edu.cornell.gdiac.rabbeat.sync.ISynced;
+import edu.cornell.gdiac.rabbeat.sync.ISyncedAnimated;
+import edu.cornell.gdiac.rabbeat.Genre;
+
+public class Bullet extends WheelGameObject implements ISynced, ISyncedAnimated {
+ public int beatCount = 0;
+
+ private float stateTime = 0;
+ public Genre bulletGenre;
+
+ private Animation animation;
+
+ public Bullet(float x, float y, float radius, float synthVX, float jazzVX, boolean fr, Genre genre) {
+ super(x, y, radius);
+ float dir = (fr ? 1 : -1);
+ bulletGenre = genre;
+ setType(Type.LETHAL);
+ //setSensor(true);
+ }
+
+ @Override
+ public float getBeat() {
+ return 1;
+ }
+
+ @Override
+ public void setAnimation(Animation anim) {
+ animation = anim;
+ }
+
+ @Override
+ public void updateAnimationFrame() {
+ stateTime++;
+ if (animation.isAnimationFinished(stateTime)) {
+ stateTime = 0;
+ }
+ }
+
+ @Override
+ public void beatAction() {
+ beatCount--;
+ if (beatCount <= 0) {
+ markRemoved(true);
+ }
+ }
+
+ public void draw(GameCanvas canvas) {
+ TextureRegion currentFrame = (TextureRegion) animation.getKeyFrame(stateTime, true);
+ canvas.draw(currentFrame, Color.WHITE,origin.x + 30,origin.y + (bulletGenre == Genre.SYNTH ? 35 : 50),getX()*drawScale.x,getY()*drawScale.y,getAngle(), 1.2f,1.2f);
+ }
+
+}
\ No newline at end of file
diff --git a/core/src/edu/cornell/gdiac/rabbeat/obstacles/projectiles/Echo.java b/core/src/edu/cornell/gdiac/rabbeat/obstacles/projectiles/Echo.java
new file mode 100644
index 00000000..08e1802e
--- /dev/null
+++ b/core/src/edu/cornell/gdiac/rabbeat/obstacles/projectiles/Echo.java
@@ -0,0 +1,58 @@
+package edu.cornell.gdiac.rabbeat.obstacles.projectiles;
+
+import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.graphics.g2d.Animation;
+import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import edu.cornell.gdiac.rabbeat.GameCanvas;
+import edu.cornell.gdiac.rabbeat.obstacles.BoxGameObject;
+import edu.cornell.gdiac.rabbeat.obstacles.Type;
+import edu.cornell.gdiac.rabbeat.sync.ISyncedAnimated;
+
+
+public class Echo extends BoxGameObject implements ISyncedAnimated {
+
+ public int beatCount = 4;
+
+ public Animation animation;
+ /** The elapsed time for animationUpdate */
+ private float stateTime = 0;
+ public boolean flipX = false;
+
+ public boolean flipY = false;
+
+ public boolean vertical = false;
+
+ public Echo(float x, float y, float width, float height, Animation _animation) {
+ super(x, y, width, height);
+ setAnimation(_animation);
+ setType(Type.LETHAL);
+ setSensor(true);
+ }
+
+ @Override
+ public float getBeat() {
+ return 1;
+ }
+
+ @Override
+ public void beatAction() {
+ beatCount--;
+ if (beatCount <= 0) {
+ markRemoved(true);
+ }
+ }
+ public void setAnimation(Animation animation){
+ this.animation = animation;
+ }
+ public void updateAnimationFrame(){
+ stateTime++;
+ }
+ public void draw(GameCanvas canvas) {
+ TextureRegion currentFrame = animation.getKeyFrame(stateTime, true);
+ float scaleX = flipX ? -1 : 1;
+ float scaleY = flipY ? -1 : 1;
+ float rotate = vertical ? (float)(Math.PI/2) : 0;
+ canvas.draw(currentFrame, Color.WHITE,origin.x,origin.y,getX()*drawScale.x,getY()*drawScale.y,
+ getAngle() + rotate, scaleX,scaleY);
+ }
+}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/sync/AnimationSync.java b/core/src/edu/cornell/gdiac/rabbeat/sync/AnimationSync.java
index 4dcf9a7f..180e3100 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/sync/AnimationSync.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/sync/AnimationSync.java
@@ -11,7 +11,7 @@ public class AnimationSync implements ISynced{
/** The animated objects that need to be synced with the game*/
public Array animatedObjects = new Array<>();
/** Number of frames that play per beat */
- float ANIMATION_FPB = 4.0f;
+ float ANIMATION_FPB = 3.0f;
@Override
public float getBeat() {
diff --git a/core/src/edu/cornell/gdiac/rabbeat/sync/BeatTest.java b/core/src/edu/cornell/gdiac/rabbeat/sync/BeatTest.java
index 508826ab..562c2778 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/sync/BeatTest.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/sync/BeatTest.java
@@ -15,6 +15,5 @@ public void beatAction() {
if(beatCount >= 5){
beatCount = 1;
}
- System.out.println(beatCount);
}
}
diff --git a/core/src/edu/cornell/gdiac/rabbeat/sync/Bullet.java b/core/src/edu/cornell/gdiac/rabbeat/sync/Bullet.java
deleted file mode 100644
index f4cc145b..00000000
--- a/core/src/edu/cornell/gdiac/rabbeat/sync/Bullet.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package edu.cornell.gdiac.rabbeat.sync;
-import com.badlogic.gdx.graphics.g2d.TextureRegion;
-import com.badlogic.gdx.utils.JsonValue;
-import edu.cornell.gdiac.rabbeat.Genre;
-import edu.cornell.gdiac.rabbeat.obstacles.WheelGameObject;
-import edu.cornell.gdiac.rabbeat.obstacles.enemies.SyncedProjectile;
-
-public class Bullet extends WheelGameObject implements ISynced {
- public int beatCount = 0;
-
- public Bullet(float x, float y, float radius, float synthVX, float jazzVX, boolean fr) {
- super(x, y, radius);
- float dir = (fr ? 1 : -1);
- }
-
- @Override
- public float getBeat() {
- return 1;
- }
-
- @Override
- public void beatAction() {
- beatCount--;
- if (beatCount <= 0) {
- markRemoved(true);
- }
- }
-
-}
\ No newline at end of file
diff --git a/core/src/edu/cornell/gdiac/rabbeat/sync/SyncController.java b/core/src/edu/cornell/gdiac/rabbeat/sync/SyncController.java
index 275c4c47..0bb170ba 100644
--- a/core/src/edu/cornell/gdiac/rabbeat/sync/SyncController.java
+++ b/core/src/edu/cornell/gdiac/rabbeat/sync/SyncController.java
@@ -3,6 +3,12 @@
import com.badlogic.gdx.utils.*;
public class SyncController {
+ /**
+ * The purpose of this class is to track all synced objects in the game and update them appropriately.
+ * This is achieved by taking in all synced objects and creating a list of intervals representing
+ * each synced object. in the update loop of {@link edu.cornell.gdiac.rabbeat.GameController},
+ * each interval is checked and updated when the tracked beat has passed.
+ */
/** The bpm of the soundtrack*/
private final int BPM = 180;
@@ -13,7 +19,7 @@ public class SyncController {
Music jazz;
/**The audio delay of the audio in seconds*/
- private float delay = 0;
+ private float delay = 0f;
/** The intervals of each of the synced objects in the game */
private Array intervals = new Array<>();
/** The interval that represents the animation update */
@@ -31,7 +37,6 @@ public void setSync(Music _synth, Music _jazz){
* */
public void addDelay(float _delay){
delay += _delay;
- System.out.println("New Delay: " + delay);
}
/**The update function for everything synced in the world*/
diff --git a/core/src/edu/cornell/gdiac/rabbeat/ui/GenreUI.java b/core/src/edu/cornell/gdiac/rabbeat/ui/GenreUI.java
new file mode 100644
index 00000000..46c795a0
--- /dev/null
+++ b/core/src/edu/cornell/gdiac/rabbeat/ui/GenreUI.java
@@ -0,0 +1,115 @@
+package edu.cornell.gdiac.rabbeat.ui;
+
+import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.graphics.g2d.Animation;
+import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import edu.cornell.gdiac.rabbeat.GameCanvas;
+import edu.cornell.gdiac.rabbeat.Genre;
+import edu.cornell.gdiac.rabbeat.obstacles.IGenreObject;
+import edu.cornell.gdiac.rabbeat.sync.ISyncedAnimated;
+
+/** Class for all in-game UI elements that depend on the current genre. */
+public class GenreUI implements IGenreObject, ISyncedAnimated {
+
+ /** The texture for the indicator. */
+ private TextureRegion texture;
+ /** The texture for synth */
+ private final TextureRegion synthTexture;
+ /** The texture for jazz */
+ private final TextureRegion jazzTexture;
+
+ /** The synth animation */
+ private Animation synthAnimation;
+ /** The jazz animation */
+ private Animation jazzAnimation;
+ /** The current animation */
+ public Animation animation;
+ /** The elapsed time for animationUpdate */
+ private float stateTime = 0;
+
+ /** Holds the genre of the ANIMATION. Doesn't specifically detect genre. */
+ private Genre animationGenre;
+
+ /**
+ * Creates a new genre indicator.
+ */
+ public GenreUI(TextureRegion synthTexture, TextureRegion jazzTexture, Animation synthAnimation, Animation jazzAnimation) {
+ this.synthTexture = synthTexture;
+ this.jazzTexture = jazzTexture;
+ this.synthAnimation = synthAnimation;
+ this.jazzAnimation = jazzAnimation;
+ texture = synthTexture;
+ animationGenre = Genre.SYNTH;
+ setAnimation(synthAnimation);
+ }
+
+ /**
+ * Updates the UI's physics animation.
+ **
+ * @param dt Number of seconds since last animation frame
+ */
+ public void update(float dt) {
+ stateTime += dt;
+ switch (animationGenre) {
+ case SYNTH:
+ if (animation.isAnimationFinished(stateTime)) {
+ stateTime = 0;
+ setAnimation(synthAnimation);
+ }
+ break;
+ case JAZZ:
+ if (animation.isAnimationFinished(stateTime)) {
+ stateTime = 0;
+ setAnimation(jazzAnimation);
+ }
+ break;
+ }
+ }
+
+ /**
+ * Draws the GenreUI.
+ *
+ * @param canvas Drawing context
+ * @param x The x coordinate on the screen
+ * @param y The y coordinate on the screen
+ */
+ public void draw(GameCanvas canvas, float x, float y) {
+ TextureRegion currentFrame = animation.getKeyFrame(stateTime, true);
+ canvas.draw(currentFrame,x,y);
+ }
+
+ /**
+ * Gets the current texture of the genre indicator.
+ */
+ public TextureRegion getTexture() {
+ return texture;
+ }
+
+ /**
+ * Sets the current texture of the genre indicator.
+ *
+ * @param texture The texture being set.
+ */
+ public void setTexture(TextureRegion texture) {
+ this.texture = texture;
+ }
+
+ @Override
+ public void genreUpdate(Genre genre) {
+ animationGenre = genre;
+ }
+
+ @Override
+ public float getBeat() {
+ return 1;
+ }
+
+ @Override
+ public void beatAction() { }
+
+ @Override
+ public void setAnimation(Animation animation) { this.animation = animation; }
+
+ @Override
+ public void updateAnimationFrame() { stateTime++; }
+}
diff --git a/desktop/build/resources/main/assets.json b/desktop/build/resources/main/assets.json
index 8e6563c3..31d59762 100644
--- a/desktop/build/resources/main/assets.json
+++ b/desktop/build/resources/main/assets.json
@@ -10,11 +10,35 @@
"wrapU": "repeated",
"wrapV": "repeated"
},
- "world:platforms:weightedSynth" : "world/platforms/synthPlat.png",
+ "world:tilesets:wallsTileset:0" : "world/tilesets/wallsTileset/0.png",
+
+ "world:tilesets:wallsTileset:1" : "world/tilesets/wallsTileset/1.png",
+
+ "world:tilesets:wallsTileset:2" : "world/tilesets/wallsTileset/2.png",
+
+ "world:tilesets:wallsTileset:3" : "world/tilesets/wallsTileset/3.png",
+
+ "world:tilesets:wallsTileset:4" : "world/tilesets/wallsTileset/4.png",
+
+ "world:tilesets:wallsTileset:5" : "world/tilesets/wallsTileset/5.png",
+
+ "world:tilesets:wallsTileset:6" : "world/tilesets/wallsTileset/6.png",
+
+ "world:tilesets:wallsTileset:7" : "world/tilesets/wallsTileset/7.png",
+
+ "world:tilesets:wallsTileset:8" : "world/tilesets/wallsTileset/8.png",
+
+ "world:tilesets:wallsTileset:9" : "world/tilesets/wallsTileset/9.png",
+
+ "world:tilesets:wallsTileset:10" : "world/tilesets/wallsTileset/10.png",
+
+ "world:tilesets:wallsTileset:11" : "world/tilesets/wallsTileset/11.png",
+
+ "world:platforms:weightedSynth" : "world/platforms/synthPlat.PNG",
"world:platforms:weightedJazz" : "world/platforms/jazzPlat.png",
- "world:platforms:movingSynth" : "world/platforms/synthPlat.png",
+ "world:platforms:movingSynth" : "world/platforms/synthPlat.PNG",
"world:platforms:movingJazz" : "world/platforms/jazzPlat.png",
@@ -22,11 +46,17 @@
"world:platforms:platformArt" : "world/platforms/purplePlatArt.png",
- "world:platforms:longPlatform:left" : "world/platforms/longPlatform/left.png",
+ "world:platforms:longPlatform:left" : "world/platforms/longPlatform/left.PNG",
+
+ "world:platforms:longPlatform:mid" : "world/platforms/longPlatform/mid.PNG",
+
+ "world:platforms:longPlatform:right" : "world/platforms/longPlatform/right.PNG",
+
+ "world:platforms:longPlatform:leftSquare" : "world/platforms/longPlatform/leftSquare.PNG",
- "world:platforms:longPlatform:mid" : "world/platforms/longPlatform/mid.png",
+ "world:platforms:longPlatform:rightSquare" : "world/platforms/longPlatform/rightSquare.PNG",
- "world:platforms:longPlatform:right" : "world/platforms/longPlatform/right.png",
+ "world:platforms:longPlatform:single" : "world/platforms/longPlatform/single.png",
"world:platforms:endPlatform" : "world/platforms/endPlatform.png",
@@ -38,22 +68,97 @@
"world:weightedLaserTile" : "world/weightedLaserTile.png",
+ "world:checkpoints:checkpointInactive": "world/checkpoints/checkpointInactive.png",
+
"world:goal": "world/goal.png",
- "checkpoint:checkDefault": "world/checkpoints/checkDefault.png",
+ "ui:synthIndicator": "ui/synth-indicator.png",
+
+ "ui:jazzIndicator": "ui/jazz-indicator.png",
+
+ "ui:pause:exitLevel": "ui/pause/exitLevel.png",
+
+ "ui:pause:hoverLowerSound": "ui/pause/hoverLowerSound.png",
+
+ "ui:pause:hoverUpSound": "ui/pause/hoverUpSound.png",
+
+ "ui:pause:indicatorStar": "ui/pause/indicatorStar.png",
+
+ "ui:pause:music": "ui/pause/music.png",
+
+ "ui:pause:overlay": "ui/pause/overlay.png",
+
+ "ui:pause:restartLevel": "ui/pause/restartLevel.png",
+
+ "ui:pause:resume": "ui/pause/resume.png",
+
+ "ui:pause:SFX": "ui/pause/SFX.png",
+
+ "ui:pause:unhoverLowerSound": "ui/pause/unhoverLowerSound.png",
+
+ "ui:pause:unhoverUpSound": "ui/pause/unhoverUpSound.png",
+
+ "ui:pause:volumeBox": "ui/pause/volumeBox.png",
+
+ "ui:blackGradient": "ui/blackGradient.png",
- "checkpoint:checkActive": "world/checkpoints/checkActive.png",
+ "ui:unlockedLevels:unlockedLevel1": "ui/unlockedLevels/unlockedLevel1.png",
+ "ui:unlockedLevels:unlockedLevel2": "ui/unlockedLevels/unlockedLevel2.png",
+ "ui:unlockedLevels:unlockedLevel3": "ui/unlockedLevels/unlockedLevel3.png",
+ "ui:unlockedLevels:unlockedLevel4": "ui/unlockedLevels/unlockedLevel4.png",
+ "ui:unlockedLevels:unlockedLevel5": "ui/unlockedLevels/unlockedLevel5.png",
+ "ui:unlockedLevels:unlockedLevel6": "ui/unlockedLevels/unlockedLevel6.png",
+ "ui:unlockedLevels:unlockedLevel7": "ui/unlockedLevels/unlockedLevel7.png",
+ "ui:unlockedLevels:unlockedLevel8": "ui/unlockedLevels/unlockedLevel8.png",
+ "ui:unlockedLevels:unlockedLevel9": "ui/unlockedLevels/unlockedLevel9.png",
+ "ui:unlockedLevels:unlockedLevel10": "ui/unlockedLevels/unlockedLevel10.png",
+ "ui:unlockedLevels:unlockedLevel11": "ui/unlockedLevels/unlockedLevel11.png",
+ "ui:unlockedLevels:unlockedLevel12": "ui/unlockedLevels/unlockedLevel12.png",
+
+ "ui:lockedLevels:lockedLevel1": "ui/lockedLevels/lockedLevel1.png",
+ "ui:lockedLevels:lockedLevel2": "ui/lockedLevels/lockedLevel2.png",
+ "ui:lockedLevels:lockedLevel3": "ui/lockedLevels/lockedLevel3.png",
+ "ui:lockedLevels:lockedLevel4": "ui/lockedLevels/lockedLevel4.png",
+ "ui:lockedLevels:lockedLevel5": "ui/lockedLevels/lockedLevel5.png",
+ "ui:lockedLevels:lockedLevel6": "ui/lockedLevels/lockedLevel6.png",
+ "ui:lockedLevels:lockedLevel7": "ui/lockedLevels/lockedLevel7.png",
+ "ui:lockedLevels:lockedLevel8": "ui/lockedLevels/lockedLevel8.png",
+ "ui:lockedLevels:lockedLevel9": "ui/lockedLevels/lockedLevel9.png",
+ "ui:lockedLevels:lockedLevel10": "ui/lockedLevels/lockedLevel10.png",
+ "ui:lockedLevels:lockedLevel11": "ui/lockedLevels/lockedLevel11.png",
+ "ui:lockedLevels:lockedLevel12": "ui/lockedLevels/lockedLevel12.png",
+
+ "ui:victory:levelSelectText": "ui/victory/levelSelect.png",
+ "ui:victory:nextLevelText": "ui/victory/nextLevel.png",
+ "ui:victory:star": "ui/victory/star.png",
+ "ui:victory:victoryLogo": "ui/victory/victoryLogo.png",
"player:synth": "player/synth.png",
"player:synth-jazz": "player/synth-jazz.png",
- "backgrounds:test-bg": "backgrounds/background.png",
+ "backgrounds:test-bg": "backgrounds/labGrafiti.png",
"backgrounds:overlay": "backgrounds/background-overlay.png",
+ "backgrounds:pauseTint": "backgrounds/white_texture.png",
+
+ "enemies:bat": "enemies/bat.png",
+
+ "enemies:echo" : "atlas/echo.png",
+
+ "enemies:echoStill" : "enemies/echoStill.png",
+
"world:bullet": "world/bullet.png",
+ "enemies:bee": "enemies/beeStill.png",
+
+ "enemies:bear": "enemies/bearStill.png",
+
+ "enemies:beehive": "enemies/beehive.png",
+
+ "enemies:hedgehog": "enemies/hedgehogStill.png",
+
"world:shelves:shelf1": "world/shelves/shelf1.png",
"world:shelves:shelf2": "world/shelves/shelf2.png",
@@ -92,21 +197,19 @@
"world:pods:wolfpod2": "world/pods/wolfpod2.png",
- "world:other:light": "world/other/light.png",
-
"world:pipes:bigpipe" : "world/pipes/bigpipe.png",
"world:pipes:bigpipetv" : "world/pipes/bigpipetv.png",
- "world:pipes:pipeleftskinny" : "world/pipes/pipeleftskinny.png",
+ "world:pipes:pipeleftskinny" : "world/pipes/pipeleftskinny.PNG",
- "world:pipes:pipeposter" : "world/pipes/pipeposter.png",
+ "world:pipes:pipeposter" : "world/pipes/pipeposter.PNG",
- "world:pipes:piperight" : "world/pipes/piperight.png",
+ "world:pipes:piperight" : "world/pipes/piperight.PNG",
- "world:pipes:piperightskinny" : "world/pipes/piperightskinny.png",
+ "world:pipes:piperightskinny" : "world/pipes/piperightskinny.PNG",
- "world:pipes:pipestraight" : "world/pipes/pipestraight.png",
+ "world:pipes:pipestraight" : "world/pipes/pipestraight.PNG",
"world:pipes:pipestraightskinny" : "world/pipes/pipestraightskinny.png",
@@ -116,14 +219,59 @@
"world:wires:wires1" : "world/wires/wires1.png",
- "world:wires:wires2" : "world/wires/wires2.png"
+ "world:wires:wires2" : "world/wires/wires2.png",
+
+ "world:other:light": "world/other/light.png",
+
+ "world:other:tv": "world/other/tv.png",
+
+ "world:other:ceilingCamera": "world/other/ceilingCamera.png",
+
+ "world:other:cam_0": "world/other/cam_0.png",
+
+ "world:other:cam_1": "world/other/cam_1.png",
+
+ "world:other:cam_2": "world/other/cam_2.png",
+
+ "world:graffiti:emoji_0" : "world/graffiti/emoji_0.png",
+
+ "world:graffiti:emoji_1" : "world/graffiti/emoji_1.png",
+
+ "world:graffiti:emoji_2" : "world/graffiti/emoji_2.png",
+
+ "world:graffiti:graffiti_0" : "world/graffiti/graffiti_0.png",
+
+ "world:graffiti:graffiti_1" : "world/graffiti/graffiti_1.png",
+
+ "world:graffiti:graffiti_2" : "world/graffiti/graffiti_2.png",
+
+ "world:graffiti:graffiti_3" : "world/graffiti/graffiti_3.png",
+
+ "world:graffiti:caution_0" : "world/graffiti/caution_0.png",
+
+ "world:laser" : "world/laser.png",
+ "world:laserMiddle" : "world/lasers/laserMiddle.png",
+ "world:laserTop" : "world/lasers/laserTop.png",
+ "world:laserBottom" : "world/lasers/laserBottom.png"
},
"jsons" : {
"defaultConstants": "defaultConstants.json",
- "example": "levelsJson/rabbeatLevel.tmj"
+ "example": "levelsJson/rabbeatLevelTest.tmj",
+ "level1": "levelsJson/level1Beta.tmj",
+ "level2": "levelsJson/rabbeatLevelBat.tmj",
+ "level3": "levelsJson/rabbeatLaserTest.tmj",
+ "level4": "levelsJson/exampleLevel.tmj",
+ "level5": "levelsJson/rabbeatLevel.tmj",
+ "level6": "levelsJson/rabbeatLevel3.tmj",
+ "level7": "levelsJson/rabbeatLevel.tmj",
+ "level8": "levelsJson/rabbeatLevel.tmj",
+ "level9": "levelsJson/rabbeatLevel.tmj",
+ "level10": "levelsJson/rabbeatLevel.tmj",
+ "level11": "levelsJson/rabbeatLevel.tmj",
+ "level12": "levelsJson/rabbeatLevel.tmj"
},
"sounds": {
-
+ "sfx:genreSwitch": "sfx/genre_switch_woosh.wav"
},
"music" : {
"music:synth1": "music/synth_alpha.ogg",
@@ -134,5 +282,8 @@
"file": "fonts/RetroGame.ttf",
"size": 64
}
- }
+ },
+ "atlas": {
+ "atlas:echoAtlas": "atlas/echo.atlas"
+ }
}
diff --git a/desktop/src/edu/cornell/gdiac/rabbeat/desktop/DesktopLauncher.java b/desktop/src/edu/cornell/gdiac/rabbeat/desktop/DesktopLauncher.java
index a14612bc..d6743d18 100644
--- a/desktop/src/edu/cornell/gdiac/rabbeat/desktop/DesktopLauncher.java
+++ b/desktop/src/edu/cornell/gdiac/rabbeat/desktop/DesktopLauncher.java
@@ -34,8 +34,8 @@ public class DesktopLauncher {
*/
public static void main (String[] arg) {
GDXAppSettings config = new GDXAppSettings();
- config.width = 1920;
- config.height = 1080;
+ config.width = 1280;
+ config.height = 720;
config.fullscreen = false;
config.resizable = false;
new GDXApp(new GDXRoot(), config);