parent
61a495e1d1
commit
dee27b2770
@ -1,33 +1,74 @@
|
|||||||
package com.throwgame.main;
|
package com.throwgame.main;
|
||||||
|
|
||||||
import com.badlogic.gdx.ApplicationAdapter;
|
import com.badlogic.gdx.ApplicationAdapter;
|
||||||
|
import com.badlogic.gdx.Game;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.InputProcessor;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import controller.Controller;
|
||||||
|
import view.Levelscreen;
|
||||||
|
import view.Titlescreen;
|
||||||
|
|
||||||
public class Main extends ApplicationAdapter {
|
public class Main extends Game implements InputProcessor{
|
||||||
SpriteBatch batch;
|
|
||||||
Texture img;
|
//Controller c;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create () {
|
public void create () {
|
||||||
batch = new SpriteBatch();
|
//c = new Controller();
|
||||||
img = new Texture("badlogic.jpg");
|
|
||||||
|
setScreen(new Titlescreen(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render () {
|
public void render () {
|
||||||
Gdx.gl.glClearColor(1, 0, 0, 1);
|
screen.render(0);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
||||||
batch.begin();
|
|
||||||
batch.draw(img, 0, 0);
|
|
||||||
batch.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose () {
|
public void dispose () {
|
||||||
batch.dispose();
|
|
||||||
img.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyDown(int i) {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyUp(int i) {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyTyped(char c) {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchDown(int i, int i1, int i2, int i3) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchUp(int i, int i1, int i2, int i3) {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchDragged(int i, int i1, int i2) {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseMoved(int i, int i1) {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean scrolled(int i) {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package view;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Game;
|
||||||
|
import com.badlogic.gdx.Screen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jan
|
||||||
|
*/
|
||||||
|
public class AbstractScreen implements Screen{
|
||||||
|
protected Game game;
|
||||||
|
|
||||||
|
public AbstractScreen(Game game){
|
||||||
|
this.game = game;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(float f) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resize(int i, int i1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pause() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resume() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package view;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Game;
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jan
|
||||||
|
*/
|
||||||
|
public class Gamescreen extends AbstractScreen{
|
||||||
|
|
||||||
|
public Gamescreen(Game game){
|
||||||
|
super(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(float f) {
|
||||||
|
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
|
||||||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
BitmapFont font = new BitmapFont();
|
||||||
|
font.setColor(Color.RED);
|
||||||
|
SpriteBatch batch = new SpriteBatch();
|
||||||
|
batch.begin();
|
||||||
|
font.draw(batch, "GAMESCREEN", 250, 250);
|
||||||
|
batch.end();
|
||||||
|
|
||||||
|
if(Gdx.input.justTouched()){
|
||||||
|
game.setScreen(new Titlescreen(game));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resize(int i, int i1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pause() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resume() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package view;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Game;
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Input;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jan
|
||||||
|
*/
|
||||||
|
public class Levelscreen extends AbstractScreen{
|
||||||
|
|
||||||
|
public Levelscreen(Game game){
|
||||||
|
super(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(float f) {
|
||||||
|
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
|
||||||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
BitmapFont font = new BitmapFont();
|
||||||
|
font.setColor(Color.RED);
|
||||||
|
SpriteBatch batch = new SpriteBatch();
|
||||||
|
batch.begin();
|
||||||
|
font.draw(batch, "LEVELSCREEN", 250, 250);
|
||||||
|
batch.end();
|
||||||
|
|
||||||
|
if(Gdx.input.justTouched()){
|
||||||
|
game.setScreen(new Gamescreen(game));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resize(int i, int i1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pause() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resume() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package view;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Game;
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Input;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jan
|
||||||
|
*/
|
||||||
|
public class Titlescreen extends AbstractScreen{
|
||||||
|
|
||||||
|
public Titlescreen(Game game){
|
||||||
|
super(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(float f) {
|
||||||
|
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
|
||||||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BitmapFont font = new BitmapFont();
|
||||||
|
font.setColor(Color.RED);
|
||||||
|
SpriteBatch batch = new SpriteBatch();
|
||||||
|
batch.begin();
|
||||||
|
font.draw(batch, "TITLESCREEN", 250, 250);
|
||||||
|
batch.end();
|
||||||
|
|
||||||
|
if(Gdx.input.justTouched()){
|
||||||
|
game.setScreen(new Levelscreen(game));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resize(int i, int i1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pause() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resume() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue