Dot eater
This commit is contained in:
parent
124f665232
commit
ea4426f0a0
@ -1,6 +1,7 @@
|
||||
package com.me.pacman.entity;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.me.pacman.level.LevelTile;
|
||||
import com.me.pacman.state.PlayState;
|
||||
|
||||
public class Pacman extends MovableEntity {
|
||||
@ -10,6 +11,8 @@ public class Pacman extends MovableEntity {
|
||||
private PlayState state;
|
||||
private int counter = 1;
|
||||
|
||||
private int freezeFrames = 0;
|
||||
|
||||
public Pacman(PlayState state) {
|
||||
super(state, 14, 7.5f, 7.5f, true, Direction.EAST, 0.3f);
|
||||
this.state = state;
|
||||
@ -38,11 +41,23 @@ public class Pacman extends MovableEntity {
|
||||
|
||||
@Override
|
||||
public void update(float dt) {
|
||||
if (freezeFrames > 0) {
|
||||
freezeFrames--;
|
||||
return;
|
||||
}
|
||||
|
||||
super.update(dt);
|
||||
|
||||
if (!state.paused && canMove && age % 4 == 0) {
|
||||
counter += 1;
|
||||
}
|
||||
|
||||
switch (state.level.getComponent(x, y)) {
|
||||
case PELLET:
|
||||
state.level.setComponent(x, y, LevelTile.EMPTY);
|
||||
freezeFrames = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,10 @@ public class Level {
|
||||
components[y][x] = component;
|
||||
}
|
||||
|
||||
public void setComponent(float x, float y, LevelTile component) {
|
||||
setComponent((int) x, (int) y, component);
|
||||
}
|
||||
|
||||
public void render(int offsetX, int offsetY) {
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
LevelTile[] row = components[i];
|
||||
|
@ -10,7 +10,7 @@ public class DesktopLauncher {
|
||||
config.title = PacDude.TITLE + " - " + PacDude.VERSION;
|
||||
config.width = PacDude.LEVEL_WIDTH * 2;
|
||||
config.height = PacDude.LEVEL_HEIGHT * 2;
|
||||
config.resizable = true;
|
||||
config.resizable = false;
|
||||
new LwjglApplication(new PacDude(), config);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user