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;
|
|
|
|
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-24 07:28:09 -07:00
|
|
|
import com.me.pacman.state.PlayState;
|
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";
|
2019-12-28 13:33:16 -07:00
|
|
|
public static final String VERSION = "v0.1.0";
|
2019-12-23 12:07:24 -07:00
|
|
|
|
2019-12-27 03:32:22 -07:00
|
|
|
public static final boolean DEBUG = false;
|
|
|
|
|
2019-12-23 12:07:24 -07:00
|
|
|
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-24 04:11:41 -07:00
|
|
|
public Assets assets;
|
2019-12-23 13:59:13 -07:00
|
|
|
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-24 04:11:41 -07:00
|
|
|
assets = new Assets();
|
|
|
|
assets.loadAssets();
|
|
|
|
|
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
|
|
|
|
2019-12-24 07:28:09 -07:00
|
|
|
setScreen(new PlayState(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
|
|
|
|
2019-12-24 02:07:35 -07:00
|
|
|
batch.begin();
|
2019-12-23 13:59:13 -07:00
|
|
|
super.render();
|
2019-12-24 02:07:35 -07:00
|
|
|
batch.end();
|
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
|
|
|
}
|
|
|
|
}
|