2019-12-23 12:07:24 -07:00
|
|
|
package com.me.pacman;
|
|
|
|
|
2019-12-23 13:59:13 -07:00
|
|
|
import com.badlogic.gdx.Game;
|
2019-12-23 12:07:24 -07:00
|
|
|
import com.badlogic.gdx.Gdx;
|
2019-12-23 13:59:13 -07:00
|
|
|
import com.badlogic.gdx.assets.AssetManager;
|
2019-12-23 12:07:24 -07:00
|
|
|
import com.badlogic.gdx.graphics.GL20;
|
|
|
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
|
|
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
2019-12-23 15:27:05 -07:00
|
|
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
2019-12-23 12:07:24 -07:00
|
|
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
|
|
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
2019-12-23 13:59:13 -07:00
|
|
|
import com.me.pacman.state.MenuState;
|
2019-12-23 12:07:24 -07:00
|
|
|
|
2019-12-23 13:59:13 -07:00
|
|
|
public class PacDude extends Game {
|
2019-12-23 12:07:24 -07:00
|
|
|
|
|
|
|
public static final String TITLE = "Pac-Dude";
|
|
|
|
public static final String VERSION = "v0.0.1";
|
|
|
|
|
|
|
|
public static final int LEVEL_WIDTH = 224;
|
2019-12-24 01:51:42 -07:00
|
|
|
public static final int LEVEL_HEIGHT = 288;
|
2019-12-23 12:07:24 -07:00
|
|
|
|
2019-12-23 13:59:13 -07:00
|
|
|
public AssetManager assets;
|
|
|
|
public SpriteBatch batch;
|
2019-12-23 15:27:05 -07:00
|
|
|
public ShapeRenderer sr;
|
2019-12-23 13:59:13 -07:00
|
|
|
|
2019-12-23 12:07:24 -07:00
|
|
|
public OrthographicCamera cam;
|
|
|
|
public Viewport viewport;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void create () {
|
|
|
|
cam = new OrthographicCamera();
|
|
|
|
viewport = new FitViewport(LEVEL_WIDTH, LEVEL_HEIGHT, cam);
|
|
|
|
viewport.apply(true);
|
|
|
|
|
2019-12-23 13:59:13 -07:00
|
|
|
assets = new AssetManager();
|
2019-12-23 12:07:24 -07:00
|
|
|
batch = new SpriteBatch();
|
2019-12-23 15:27:05 -07:00
|
|
|
sr = new ShapeRenderer();
|
2019-12-23 13:59:13 -07:00
|
|
|
|
|
|
|
setScreen(new MenuState(this));
|
2019-12-23 12:07:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render () {
|
|
|
|
Gdx.gl.glClearColor(0, 0, 0, 1);
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
2019-12-23 13:59:13 -07:00
|
|
|
|
|
|
|
super.render();
|
2019-12-23 12:07:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void resize(int width, int height) {
|
|
|
|
viewport.update(width, height);
|
|
|
|
|
|
|
|
batch.setProjectionMatrix(cam.combined);
|
2019-12-23 15:27:05 -07:00
|
|
|
sr.setProjectionMatrix(cam.combined);
|
2019-12-23 12:07:24 -07:00
|
|
|
|
|
|
|
super.resize(width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void dispose () {
|
|
|
|
batch.dispose();
|
2019-12-23 13:59:13 -07:00
|
|
|
assets.dispose();
|
2019-12-23 12:07:24 -07:00
|
|
|
}
|
|
|
|
}
|