Search in sources :

Example 1 with MainController

use of com.hackerhop.game.core.MainController in project HackerHop by nicovank.

the class GameOverScene method keyDown.

@Override
public boolean keyDown(int keycode) {
    if (keycode == Input.Keys.ESCAPE) {
        MainController controller = super.getController();
        controller.setScene(new MainMenu(controller));
    }
    return true;
}
Also used : MainController(com.hackerhop.game.core.MainController)

Example 2 with MainController

use of com.hackerhop.game.core.MainController in project HackerHop by nicovank.

the class GameScene method keyDown.

/**
 * Called when a key is pressed.
 *
 * @param keycode The code of the pressed key.
 * @return whether the input was processed.
 */
@Override
public boolean keyDown(int keycode) {
    if (keycode == Input.Keys.A || keycode == Input.Keys.LEFT) {
        player.getBody().applyForceToCenter(new Vec2(-5000f, 0f));
        player.setDirection(Direction.LEFT);
    }
    if (keycode == Input.Keys.D || keycode == Input.Keys.RIGHT) {
        player.getBody().applyForceToCenter(new Vec2(5000f, 0f));
        player.setDirection(Direction.RIGHT);
    }
    if (keycode == Input.Keys.SPACE || keycode == Input.Keys.UP) {
        player.getBody().applyForceToCenter(new Vec2(0f, 5000f));
        jump.play(0.2f);
    }
    if (keycode == Input.Keys.ESCAPE) {
        MainController controller = super.getController();
        controller.setScene(new MainMenu(controller));
    }
    return true;
}
Also used : Vec2(org.jbox2d.common.Vec2) MainController(com.hackerhop.game.core.MainController)

Example 3 with MainController

use of com.hackerhop.game.core.MainController in project HackerHop by nicovank.

the class MainMenu method touchDown.

@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    int y = Gdx.graphics.getHeight() - screenY;
    MainController controller = super.getController();
    if (sprite1.getBoundingRectangle().contains(screenX, y)) {
        controller.setScene(new GameScene(controller, Character.ROB));
    } else if (sprite2.getBoundingRectangle().contains(screenX, y)) {
        controller.setScene(new GameScene(controller, Character.NICK));
    } else if (sprite3.getBoundingRectangle().contains(screenX, y)) {
        controller.setScene(new GameScene(controller, Character.KATIE));
    } else if (sprite4.getBoundingRectangle().contains(screenX, y)) {
        controller.setScene(new GameScene(controller, Character.YE));
    } else if (gitHubButton.getBoundingRectangle().contains(screenX, y)) {
        try {
            openWebpage(new URL("https://github.com/nicovank/HackerHop"));
        } catch (MalformedURLException ignored) {
        }
    }
    return true;
}
Also used : MalformedURLException(java.net.MalformedURLException) MainController(com.hackerhop.game.core.MainController) URL(java.net.URL)

Example 4 with MainController

use of com.hackerhop.game.core.MainController in project HackerHop by nicovank.

the class GameDesktop method main.

public static void main(String[] args) {
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
    config.height = 720;
    config.width = 540;
    config.resizable = false;
    new LwjglApplication(new MainController(), config);
}
Also used : LwjglApplication(com.badlogic.gdx.backends.lwjgl.LwjglApplication) MainController(com.hackerhop.game.core.MainController) LwjglApplicationConfiguration(com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration)

Aggregations

MainController (com.hackerhop.game.core.MainController)4 LwjglApplication (com.badlogic.gdx.backends.lwjgl.LwjglApplication)1 LwjglApplicationConfiguration (com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Vec2 (org.jbox2d.common.Vec2)1