Package com.supercookie.deathrace

Source Code of com.supercookie.deathrace.DeathRaceGame

package com.supercookie.deathrace;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.utils.viewport.StretchViewport;
import com.supercookie.deathrace.road.Road;

public class DeathRaceGame extends Game {

    public static final int GAME_VIEWPORT_WIDTH = 1920, GAME_VIEWPORT_HEIGHT = 1080;

    @Override
    public void create() {
        setScreen(new Screen() {

            private final Stage stage = new Stage(new StretchViewport(GAME_VIEWPORT_WIDTH, GAME_VIEWPORT_HEIGHT));
            private final BitmapFont bitmapFont = new BitmapFont();
            private final Label fps = new Label("", new Label.LabelStyle(bitmapFont, Color.WHITE));
            private final Road road = new Road();

            @Override
            public void render(float v) {
                GL20 gl = Gdx.graphics.getGL20();
                gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
                fps.setText("" + Gdx.graphics.getFramesPerSecond());

                road.update(v);
                road.render(stage.getCamera());

                stage.act();
                stage.draw();
            }

            @Override
            public void resize(int i, int i2) {

            }

            @Override
            public void show() {
                fps.setFontScale(5F);
                stage.addActor(fps);
                road.resetRoad();
            }

            @Override
            public void hide() {

            }

            @Override
            public void pause() {

            }

            @Override
            public void resume() {

            }

            @Override
            public void dispose() {

            }
        });
    }
}
TOP

Related Classes of com.supercookie.deathrace.DeathRaceGame

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.