use of net.catacombsnatch.game.world.level.View 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);
}
use of net.catacombsnatch.game.world.level.View in project Catacomb-Snatch by Catacomb-Snatch.
the class GameScene method update.
@Override
public void update(boolean resize) {
if (!resize || views == null)
return;
float w = Screen.getWidth(), h = Screen.getHeight();
for (View view : views) {
view.setViewport(0, 0, w, h);
view.update(true);
}
}
Aggregations