Compare commits

...

8 Commits

Author SHA1 Message Date
ab3e4a177b Allow swiping for inputting high score name 2020-01-22 20:50:30 +04:00
fc912863ad Register high score if it fits anywhere in the top 10.
When adding it, render in appropriate position.
2020-01-22 20:18:14 +04:00
5645b4bcf5 Add visible return/save buttons to high scores pages 2020-01-22 19:42:49 +04:00
1989b4557b Move GHOST_SPAWN_DIRS and GHOST_SPAWN_POINTS 2020-01-22 19:12:06 +04:00
784bcac437 Move pellet eaten counters to level 2020-01-22 03:03:05 +04:00
f655fe2448 Refactors 2020-01-22 02:40:36 +04:00
b19daafc2b Refactor some constants to Constants class
Use TILE_SIZE everywhere a magic 8 appears (in the context of a tile size)
2020-01-22 02:35:05 +04:00
fb6f77b72c Alter positioning on high score screens
Fix removal of preNewGame() after GameOver
2020-01-16 17:01:07 +04:00
21 changed files with 409 additions and 195 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,44 @@
package com.me.pacman;
import com.me.pacman.entity.Direction;
public final class Constants {
public static final String TITLE = "Pac-Dude";
public static final String VERSION = "v0.1.0";
public static final boolean DEBUG = false;
// Pixels
public static final int TILE_SIZE = 8;
// The size of the original Pac-Man game in 8x8 pixel tiles
public static final int GAME_WIDTH_TILES = 28;
public static final int GAME_HEIGHT_TILES = 36;
// The game window width and height - arbitrary units (in this case, matches up with the pixel
// counts of the original Pacman.
public static final int GAME_WIDTH = GAME_WIDTH_TILES * TILE_SIZE;
public static final int GAME_HEIGHT = GAME_HEIGHT_TILES * TILE_SIZE;
// Pac-man level rendering position offset in game coordinates
public static final int LEVEL_OFFSET_X = 0;
public static final int LEVEL_OFFSET_Y = 2 * TILE_SIZE;
// 100% speed in tiles (8 pixel / tile) per second. roughly 75 pixels/second
// 75 pixels/second aligns with the per-frame pixel movement steps in:
// https://github.com/masonicGIT/pacman/blob/master/pacman.js
// and is close to the 75.75757625 pixels/second claimed in:
// https://pacman.holenet.info/#LvlSpecs
public static final float FULL_SPEED = 9.375f;
// Ghost spawn directions, should remain constant assuming they always exit the ghost house
// from the top
public static final Direction[] GHOST_SPAWN_DIRS = {
Direction.LEFT, // Blinky
Direction.UP, // Pinky
Direction.DOWN, // Inky
Direction.DOWN, // Clyde
};
}

View File

