use of net.catacombsnatch.game.player.LocalPlayer in project Catacomb-Snatch by Catacomb-Snatch.
the class CatacombSnatch method create.
@Override
public void create() {
Gdx.app.setLogLevel(Application.LOG_INFO | Application.LOG_DEBUG | Application.LOG_ERROR);
if (!Art.loadResources())
Gdx.app.exit();
// Load options
options = new PreferenceOptions("catacombsnatch-options.xml");
DefaultOptions.setDefaults();
// Load sound system
try {
sound = new GdxSoundPlayer();
} catch (Exception e) {
Gdx.app.log(TAG, "Could not enable sound system, falling back to NoSound!", e);
sound = new NoSoundPlayer();
}
// Load main managers
sceneManager = new SceneManager();
input = new InputManager();
Gdx.input.setInputProcessor(input);
platform.create();
Controllers.addListener(input);
EventManager.registerListener(this);
// Dive in :)
localPlayers = new Player[4];
localPlayers[0] = new LocalPlayer();
SceneManager.switchTo(TitleScreen.class);
}
use of net.catacombsnatch.game.player.LocalPlayer in project Catacomb-Snatch by Catacomb-Snatch.
the class GameScene method tick.
@Override
public void tick(float delta) {
if (campaign.hasFinished()) {
SceneManager.exit();
return;
}
if (!paused) {
// Tick, tock - the campaign is just a clock...
campaign.tick(delta);
// Prepare views for rendering and level initialization
if (views == null) {
final Level level = campaign.getCurrentLevel();
views = new LinkedList<>();
for (Player player : campaign.players) {
if (!(player instanceof LocalPlayer))
continue;
final View view = new View(level);
view.setTarget(player.createEntity(level).getComponent(Position.class).xy());
views.add(view);
}
// Update viewports
update(true);
}
// Player movement
int mx = 0, my = 0;
if (InputManager.isPressed(Key.MOVE_LEFT))
mx--;
if (InputManager.isPressed(Key.MOVE_RIGHT))
mx++;
if (InputManager.isPressed(Key.MOVE_UP))
my++;
if (InputManager.isPressed(Key.MOVE_DOWN))
my--;
for (Entity player : campaign.getCurrentLevel().players) {
Entities.velocity.get(player).add(mx << 2, my << 2);
}
}
// Open the windows to see what's happening!
getBatch().begin();
for (View view : views) {
view.render(this);
}
getBatch().end();
// Just some overlays
super.tick(delta);
}
Aggregations