Search in sources :

Example 1 with LocalPlayer

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);
}
Also used : SceneManager(net.catacombsnatch.game.scene.SceneManager) NoSoundPlayer(net.catacombsnatch.game.sound.NoSoundPlayer) LocalPlayer(net.catacombsnatch.game.player.LocalPlayer) GdxSoundPlayer(net.catacombsnatch.game.sound.GdxSoundPlayer) InputManager(net.catacombsnatch.game.event.input.InputManager) PreferenceOptions(net.catacombsnatch.game.resource.options.PreferenceOptions)

Example 2 with LocalPlayer

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);
}
Also used : Entity(com.badlogic.ashley.core.Entity) LocalPlayer(net.catacombsnatch.game.player.LocalPlayer) Player(net.catacombsnatch.game.player.Player) LocalPlayer(net.catacombsnatch.game.player.LocalPlayer) Level(net.catacombsnatch.game.world.level.Level) View(net.catacombsnatch.game.world.level.View)

Aggregations

LocalPlayer (net.catacombsnatch.game.player.LocalPlayer)2 Entity (com.badlogic.ashley.core.Entity)1 InputManager (net.catacombsnatch.game.event.input.InputManager)1 Player (net.catacombsnatch.game.player.Player)1 PreferenceOptions (net.catacombsnatch.game.resource.options.PreferenceOptions)1 SceneManager (net.catacombsnatch.game.scene.SceneManager)1 GdxSoundPlayer (net.catacombsnatch.game.sound.GdxSoundPlayer)1 NoSoundPlayer (net.catacombsnatch.game.sound.NoSoundPlayer)1 Level (net.catacombsnatch.game.world.level.Level)1 View (net.catacombsnatch.game.world.level.View)1