Sletter ubrukt kode og omstruktuerer klasser

Fjerner AppTest.java
Fjerner HelloWorld.java
Fjerner GameBoard.java
Flytter alle filer fra inf112.skeleton.app til inf112.fiasko.roborally
Flytter IDrawableGame og Game til en egen pakke
Flytter IDrawableObject og DrawableObject til en egen pakke
Flytter GameTexture til en egen pakke
This commit is contained in:
Kristian Knarvik 2020-02-04 17:52:17 +01:00
parent d73e027e51
commit 2d40d9fd21
12 changed files with 27 additions and 144 deletions

View File

@ -1,4 +1,4 @@
package inf112.skeleton.app;
package inf112.fiasko.roborally;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
@ -6,6 +6,10 @@ import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import inf112.fiasko.roborally.abstractions.GameTexture;
import inf112.fiasko.roborally.game.Game;
import inf112.fiasko.roborally.game.IDrawableGame;
import inf112.fiasko.roborally.objects.IDrawableObject;
/**
* This class renders a game using libgdx

View File

@ -1,8 +1,7 @@
package inf112.skeleton.app;
package inf112.fiasko.roborally;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import inf112.skeleton.app.demo.GameBoard;
public class Main {

View File

@ -1,4 +1,4 @@
package inf112.skeleton.app;
package inf112.fiasko.roborally.abstractions;
/**
* This enum represents a drawable texture

View File

@ -1,4 +1,8 @@
package inf112.skeleton.app;
package inf112.fiasko.roborally.game;
import inf112.fiasko.roborally.abstractions.GameTexture;
import inf112.fiasko.roborally.objects.DrawableObject;
import inf112.fiasko.roborally.objects.IDrawableObject;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,6 @@
package inf112.skeleton.app;
package inf112.fiasko.roborally.game;
import inf112.fiasko.roborally.objects.IDrawableObject;
import java.util.List;

View File

@ -1,4 +1,6 @@
package inf112.skeleton.app;
package inf112.fiasko.roborally.objects;
import inf112.fiasko.roborally.abstractions.GameTexture;
/**
* This class represents an object that can be drawn using libgdx

View File

@ -1,4 +1,6 @@
package inf112.skeleton.app;
package inf112.fiasko.roborally.objects;
import inf112.fiasko.roborally.abstractions.GameTexture;
/**
* This interface describes an object drawable using libgdx

View File

@ -1,67 +0,0 @@
package inf112.skeleton.app.demo;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Rectangle;
public class GameBoard extends ApplicationAdapter {
private OrthographicCamera camera;
private SpriteBatch batch;
private Texture robotTexture;
private Texture tileTexture;
private Rectangle robot;
@Override
public void create() {
//Loads some textures
robotTexture = new Texture(Gdx.files.internal("assets/Robot.png"));
tileTexture = new Texture(Gdx.files.internal("assets/Tile.png"));
robot = new Rectangle((float)768/2,(float)768/2,64,64);
camera = new OrthographicCamera();
camera.setToOrtho(false, 768, 768);
batch = new SpriteBatch();
}
/**
* Renders all textures necessary to display a game
*/
public void render() {
Gdx.gl.glClearColor(0,0,0.2f,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
batch.setProjectionMatrix(camera.combined);
batch.begin();
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
batch.draw(tileTexture, i * 64, j * 64);
}
}
batch.draw(robotTexture, robot.x, robot.y);
batch.end();
if (Gdx.input.isKeyJustPressed(Input.Keys.RIGHT) && robot.x < 768-64) {
robot.x += 64;
}
if (Gdx.input.isKeyJustPressed(Input.Keys.LEFT) && robot.x > 0) {
robot.x -= 64;
}
if (Gdx.input.isKeyJustPressed(Input.Keys.UP) && robot.y < 768-64) {
robot.y += 64;
}
if (Gdx.input.isKeyJustPressed(Input.Keys.DOWN) && robot.y > 0) {
robot.y -= 64;
}
}
@Override
public void dispose() {
batch.dispose();
}
}

View File

@ -1,48 +0,0 @@
package inf112.skeleton.app.demo;
import com.badlogic.gdx.ApplicationListener;
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;
public class HelloWorld implements ApplicationListener {
private SpriteBatch batch;
private BitmapFont font;
@Override
public void create() {
batch = new SpriteBatch();
font = new BitmapFont();
font.setColor(Color.RED);
}
@Override
public void dispose() {
batch.dispose();
font.dispose();
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
font.draw(batch, "Hello World", 200, 200);
batch.end();
}
@Override
public void resize(int width, int height) {
}
@Override
public void pause() {
}
@Override
public void resume() {
}
}

View File

@ -1,5 +1,7 @@
package inf112.skeleton.app;
package inf112.fiasko.roborally;
import inf112.fiasko.roborally.objects.DrawableObject;
import inf112.fiasko.roborally.abstractions.GameTexture;
import org.junit.Before;
import org.junit.Test;

View File

@ -1,8 +1,10 @@
package inf112.skeleton.app;
package inf112.fiasko.roborally;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import inf112.fiasko.roborally.game.Game;
import inf112.fiasko.roborally.game.IDrawableGame;
import org.junit.Before;
import org.junit.Test;

View File

@ -1,19 +0,0 @@
package inf112.skeleton.app;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}