Android Open Source - Ready-Set-Rogue Main Menu Screen






From Project

Back to project page Ready-Set-Rogue.

License

The source code is released under:

GNU General Public License

If you think the Android project Ready-Set-Rogue listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.warsheep.scamp.screens;
// w  ww . j  av  a2 s . co m
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector3;
import com.warsheep.scamp.Scamp;

import java.util.Random;

public class MainMenuScreen extends ScreenAdapter {

    Scamp game;
    OrthographicCamera guiCam;
    Rectangle playBounds;
    Vector3 touchPoint;

    private static Random rnd = new Random();

    public MainMenuScreen(Scamp game) {
        this.game = game;

        guiCam = new OrthographicCamera(Scamp.V_WIDTH, Scamp.V_HEIGHT);
        guiCam.position.set(Scamp.V_WIDTH / 2, Scamp.V_HEIGHT / 2, 0);
        playBounds = new Rectangle(Gdx.graphics.getWidth()/4, Gdx.graphics.getHeight()/4, Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
        touchPoint = new Vector3();
    }

    public void update() {
        if (Gdx.input.justTouched()) {
            guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

            if (playBounds.contains(touchPoint.x, touchPoint.y)) {
//                Assets.playSound(Assets.clickSound);
                game.setScreen(new MainGameScreen(game));
                return;
            }
        }
    }

    public void draw () {
        GL20 gl = Gdx.gl;
        gl.glClearColor(0, 0, 0, 1);
        gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        guiCam.update();
        game.batcher.setProjectionMatrix(guiCam.combined);

        CharSequence str = "Play";
        SpriteBatch spriteBatch = new SpriteBatch();
        BitmapFont font = new BitmapFont();

        spriteBatch.begin();
        font.draw(spriteBatch, str, Gdx.graphics.getWidth()/2 - 12, Gdx.graphics.getHeight()/2);
        spriteBatch.end();
    }

    @Override
    public void render (float delta) {
        update();
        draw();
    }

}




Java Source Code List

com.warsheep.scamp.AssetDepot.java
com.warsheep.scamp.IOSLauncher.java
com.warsheep.scamp.MapImporter.java
com.warsheep.scamp.PrefabFactory.java
com.warsheep.scamp.Scamp.java
com.warsheep.scamp.adt.BSPRectangle.java
com.warsheep.scamp.adt.Container.java
com.warsheep.scamp.adt.Pair.java
com.warsheep.scamp.adt.Room.java
com.warsheep.scamp.algorithms.BSPMapGenerator.java
com.warsheep.scamp.algorithms.Compositor.java
com.warsheep.scamp.android.AndroidLauncher.java
com.warsheep.scamp.client.HtmlLauncher.java
com.warsheep.scamp.components.AIControllableComponent.java
com.warsheep.scamp.components.AttackerComponent.java
com.warsheep.scamp.components.CameraComponent.java
com.warsheep.scamp.components.CollidableComponent.java
com.warsheep.scamp.components.ControllableComponent.java
com.warsheep.scamp.components.DamageableComponent.java
com.warsheep.scamp.components.DropComponent.java
com.warsheep.scamp.components.ECSMapper.java
com.warsheep.scamp.components.FactionComponent.java
com.warsheep.scamp.components.InventoryComponent.java
com.warsheep.scamp.components.LevelComponent.java
com.warsheep.scamp.components.MovementComponent.java
com.warsheep.scamp.components.StateComponent.java
com.warsheep.scamp.components.TileComponent.java
com.warsheep.scamp.components.TransformComponent.java
com.warsheep.scamp.components.VisibleComponent.java
com.warsheep.scamp.desktop.AssetPacker.java
com.warsheep.scamp.desktop.DesktopLauncher.java
com.warsheep.scamp.processors.AIProcessor.java
com.warsheep.scamp.processors.CameraProcessor.java
com.warsheep.scamp.processors.CollisionProcessor.java
com.warsheep.scamp.processors.CombatProcessor.java
com.warsheep.scamp.processors.ControlProcessor.java
com.warsheep.scamp.processors.DeathProcessor.java
com.warsheep.scamp.processors.LevelingProcessor.java
com.warsheep.scamp.processors.MovementProcessor.java
com.warsheep.scamp.processors.StateProcessor.java
com.warsheep.scamp.processors.TileProcessor.java
com.warsheep.scamp.processors.VisibilityProcessor.java
com.warsheep.scamp.screens.MainGameScreen.java
com.warsheep.scamp.screens.MainMenuScreen.java