Various changes and fixes.
Set dirty = true in setVertices() Correct Viewport worldWidth/worldHeight assignment Optimize imports + various formatting Remove html project
This commit is contained in:
@ -3,4 +3,4 @@ apply plugin: "java"
|
||||
sourceCompatibility = 1.7
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||
sourceSets.main.java.srcDirs = ["src/"]
|
||||
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd">
|
||||
<module>
|
||||
<source path="com/me/asteroids" />
|
||||
</module>
|
@ -61,7 +61,7 @@ public final class AsteroidFactory {
|
||||
if (angleVariation < 0) {
|
||||
throw new IllegalStateException(String.format("Illegal angleVariation: %f. Must be >= 0.", angleVariation));
|
||||
}
|
||||
if (angleVariation > MathUtils.PI2 / vertexCount / 2) {
|
||||
if (angleVariation > MathUtils.PI2 / vertexCount / 2) {
|
||||
throw new IllegalStateException(String.format("Illegal angleVariation: %f. May cause vertexes positions to swap.", angleVariation));
|
||||
}
|
||||
}
|
||||
|
@ -7,33 +7,33 @@ import com.me.common.Game;
|
||||
|
||||
public class Asteroids extends ApplicationAdapter {
|
||||
|
||||
public Graphics graphics;
|
||||
private Game game;
|
||||
public Graphics graphics;
|
||||
private Game game;
|
||||
|
||||
@Override
|
||||
public void create () {
|
||||
graphics = new Graphics(Constants.WIDTH, Constants.HEIGHT);
|
||||
graphics.initialize();
|
||||
@Override
|
||||
public void create() {
|
||||
graphics = new Graphics(Constants.WIDTH, Constants.HEIGHT);
|
||||
graphics.initialize();
|
||||
|
||||
game = new Game();
|
||||
game.setNextScreen(new GameScreen(graphics));
|
||||
}
|
||||
game = new Game();
|
||||
game.setNextScreen(new GameScreen(graphics));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render () {
|
||||
game.update(Gdx.graphics.getDeltaTime());
|
||||
game.render();
|
||||
}
|
||||
@Override
|
||||
public void render() {
|
||||
game.update(Gdx.graphics.getDeltaTime());
|
||||
game.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose () {
|
||||
graphics.dispose();
|
||||
game.dispose();
|
||||
}
|
||||
@Override
|
||||
public void dispose() {
|
||||
graphics.dispose();
|
||||
game.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
graphics.setScreenSize(width, height);
|
||||
}
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
graphics.setScreenSize(width, height);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class Graphics {
|
||||
this.screenHeight = Gdx.graphics.getHeight();
|
||||
|
||||
this.camera = new OrthographicCamera();
|
||||
this.viewport = new FitViewport(worldHeight, worldWidth, camera);
|
||||
this.viewport = new FitViewport(worldWidth, worldHeight, camera);
|
||||
|
||||
this.shapeRenderer = new ShapeRenderer();
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ public class LineModel implements Model {
|
||||
@Override
|
||||
public void setVertices(float[] vertices) {
|
||||
model.setVertices(vertices);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,7 +95,7 @@ public class LineModel implements Model {
|
||||
|
||||
for (int i = 2, n = vertices.length; i < n; i += 2) {
|
||||
float x = vertices[i];
|
||||
float y = vertices[i+1];
|
||||
float y = vertices[i + 1];
|
||||
minX = x < minX ? x : minX;
|
||||
maxX = x > maxX ? x : maxX;
|
||||
minY = y < minY ? y : minY;
|
||||
|
@ -30,6 +30,7 @@ public class PolygonModel implements Model {
|
||||
@Override
|
||||
public void setVertices(float[] vertices) {
|
||||
model.setVertices(vertices);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,10 +7,10 @@ import com.me.asteroids.Constants;
|
||||
import com.me.asteroids.EntityFactory;
|
||||
import com.me.asteroids.Utils;
|
||||
import com.me.asteroids.components.AsteroidComponent;
|
||||
import com.me.asteroids.components.model.Model;
|
||||
import com.me.asteroids.components.ModelComponent;
|
||||
import com.me.asteroids.components.PositionComponent;
|
||||
import com.me.asteroids.components.VelocityComponent;
|
||||
import com.me.asteroids.components.model.Model;
|
||||
import com.me.common.ecs.BaseSystem;
|
||||
import com.me.common.ecs.ComponentMapper;
|
||||
import com.me.common.ecs.Engine;
|
||||
|
@ -2,8 +2,8 @@ package com.me.asteroids.systems;
|
||||
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.me.asteroids.Graphics;
|
||||
import com.me.asteroids.components.model.Model;
|
||||
import com.me.asteroids.components.ModelComponent;
|
||||
import com.me.asteroids.components.model.Model;
|
||||
import com.me.common.ecs.ComponentMapper;
|
||||
import com.me.common.ecs.Engine;
|
||||
import com.me.common.ecs.Entity;
|
||||
|
@ -4,10 +4,10 @@ import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.me.asteroids.Utils;
|
||||
import com.me.asteroids.components.AccelerationComponent;
|
||||
import com.me.asteroids.components.model.Model;
|
||||
import com.me.asteroids.components.ModelComponent;
|
||||
import com.me.asteroids.components.PositionComponent;
|
||||
import com.me.asteroids.components.VelocityComponent;
|
||||
import com.me.asteroids.components.model.Model;
|
||||
import com.me.common.ecs.ComponentMapper;
|
||||
import com.me.common.ecs.Engine;
|
||||
import com.me.common.ecs.Entity;
|
||||
|
@ -52,7 +52,7 @@ public class ScreenWrapSystem extends EntitySystem {
|
||||
float maxX = minX + aabb.width;
|
||||
if (maxX < 0) {
|
||||
updatePosition(entity, position, Constants.WIDTH + (position.x - minX) + maxX, position.y);
|
||||
} else if (minX > Constants.WIDTH) {
|
||||
} else if (minX > Constants.WIDTH) {
|
||||
updatePosition(entity, position, (position.x - maxX) + (minX - Constants.WIDTH), position.y);
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,4 @@ final class EntityManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.me.common.ecs;
|
||||
|
||||
import com.me.common.ecs.event.Event;
|
||||
import com.me.common.ecs.event.RegisteredListener;
|
||||
import com.me.common.ecs.event.EventHandler;
|
||||
import com.me.common.ecs.event.Listener;
|
||||
import com.me.common.ecs.event.RegisteredListener;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
Reference in New Issue
Block a user