@ -9,9 +9,10 @@ public class FontRenderer {
public static final char[] CHARS = "abcdefghijklmnopqrstuvwxyz0123456789!?()[]<>$&*:#^~-_/\\".toCharArray();
public static final int[] CHAR_TO_INDEX = new int[256];
private Color color = Color.WHITE;
private TextureRegion[][] sprites;
private final TextureRegion[][] sprites;
private Color color = Color.WHITE;
public FontRenderer(TextureRegion[][] sprites) {
this.sprites = sprites;
@ -31,8 +32,7 @@ public class FontRenderer {
continue;
}
int i = CHAR_TO_INDEX[c];
TextureRegion region = sprites[i / 8][i % 8];
batch.draw(region, x, y);
batch.draw(sprites[i / 8][i % 8], x, y);
x += 8;
}

View File

@ -9,7 +9,7 @@ import com.badlogic.gdx.utils.Array;
*
* Scores are saved in a simple text file
*/
public class HighScores {
public class HighScoreManager {
public static final String FILE = "scores.dat";
@ -17,7 +17,7 @@ public class HighScores {
private Array<Score> scores = new Array<>(10);
public HighScores() {
public HighScoreManager() {
file = Gdx.files.local(FILE);
loadScores();
}

View File

@ -3,53 +3,45 @@ package com.me.pacman;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.me.pacman.state.HighScoresState;
import com.me.pacman.state.MenuState;
import com.me.pacman.state.State;
public class PacDude extends Game {
public static final String TITLE = "Pac-Dude";
public static final String VERSION = "v0.1.0";
public static final boolean DEBUG = false;
public static final int LEVEL_WIDTH = 224;
public static final int LEVEL_HEIGHT = 288;
public HighScores highScores;
public Camera cam;
public Viewport viewport;
public Assets assets;
public Sound sound;
public SoundManager sound;
public SpriteBatch batch;
public FontRenderer fontRenderer;
public OrthographicCamera cam;
public Viewport viewport;
public HighScoreManager highScores;
private State nextState;
@Override
public void create () {
cam = new OrthographicCamera();
viewport = new FitViewport(LEVEL_WIDTH, LEVEL_HEIGHT, cam);
viewport = new FitViewport(Constants.GAME_WIDTH, Constants.GAME_HEIGHT, cam);
viewport.apply(true);
highScores = new HighScores();
assets = new Assets();
assets.loadAssets();
sound = new Sound(this);
sound = new SoundManager(this);
batch = new SpriteBatch();
fontRenderer = new FontRenderer(assets.font);
highScores = new HighScoreManager();
Gdx.gl.glClearColor(0, 0, 0, 1);
setNextState(new MenuState(this));
}
@ -57,7 +49,6 @@ public class PacDude extends Game {
@Override
public void render () {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
if (nextState != null) {
Screen currScreen = getScreen();
if (currScreen != null) currScreen.dispose();
@ -67,8 +58,8 @@ public class PacDude extends Game {
}
batch.begin();
if (DEBUG) {
fontRenderer.draw(batch, "fps:" + Gdx.graphics.getFramesPerSecond(), 19 * 8, 34 * 8);
if (Constants.DEBUG) {
fontRenderer.draw(batch, "fps:" + Gdx.graphics.getFramesPerSecond(), 19 * Constants.TILE_SIZE, 34 * Constants.TILE_SIZE);
}
super.render();
batch.end();

View File

@ -1,12 +1,10 @@
package com.me.pacman.level;
import com.me.pacman.state.PlayState;
package com.me.pacman;
import java.util.Arrays;
public class Modifiers {
public class RoundModifiers {
private static final Modifiers[] ROUND_MODIFIERS;
private static final RoundModifiers[] ROUND_MODIFIERS;
private float frightTime;
@ -35,23 +33,23 @@ public class Modifiers {
}
public static float getPacmanSpeed(int round) {
return PlayState.FULL_SPEED * ROUND_MODIFIERS[cap(round)].pacmanSpeed;
return Constants.FULL_SPEED * ROUND_MODIFIERS[cap(round)].pacmanSpeed;
}
public static float getPacmanFrightSpeed(int round) {
return PlayState.FULL_SPEED * ROUND_MODIFIERS[cap(round)].pacmanFrightSpeed;
return Constants.FULL_SPEED * ROUND_MODIFIERS[cap(round)].pacmanFrightSpeed;
}
public static float getGhostSpeed(int round) {
return PlayState.FULL_SPEED * ROUND_MODIFIERS[cap(round)].ghostSpeed;
return Constants.FULL_SPEED * ROUND_MODIFIERS[cap(round)].ghostSpeed;
}
public static float getGhostFrightSpeed(int round) {
return PlayState.FULL_SPEED * ROUND_MODIFIERS[cap(round)].ghostFrightSpeed;
return Constants.FULL_SPEED * ROUND_MODIFIERS[cap(round)].ghostFrightSpeed;
}
public static float getGhostTunnelSpeed(int round) {
return PlayState.FULL_SPEED * ROUND_MODIFIERS[cap(round)].ghostTunnelSpeed;
return Constants.FULL_SPEED * ROUND_MODIFIERS[cap(round)].ghostTunnelSpeed;
}
public static int getElroy1DotsLeft(int round) {
@ -59,7 +57,7 @@ public class Modifiers {
}
public static float getElroy1Speed(int round) {
return PlayState.FULL_SPEED * ROUND_MODIFIERS[cap(round)].elroy1Speed;
return Constants.FULL_SPEED * ROUND_MODIFIERS[cap(round)].elroy1Speed;
}
public static int getElroy2DotsLeft(int round) {
@ -67,7 +65,7 @@ public class Modifiers {
}
public static float getElroy2Speed(int round) {
return PlayState.FULL_SPEED * ROUND_MODIFIERS[cap(round)].elroy2Speed;
return Constants.FULL_SPEED * ROUND_MODIFIERS[cap(round)].elroy2Speed;
}
public static int getForceLeaveSeconds(int round) {
@ -78,8 +76,8 @@ public class Modifiers {
return ROUND_MODIFIERS[cap(round)].scatterChaseSwitchTimings[scatterChaseTransition];
}
public Modifiers clone() {
Modifiers mod = new Modifiers();
public RoundModifiers clone() {
RoundModifiers mod = new RoundModifiers();
mod.frightTime = frightTime;
mod.pacmanSpeed = pacmanSpeed;
mod.pacmanFrightSpeed = pacmanFrightSpeed;
@ -100,11 +98,11 @@ public class Modifiers {
}
static {
ROUND_MODIFIERS = new Modifiers[21];
ROUND_MODIFIERS = new RoundModifiers[21];
int round = 0;
// Round 1
Modifiers mod = new Modifiers();
RoundModifiers mod = new RoundModifiers();
mod.frightTime = 6f;
mod.pacmanSpeed = 0.8f;
mod.pacmanFrightSpeed = 0.9f;

View File

@ -2,7 +2,7 @@ package com.me.pacman;
import java.util.Arrays;
public class Sound {
public class SoundManager {
public enum Effect {
BEGINNING,
@ -28,7 +28,7 @@ public class Sound {
private long[] playing;
private long[] looping;
public Sound(PacDude game) {
public SoundManager(PacDude game) {
this.game = game;
this.playing = new long[Effect.values().length];
this.looping = new long[Effect.values().length];

View File

@ -1,16 +1,16 @@
package com.me.pacman.entity;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.PacDude;
import com.me.pacman.Constants;
import com.me.pacman.entity.ai.BlinkyChaseBehaviour;
import com.me.pacman.entity.ai.StaticTargetBehaviour;
import com.me.pacman.entity.ai.Target;
import com.me.pacman.level.Modifiers;
import com.me.pacman.RoundModifiers;
import com.me.pacman.state.PlayState;
public class Blinky extends Ghost {
public static final Target SCATTER_TARGET = new Target((PacDude.LEVEL_WIDTH / 8) - 2, PacDude.LEVEL_HEIGHT / 8);
public static final Target SCATTER_TARGET = new Target((Constants.GAME_WIDTH / 8) - 2, Constants.GAME_HEIGHT / 8);
public Blinky(PlayState state, Vector2 pos, Direction direction) {
super(state, pos, direction, 0, new BlinkyChaseBehaviour(state), new StaticTargetBehaviour(state, SCATTER_TARGET), false);
@ -20,10 +20,10 @@ public class Blinky extends Ghost {
protected float getNormalSpeed() {
int round = state.round;
if (!state.hasDied || !state.ghosts[3].inHouse) {
if (state.pelletsRemaining <= Modifiers.getElroy2DotsLeft(round)) {
return Modifiers.getElroy2Speed(round);
} else if (state.pelletsRemaining <= Modifiers.getElroy1DotsLeft(round)) {
return Modifiers.getElroy1Speed(round);
if (state.level.getPelletsRemaining() <= RoundModifiers.getElroy2DotsLeft(round)) {
return RoundModifiers.getElroy2Speed(round);
} else if (state.level.getPelletsRemaining() <= RoundModifiers.getElroy1DotsLeft(round)) {
return RoundModifiers.getElroy1Speed(round);
}
}
return super.getNormalSpeed();

View File

@ -2,7 +2,7 @@ package com.me.pacman.entity;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.PacDude;
import com.me.pacman.Constants;
import com.me.pacman.entity.ai.Target;
import com.me.pacman.level.LevelTile;
import com.me.pacman.state.LevelState;
@ -29,8 +29,8 @@ public abstract class Entity {
state.drawSprite(texture, pos.x, pos.y);
if (PacDude.DEBUG) {
state.level.renderTile(LevelTile.DEBUG, (int) pos.x, (int) pos.y, LevelState.LEVEL_OFFSET_X, LevelState.LEVEL_OFFSET_Y);
if (Constants.DEBUG) {
state.level.renderTile(LevelTile.DEBUG, (int) pos.x, (int) pos.y, Constants.LEVEL_OFFSET_X, Constants.LEVEL_OFFSET_Y);
}
}

View File

@ -2,13 +2,14 @@ package com.me.pacman.entity;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.Constants;
import com.me.pacman.entity.ai.Behaviour;
import com.me.pacman.entity.ai.ReturnToBase;
import com.me.pacman.entity.ai.Target;
import com.me.pacman.entity.path.EnterGhostHousePath;
import com.me.pacman.entity.path.ExitGhostHousePath;
import com.me.pacman.level.LevelTile;
import com.me.pacman.level.Modifiers;
import com.me.pacman.RoundModifiers;
import com.me.pacman.state.PlayState;
import java.util.ArrayList;
@ -16,7 +17,7 @@ import java.util.ArrayList;
public class Ghost extends MovableEntity {
public static final float EYES_SPEED = 15f;
public static final float HOUSE_SPEED = PlayState.FULL_SPEED * 0.5f;
public static final float HOUSE_SPEED = Constants.FULL_SPEED * 0.5f;
public static final Direction[] GHOST_ORDER = { Direction.UP, Direction.LEFT, Direction.DOWN, Direction.RIGHT };
@ -43,7 +44,7 @@ public class Ghost extends MovableEntity {
public Ghost(PlayState state, Vector2 pos, Direction direction, int spriteIndex,
Behaviour chaseBehaviour, Behaviour scatterBehaviour, boolean inHouse) {
super(state, pos.x, pos.y, Modifiers.getGhostSpeed(0), true, direction, 0.1f);
super(state, pos.x, pos.y, RoundModifiers.getGhostSpeed(0), true, direction, 0.1f);
this.state = state;
this.spriteIndex = spriteIndex;
this.chaseBehaviour = chaseBehaviour;
@ -83,7 +84,7 @@ public class Ghost extends MovableEntity {
}
protected float getNormalSpeed() {
return Modifiers.getGhostSpeed(state.round);
return RoundModifiers.getGhostSpeed(state.round);
}
@Override
@ -94,9 +95,9 @@ public class Ghost extends MovableEntity {
LevelTile currentTile = state.level.getTile(pos);
if (currentTile == null || currentTile == LevelTile.TUNNEL) {
speed = Modifiers.getGhostTunnelSpeed(state.round);
speed = RoundModifiers.getGhostTunnelSpeed(state.round);
} else if (currentBehaviour instanceof FrightenedBehaviour) {
speed = Modifiers.getGhostFrightSpeed(state.round);
speed = RoundModifiers.getGhostFrightSpeed(state.round);
} else if (currentBehaviour instanceof ReturnToBase) {
speed = EYES_SPEED;
} else if (inHouse) {

View File

@ -1,7 +1,7 @@
package com.me.pacman.entity;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.PacDude;
import com.me.pacman.Constants;
import com.me.pacman.entity.ai.InkyChaseBehaviour;
import com.me.pacman.entity.ai.StaticTargetBehaviour;
import com.me.pacman.entity.ai.Target;
@ -9,7 +9,7 @@ import com.me.pacman.state.PlayState;
public class Inky extends Ghost {
public static final Target SCATTER_TARGET = new Target(PacDude.LEVEL_WIDTH / 8, -1);
public static final Target SCATTER_TARGET = new Target(Constants.GAME_WIDTH / 8, -1);
public static final int DOT_LIMIT = 30;

View File

@ -2,8 +2,9 @@ package com.me.pacman.entity;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.Constants;
import com.me.pacman.level.LevelTile;
import com.me.pacman.level.Modifiers;
import com.me.pacman.RoundModifiers;
import com.me.pacman.state.PlayState;
public class Pacman extends MovableEntity {
@ -22,7 +23,7 @@ public class Pacman extends MovableEntity {
public int deathFrame = 0;
public Pacman(PlayState state, boolean moving) {
super(state, HOME.x, HOME.y, PlayState.FULL_SPEED * 0.8f, moving, Direction.LEFT, 0.3f);
super(state, HOME.x, HOME.y, Constants.FULL_SPEED * 0.8f, moving, Direction.LEFT, 0.3f);
this.state = state;
sprite = state.getGame().assets.pacman;
death = state.getGame().assets.deathAnimation;
@ -49,9 +50,9 @@ public class Pacman extends MovableEntity {
}
if (state.frightTimer > 0) {
speed = Modifiers.getPacmanFrightSpeed(state.round);
speed = RoundModifiers.getPacmanFrightSpeed(state.round);
} else {
speed = Modifiers.getPacmanSpeed(state.round);
speed = RoundModifiers.getPacmanSpeed(state.round);
}
super.update(dt);

View File

@ -1,7 +1,7 @@
package com.me.pacman.entity;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.PacDude;
import com.me.pacman.Constants;
import com.me.pacman.entity.ai.PinkyChaseBehaviour;
import com.me.pacman.entity.ai.StaticTargetBehaviour;
import com.me.pacman.entity.ai.Target;
@ -9,7 +9,7 @@ import com.me.pacman.state.PlayState;
public class Pinky extends Ghost {
public static final Target SCATTER_TARGET = new Target(2, PacDude.LEVEL_HEIGHT / 8);
public static final Target SCATTER_TARGET = new Target(2, Constants.GAME_HEIGHT / 8);
public Pinky(PlayState state, Vector2 pos, Direction direction) {
super(state, pos, direction, 1, new PinkyChaseBehaviour(state), new StaticTargetBehaviour(state, SCATTER_TARGET), true);

View File

@ -2,10 +2,18 @@ package com.me.pacman.level;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.Constants;
import com.me.pacman.PacDude;
public class Level {
public static final Vector2[] GHOST_SPAWN_POINTS = {
new Vector2(14f, 19.5f),
new Vector2(14f, 16.5f),
new Vector2(12f, 16.5f),
new Vector2(16f, 16.5f),
};
private PacDude game;
private TextureRegion pellet;
@ -15,9 +23,12 @@ public class Level {
// Grid of tiles, [rows][columns]
public LevelTile[][] tiles;
// Level width and height in tiles
public int width;
public int height;
private int pellets;
private int pelletsRemaining;
public Level(PacDude game, String level) {
this.game = game;
@ -31,6 +42,20 @@ public class Level {
height = tiles.length;
width = tiles[0].length;
pellets = pelletsRemaining = getTileCount(LevelTile.PELLET) + getTileCount(LevelTile.POWER_PELLET);
}
public int getPelletCount() {
return pellets;
}
public int getPelletsRemaining() {
return pelletsRemaining;
}
public int getPelletsEaten() {
return pellets - pelletsRemaining;
}
public LevelTile getTile(int x, int y) {
@ -46,6 +71,10 @@ public class Level {
}
public void setTile(int x, int y, LevelTile tile) {
LevelTile exist = tiles[y][x];
if (exist.isPellet() && !tile.isPellet()) {
pelletsRemaining--;
}
tiles[y][x] = tile;
}
@ -90,7 +119,7 @@ public class Level {
default:
return;
}
game.batch.draw(sprite, (tileX * 8) + offsetX, (tileY * 8) + offsetY);
game.batch.draw(sprite, (tileX * Constants.TILE_SIZE) + offsetX, (tileY * Constants.TILE_SIZE) + offsetY);
}
}

View File

@ -13,7 +13,22 @@ public enum LevelTile {
;
public boolean isPassable() {
return this != WALL && this != GHOST_CHAMBER && this != GHOST_GATE;
switch (this) {
case WALL:
case GHOST_CHAMBER:
case GHOST_GATE:
return false;
}
return true;
}
public boolean isPellet() {
switch (this) {
case PELLET:
case POWER_PELLET:
return true;
}
return false;
}
}

View File

@ -5,28 +5,40 @@ import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.Constants;
import com.me.pacman.FontRenderer;
import com.me.pacman.Score;
import com.me.pacman.PacDude;
import com.me.pacman.entity.Direction;
import static com.me.pacman.state.HighScoresState.BUTTON;
public class HighScoreEntryState extends State {
private Texture background;
private Score score;
private final int position;
private int currLetter;
private char[] name;
private boolean flash;
private float elapsed;
public HighScoreEntryState(PacDude game, Score score) {
private boolean buttonPressed;
private Direction nextDirection;
public HighScoreEntryState(PacDude game, Score score, int position) {
super(game);
this.position = position;
this.score = score;
this.currLetter = 0;
this.flash = false;
this.elapsed = 0f;
this.name = score.scorer.toCharArray();
this.nextDirection = null;
}
@Override
@ -40,24 +52,31 @@ public class HighScoreEntryState extends State {
game.batch.draw(background, 0, 16);
game.fontRenderer.setColor(Color.YELLOW);
game.fontRenderer.draw(game.batch, "high scores", (8 * 8) + 4, 25 * 8);
game.fontRenderer.draw(game.batch, "high scores", (8 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2, 25 * Constants.TILE_SIZE);
game.fontRenderer.setColor(Color.CHARTREUSE);
game.fontRenderer.draw(game.batch, "score name", (8 * 8) + 4, 23 * 8);
game.fontRenderer.draw(game.batch, "score name", (8 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2, 22 * Constants.TILE_SIZE);
game.fontRenderer.setColor(Color.BLUE);
game.fontRenderer.draw(game.batch, "" + score.score, (8 * 8) + 4, 18 * 9);
for (int i = 0; i < 3; i++) {
game.fontRenderer.draw(game.batch, String.valueOf((i == currLetter && flash)? '_' : name[i]), (16 + i) * 8 + 4, 18 * 9);
}
game.fontRenderer.setColor(Color.WHITE);
Score[] scores = game.highScores.getHighScores(9);
for (int i = 0; i < scores.length; i++) {
Score score = scores[i];
game.fontRenderer.draw(game.batch, String.format("%-8d%s", score.score, score.scorer), (8 * 8) + 4, (16 - i) * 9);
for (int n = 0; n < scores.length + 1; n++) {
int y = (18 - n) * 9;
if (n == position) {
game.fontRenderer.setColor(Color.BLUE);
game.fontRenderer.draw(game.batch, "" + score.score, (8 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2, y);
for (int i = 0; i < 3; i++) {
game.fontRenderer.draw(game.batch, String.valueOf((i == currLetter && flash)? '_' : name[i]), (16 + i) * Constants.TILE_SIZE + Constants.TILE_SIZE/2, y);
}
} else {
Score score = scores[n > position? n - 1 : n];
game.fontRenderer.setColor(Color.WHITE);
game.fontRenderer.draw(game.batch, String.format("%-8d%s", score.score, score.scorer), (8 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2, y);
}
}
game.fontRenderer.setColor(buttonPressed ? Color.BLUE : Color.WHITE);
game.fontRenderer.draw(game.batch, "save", 12 * Constants.TILE_SIZE, 5 * Constants.TILE_SIZE - 1);
}
@Override
@ -67,19 +86,10 @@ public class HighScoreEntryState extends State {
elapsed = 0f;
flash = !flash;
}
}
@Override
public void dispose() {
Gdx.input.setInputProcessor(null);
}
private final class Controller extends InputAdapter {
@Override
public boolean keyDown(int keycode) {
switch(keycode) {
case Input.Keys.DOWN:
if (nextDirection != null) {
switch (nextDirection) {
case UP:
int nextIndex = FontRenderer.CHAR_TO_INDEX[name[currLetter]] - 1;
if (nextIndex < 0) {
nextIndex = 25;
@ -87,7 +97,7 @@ public class HighScoreEntryState extends State {
flash = false;
name[currLetter] = FontRenderer.CHARS[nextIndex];
break;
case Input.Keys.UP:
case DOWN:
nextIndex = FontRenderer.CHAR_TO_INDEX[name[currLetter]] + 1;
if (nextIndex > 25) {
nextIndex = 0;
@ -95,30 +105,117 @@ public class HighScoreEntryState extends State {
flash = false;
name[currLetter] = FontRenderer.CHARS[nextIndex];
break;
case Input.Keys.RIGHT:
currLetter++;
if (currLetter > 2) {
currLetter = 0;
}
flash = true;
break;
case Input.Keys.LEFT:
case LEFT:
currLetter--;
if (currLetter < 0) {
currLetter = 2;
}
flash = true;
break;
case Input.Keys.ENTER:
case RIGHT:
currLetter++;
if (currLetter > 2) {
currLetter = 0;
}
flash = true;
break;
}
nextDirection = null;
}
}
@Override
public void dispose() {
Gdx.input.setInputProcessor(null);
}
private void saveScoreAndReturn() {
score.scorer = String.valueOf(name);
game.highScores.addScore(score);
game.setNextState(new HighScoresState(game));
}
private final class Controller extends InputAdapter {
int downX;
int downY;
@Override
public boolean keyDown(int keycode) {
switch(keycode) {
case Input.Keys.DOWN:
nextDirection = Direction.DOWN;
break;
case Input.Keys.UP:
nextDirection = Direction.UP;
break;
case Input.Keys.RIGHT:
nextDirection = Direction.RIGHT;
break;
case Input.Keys.LEFT:
nextDirection = Direction.LEFT;
break;
case Input.Keys.ENTER:
case Input.Keys.BACK:
case Input.Keys.ESCAPE:
saveScoreAndReturn();
break;
}
elapsed = 0f;
return super.keyDown(keycode);
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
Vector2 coords = game.viewport.unproject(new Vector2(screenX, screenY));
if (BUTTON.contains(coords)) {
buttonPressed = true;
}
downX = screenX;
downY = screenY;
return true;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if (buttonPressed) {
Vector2 coords = game.viewport.unproject(new Vector2(screenX, screenY));
if (BUTTON.contains(coords)) {
saveScoreAndReturn();
}
return true;
}
buttonPressed = false;
int relaX = screenX - downX;
int relaY = screenY - downY;
if (Math.abs(relaX) < 50 && Math.abs(relaY) < 50) {
// didn't move enough to consider a swipe
return true;
}
if (Math.abs(relaX) > Math.abs(relaY)) {
// x > y, so moving left-right
if (relaX > 0) {
nextDirection = Direction.RIGHT;
} else {
nextDirection = Direction.LEFT;
}
} else {
// else, moving up/down
int nextIndex;
if (relaY > 0) {
nextDirection = Direction.DOWN;
} else {
nextDirection = Direction.UP;
}
}
return true;
}
}
}

View File

@ -5,14 +5,25 @@ import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.Constants;
import com.me.pacman.PacDude;
import com.me.pacman.Score;
public class HighScoresState extends State {
public static final MenuState.BoundingBox BUTTON = new MenuState.BoundingBox(
11 * Constants.TILE_SIZE,
5 * Constants.TILE_SIZE,
17 * Constants.TILE_SIZE,
6 * Constants.TILE_SIZE);
private Texture background;
private boolean buttonPressed = false;
public HighScoresState(PacDude game) {
super(game);
}
@ -28,17 +39,20 @@ public class HighScoresState extends State {
game.batch.draw(background, 0, 16);
game.fontRenderer.setColor(Color.YELLOW);
game.fontRenderer.draw(game.batch, "high scores", (8 * 8) + 4, 25 * 8);
game.fontRenderer.draw(game.batch, "high scores", (8 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2, 25 * Constants.TILE_SIZE);
game.fontRenderer.setColor(Color.CHARTREUSE);
game.fontRenderer.draw(game.batch, "score name", (8 * 8) + 4, 23 * 8);
game.fontRenderer.draw(game.batch, "score name", (8 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2, 22 * Constants.TILE_SIZE);
game.fontRenderer.setColor(Color.WHITE);
Score[] scores = game.highScores.getHighScores(10);
for (int i = 0; i < scores.length; i++) {
Score score = scores[i];
game.fontRenderer.draw(game.batch, String.format("%-8d%s", score.score, score.scorer), (8 * 8) + 4, (17 - i) * 9);
game.fontRenderer.draw(game.batch, String.format("%-8d%s", score.score, score.scorer), (8 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2, (18 - i) * 9);
}
game.fontRenderer.setColor(buttonPressed ? Color.BLUE : Color.WHITE);
game.fontRenderer.draw(game.batch, "return", 11 * Constants.TILE_SIZE, 5 * Constants.TILE_SIZE - 1);
}
@Override
@ -55,6 +69,7 @@ public class HighScoresState extends State {
public boolean keyDown(int keycode) {
switch(keycode) {
case Input.Keys.ENTER:
case Input.Keys.BACK:
case Input.Keys.ESCAPE:
game.setNextState(new MenuState(game));
break;
@ -62,6 +77,30 @@ public class HighScoresState extends State {
return super.keyDown(keycode);
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
Vector2 coords = game.viewport.unproject(new Vector2(screenX, screenY));
if (BUTTON.contains(coords)) {
buttonPressed = true;
}
return true;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if (!buttonPressed) {
return true;
}
buttonPressed = false;
Vector2 coords = game.viewport.unproject(new Vector2(screenX, screenY));
if (BUTTON.contains(coords)) {
game.setNextState(new MenuState(game));
}
return true;
}
}
}

View File

@ -1,14 +1,12 @@
package com.me.pacman.state;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.me.pacman.Constants;
import com.me.pacman.PacDude;
import com.me.pacman.level.Level;
public abstract class LevelState extends State {
public static final int LEVEL_OFFSET_X = 0;
public static final int LEVEL_OFFSET_Y = 16;
public Level level;
public LevelState(PacDude game) {
@ -16,7 +14,11 @@ public abstract class LevelState extends State {
}
public void drawSprite(TextureRegion sprite, float x, float y) {
game.batch.draw(sprite, (int) (x * 8) + (LEVEL_OFFSET_X - 8), (int) (y * 8) + (LEVEL_OFFSET_Y - 8));
game.batch.draw(
sprite,
(int) (x * Constants.TILE_SIZE) + (Constants.LEVEL_OFFSET_X - Constants.TILE_SIZE),
(int) (y * Constants.TILE_SIZE) + (Constants.LEVEL_OFFSET_Y - Constants.TILE_SIZE)
);
}
}

View File

@ -6,8 +6,9 @@ import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.Constants;
import com.me.pacman.PacDude;
import com.me.pacman.Sound;
import com.me.pacman.SoundManager;
public class MenuState extends LevelState {
@ -18,8 +19,8 @@ public class MenuState extends LevelState {
public static final int NEW_GAME = 0;
public static final int HIGH_SCORES = 1;
private BoundingBox NEW_GAME_BOX = new BoundingBox(88, 66, 136, 84);
private BoundingBox HIGH_SCORE_BOX = new BoundingBox(88, 42, 136, 60);
private static final BoundingBox NEW_GAME_BOX = new BoundingBox(88, 66, 136, 84);
private static final BoundingBox HIGH_SCORE_BOX = new BoundingBox(88, 42, 136, 60);
private int selectedOption;
@ -34,10 +35,11 @@ public class MenuState extends LevelState {
logo.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
Gdx.input.setInputProcessor(this.new Controller());
game.sound.play(Sound.Effect.BEGINNING);
game.sound.play(SoundManager.Effect.BEGINNING);
switch(Gdx.app.getType()) {
case Android:
case iOS:
selectedOption = -1;
break;
default:
@ -53,12 +55,12 @@ public class MenuState extends LevelState {
game.fontRenderer.setColor(selectedOption == 0 ? Color.BLUE : Color.WHITE);
game.fontRenderer.draw(game.batch, "new", (12 * 8) + 4, (9 * 8) + 4);
game.fontRenderer.draw(game.batch, "game", 12 * 8, (8 * 8) + 4);
game.fontRenderer.draw(game.batch, "new", (12 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2, (9 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2);
game.fontRenderer.draw(game.batch, "game", 12 * Constants.TILE_SIZE, (8 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2);
game.fontRenderer.setColor(selectedOption == 1 ? Color.BLUE : Color.WHITE);
game.fontRenderer.draw(game.batch, "high", (12 * 8), (6 * 8) + 4);
game.fontRenderer.draw(game.batch, "scores", (11 * 8), (5 * 8) + 4);
game.fontRenderer.draw(game.batch, "high", (12 * Constants.TILE_SIZE), (6 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2);
game.fontRenderer.draw(game.batch, "scores", (11 * Constants.TILE_SIZE), (5 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2);
}
@Override
@ -71,11 +73,11 @@ public class MenuState extends LevelState {
switch (keycode) {
case Input.Keys.UP:
selectedOption = selectedOption > 0 ? --selectedOption : 1;
game.sound.play(Sound.Effect.CHOMP_1);
game.sound.play(SoundManager.Effect.CHOMP_1);
break;
case Input.Keys.DOWN:
selectedOption = selectedOption < 1 ? ++selectedOption : 0;
game.sound.play(Sound.Effect.CHOMP_2);
game.sound.play(SoundManager.Effect.CHOMP_2);
break;
case Input.Keys.ENTER:
switch (selectedOption) {

View File

@ -5,47 +5,28 @@ import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.me.pacman.Constants;
import com.me.pacman.PacDude;
import com.me.pacman.Score;
import com.me.pacman.Sound;
import com.me.pacman.SoundManager;
import com.me.pacman.entity.*;
import com.me.pacman.entity.ai.ReturnToBase;
import com.me.pacman.entity.path.EnterGhostHousePath;
import com.me.pacman.level.Level;
import com.me.pacman.level.LevelTile;
import com.me.pacman.level.Modifiers;
import com.me.pacman.RoundModifiers;
import java.util.Random;
public class PlayState extends LevelState {
public static final float FULL_SPEED = 9.375f;
public static final Vector2[] GHOST_SPAWN_POINTS = {
new Vector2(14f, 19.5f),
new Vector2(14f, 16.5f),
new Vector2(12f, 16.5f),
new Vector2(16f, 16.5f),
};
public static final Direction[] GHOST_SPAWN_DIRS = {
Direction.LEFT,
Direction.UP,
Direction.DOWN,
Direction.DOWN,
};
private Texture levelBackground, winBackground;
private TextureRegion lifeSprite;
public Random random;
public int pelletsRemaining;
private int pelletsEaten;
public int pelletsEatenSinceDeath;
public boolean pelletsEatenSinceDeathCounterEnabled;
public boolean hasDied;
@ -104,25 +85,25 @@ public class PlayState extends LevelState {
for (Ghost ghost : ghosts) {
if ((ghost.currentBehaviour instanceof ReturnToBase
|| ghost.currentPath instanceof EnterGhostHousePath) && !ghost.inHouse) {
if (!game.sound.isLooping(Sound.Effect.RETURN_BASE)) {
if (!game.sound.isLooping(SoundManager.Effect.RETURN_BASE)) {
game.sound.stopLoops();
game.sound.loop(Sound.Effect.RETURN_BASE);
game.sound.loop(SoundManager.Effect.RETURN_BASE);
}
return;
}
}
if (frightTimer > 0) {
if (!game.sound.isLooping(Sound.Effect.FRIGHT)) {
if (!game.sound.isLooping(SoundManager.Effect.FRIGHT)) {
game.sound.stopLoops();
game.sound.loop(Sound.Effect.FRIGHT);
game.sound.loop(SoundManager.Effect.FRIGHT);
}
return;
}
if (!game.sound.isLooping(Sound.Effect.SIREN)) {
if (!game.sound.isLooping(SoundManager.Effect.SIREN)) {
game.sound.stopLoops();
game.sound.loop(Sound.Effect.SIREN);
game.sound.loop(SoundManager.Effect.SIREN);
}
}
@ -134,17 +115,17 @@ public class PlayState extends LevelState {
private void spawnGhosts() {
ghosts = new Ghost[4];
ghosts[0] = new Blinky(this, new Vector2(GHOST_SPAWN_POINTS[0]), GHOST_SPAWN_DIRS[0]);
ghosts[1] = new Pinky(this, new Vector2(GHOST_SPAWN_POINTS[1]), GHOST_SPAWN_DIRS[1]);
ghosts[2] = new Inky(this, new Vector2(GHOST_SPAWN_POINTS[2]), GHOST_SPAWN_DIRS[2]);
ghosts[3] = new Clyde(this, new Vector2(GHOST_SPAWN_POINTS[3]), GHOST_SPAWN_DIRS[3]);
ghosts[0] = new Blinky(this, new Vector2(Level.GHOST_SPAWN_POINTS[0]), Constants.GHOST_SPAWN_DIRS[0]);
ghosts[1] = new Pinky(this, new Vector2(Level.GHOST_SPAWN_POINTS[1]), Constants.GHOST_SPAWN_DIRS[1]);
ghosts[2] = new Inky(this, new Vector2(Level.GHOST_SPAWN_POINTS[2]), Constants.GHOST_SPAWN_DIRS[2]);
ghosts[3] = new Clyde(this, new Vector2(Level.GHOST_SPAWN_POINTS[3]), Constants.GHOST_SPAWN_DIRS[3]);
}
public void resetGhosts() {
for (int i = 0; i < 4; i++) {
if (ghosts[i] == null) continue;
ghosts[i].pos = new Vector2(GHOST_SPAWN_POINTS[i]);
ghosts[i].currDirection = GHOST_SPAWN_DIRS[i];
ghosts[i].pos = new Vector2(Level.GHOST_SPAWN_POINTS[i]);
ghosts[i].currDirection = Constants.GHOST_SPAWN_DIRS[i];
ghosts[i].currentPath = null;
ghosts[i].caught = false;
ghosts[i].inHouse = i > 0;
@ -154,7 +135,6 @@ public class PlayState extends LevelState {
private void initializeLevel() {
level = new Level(game,"level");
pelletsRemaining = level.getTileCount(LevelTile.PELLET) + level.getTileCount(LevelTile.POWER_PELLET);
pacman = new Pacman(this, false);
}
@ -162,7 +142,6 @@ public class PlayState extends LevelState {
scatter = true;
scatterChaseTransition = 0;
pelletsEaten = 0;
pelletsEatenSinceDeath = 0;
pelletsEatenSinceDeathCounterEnabled = false;
hasDied = false;
@ -176,7 +155,7 @@ public class PlayState extends LevelState {
lastGhostCaptured = null;
secondsSinceLastDot = 0;
scatterChaseTimer = Modifiers.getScatterChaseTimer(round, scatterChaseTransition);
scatterChaseTimer = RoundModifiers.getScatterChaseTimer(round, scatterChaseTransition);
random = new Random(897198256012865L);
@ -196,7 +175,7 @@ public class PlayState extends LevelState {
initializeLevel();
game.sound.stopAll();
game.sound.play(Sound.Effect.BEGINNING);
game.sound.play(SoundManager.Effect.BEGINNING);
}
private void newGame() {
@ -213,14 +192,36 @@ public class PlayState extends LevelState {
round++;
game.sound.stopAll();
game.sound.play(Sound.Effect.BEGINNING_ALT);
game.sound.play(SoundManager.Effect.BEGINNING_ALT);
}
private void startGame() {
game.sound.loop(Sound.Effect.SIREN);
game.sound.loop(SoundManager.Effect.SIREN);
pacman.moving = true;
}
private GameState endGame() {
Score[] scores = game.highScores.getHighScores(10);
boolean addToScores = scores.length < 10;
int scorePosition = scores.length;
for (int i = 0; i < scores.length; i++) {
if (score > scores[i].score) {
addToScores = true;
scorePosition = i;
break;
}
}
if (addToScores) {
game.setNextState(new HighScoreEntryState(game, new Score("aaa", score), scorePosition));
return null;
}
return GameState.PRE_NEW_GAME;
}
@Override
public void setup() {
levelBackground = game.assets.getLevelBackground();
@ -248,16 +249,12 @@ public class PlayState extends LevelState {
newRound();
return GameState.NEW_ROUND_WAIT;
case GAME_OVER:
if (score > highScore) {
game.setNextState(new HighScoreEntryState(game, new Score("aaa", score)));
return null;
}
return GameState.PRE_NEW_GAME;
return endGame();
case GHOST_CAUGHT_POINTS_WAIT:
updateBackgroundAudio();
return GameState.PLAYING;
case PACMAN_CAUGHT_WAIT:
game.sound.play(Sound.Effect.DEATH);
game.sound.play(SoundManager.Effect.DEATH);
pacman.alive = false;
return GameState.PACMAN_CAUGHT;
}
@ -268,16 +265,16 @@ public class PlayState extends LevelState {
public void render() {
game.fontRenderer.setColor(Color.WHITE);
game.fontRenderer.draw(game.batch, "1up", 3 * 8, 35 * 8);
game.fontRenderer.draw(game.batch, "1up", 3 * Constants.TILE_SIZE, 35 * Constants.TILE_SIZE);
// Draw score
// Determine x position based on score size.
String s = score > 0 ? Integer.toString(score) : "00";
game.fontRenderer.draw(game.batch, s, (7 - s.length()) * 8, 34 * 8);
game.fontRenderer.draw(game.batch, s, (7 - s.length()) * Constants.TILE_SIZE, 34 * Constants.TILE_SIZE);
// Draw high score
game.fontRenderer.draw(game.batch, "high score", 9 * 8, 35 * 8);
game.fontRenderer.draw(game.batch, score >= highScore? s : Integer.toString(highScore), 12 * 8, 34 * 8);
game.fontRenderer.draw(game.batch, "high score", 9 * Constants.TILE_SIZE, 35 * Constants.TILE_SIZE);
game.fontRenderer.draw(game.batch, score >= highScore? s : Integer.toString(highScore), 12 * Constants.TILE_SIZE, 34 * Constants.TILE_SIZE);
// Draw remaining lives
for (int i = 0; i < lives; i++) {
@ -285,14 +282,14 @@ public class PlayState extends LevelState {
}
// Draw the level tiles
level.render(LEVEL_OFFSET_X, LEVEL_OFFSET_Y);
level.render(Constants.LEVEL_OFFSET_X, Constants.LEVEL_OFFSET_Y);
if (state == GameState.ROUND_WON) {
// draw flashing level background
game.batch.draw((int) (stateTimer * 4) % 2 == 0? levelBackground : winBackground, LEVEL_OFFSET_X, LEVEL_OFFSET_Y);
game.batch.draw((int) (stateTimer * 4) % 2 == 0? levelBackground : winBackground, Constants.LEVEL_OFFSET_X, Constants.LEVEL_OFFSET_Y);
return;
} else {
game.batch.draw(levelBackground, LEVEL_OFFSET_X, LEVEL_OFFSET_Y);
game.batch.draw(levelBackground, Constants.LEVEL_OFFSET_X, Constants.LEVEL_OFFSET_Y);
}
if (state != GameState.GHOST_CAUGHT_POINTS_WAIT) {
@ -317,18 +314,18 @@ public class PlayState extends LevelState {
if (paused) {
game.fontRenderer.setColor(Color.YELLOW);
game.fontRenderer.draw(game.batch, "paused", 11 * 8, 15 * 8);
game.fontRenderer.draw(game.batch, "paused", 11 * Constants.TILE_SIZE, 15 * Constants.TILE_SIZE);
} else {
switch (state) {
case PRE_NEW_GAME:
case NEW_ROUND_WAIT:
case START_ROUND_WAIT:
game.fontRenderer.setColor(Color.YELLOW);
game.fontRenderer.draw(game.batch, "ready!", 11 * 8, 15 * 8);
game.fontRenderer.draw(game.batch, "ready!", 11 * Constants.TILE_SIZE, 15 * Constants.TILE_SIZE);
break;
case GAME_OVER:
game.fontRenderer.setColor(Color.RED);
game.fontRenderer.draw(game.batch, "game over", (9 * 8) + 4, 15 * 8);
game.fontRenderer.draw(game.batch, "game over", (9 * Constants.TILE_SIZE) + Constants.TILE_SIZE/2, 15 * Constants.TILE_SIZE);
break;
}
}
@ -337,10 +334,7 @@ public class PlayState extends LevelState {
private void pelletEaten(float x, float y) {
level.setTile(x, y, LevelTile.EMPTY);
game.sound.play(pelletsEaten % 2 == 0? Sound.Effect.CHOMP_1 : Sound.Effect.CHOMP_2);
pelletsEaten++;
pelletsRemaining--;
game.sound.play(level.getPelletsEaten() % 2 == 0? SoundManager.Effect.CHOMP_1 : SoundManager.Effect.CHOMP_2);
if (pelletsEatenSinceDeathCounterEnabled) {
// Increase global dot counter when enabled
@ -359,7 +353,7 @@ public class PlayState extends LevelState {
secondsSinceLastDot = 0;
if (pelletsRemaining == 0) {
if (level.getPelletsRemaining() == 0) {
game.sound.stopLoops();
setGameState(GameState.ROUND_WON_WAIT);
}
@ -378,7 +372,7 @@ public class PlayState extends LevelState {
ghost.currentBehaviour = ghost.frightBehaviour;
ghost.reverse = true;
}
frightTimer = Modifiers.getFrightTime(round);
frightTimer = RoundModifiers.getFrightTime(round);
ghostsCaught = 0;
score += 50;
@ -386,7 +380,7 @@ public class PlayState extends LevelState {
}
private void pacmanCaught() {
game.sound.stopLooping(Sound.Effect.SIREN);
game.sound.stopLooping(SoundManager.Effect.SIREN);
pacman.moving = false;
pelletsEatenSinceDeath = 0;
pelletsEatenSinceDeathCounterEnabled = true;
@ -403,7 +397,7 @@ public class PlayState extends LevelState {
ghostsCaught++;
score += ghostsCaught * 200;
game.sound.play(Sound.Effect.EAT_GHOST);
game.sound.play(SoundManager.Effect.EAT_GHOST);
setGameState(GameState.GHOST_CAUGHT_POINTS_WAIT);
}
@ -413,7 +407,7 @@ public class PlayState extends LevelState {
if (scatterChaseTimer <= 0) {
scatter = !scatter;
scatterChaseTransition++;
scatterChaseTimer = Modifiers.getScatterChaseTimer(round, scatterChaseTransition);
scatterChaseTimer = RoundModifiers.getScatterChaseTimer(round, scatterChaseTransition);
}
}
}
@ -433,7 +427,7 @@ public class PlayState extends LevelState {
private void updateSecondsSinceLastDot(float dt) {
secondsSinceLastDot += dt;
if (secondsSinceLastDot >= Modifiers.getForceLeaveSeconds(round)) {
if (secondsSinceLastDot >= RoundModifiers.getForceLeaveSeconds(round)) {
// It's been 4 seconds since pacman last ate a dot, he's tryin' to avoid ghosts coming out!
// We'll get him...
for (int i = 1; i < 4; i++) {
@ -466,7 +460,7 @@ public class PlayState extends LevelState {
return;
}
if (PacDude.DEBUG) {
if (Constants.DEBUG) {
// Fixed time step for debugger
dt = 1/60f;
}

View File

@ -2,14 +2,15 @@ package com.me.pacman.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.me.pacman.Constants;
import com.me.pacman.PacDude;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = PacDude.TITLE + " - " + PacDude.VERSION;
config.width = PacDude.LEVEL_WIDTH * 2;
config.height = PacDude.LEVEL_HEIGHT * 2;
config.title = Constants.TITLE + " - " + Constants.VERSION;
config.width = Constants.GAME_WIDTH * 2;
config.height = Constants.GAME_HEIGHT * 2;
config.resizable = true;
new LwjglApplication(new PacDude(), config);
}