diff --git a/core/src/com/mygdx/game/Camera.java b/core/src/com/mygdx/game/Camera.java deleted file mode 100644 index a57cc9f..0000000 --- a/core/src/com/mygdx/game/Camera.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 com.mygdx.game; - -/** - * - * @author fazo - */ -public class Camera { - - private int x, y, speed; - private float scale = 1; - - public Camera() { - x = 0; - y = 0; - speed = 5; - } - - public void translate(int deltaX, int deltaY) { - x += deltaX; - y += deltaY; - } - - public void zoomOut() { - scale -= 0.001f; - } - - public void zoomIn() { - scale += 0.001f; - } - - public int getX() { - return x; - } - - public void setX(int x) { - this.x = x; - } - - public int getY() { - return y; - } - - public void setY(int y) { - this.y = y; - } - - public int getSpeed() { - return speed; - } - - public void setSpeed(int speed) { - this.speed = speed; - } - - public float getScale() { - return scale; - } - - public void setScale(float scale) { - this.scale = scale; - } - -} diff --git a/core/src/com/mygdx/game/Game.java b/core/src/com/mygdx/game/Game.java index 3dabd9f..8c9f642 100644 --- a/core/src/com/mygdx/game/Game.java +++ b/core/src/com/mygdx/game/Game.java @@ -30,22 +30,22 @@ public class Game extends ApplicationAdapter { world.newGen(false); } if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) { - shaper.translate(-cameraSpeed, 0,0); + shaper.translate(-cameraSpeed, 0, 0); } if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) { - shaper.translate(cameraSpeed, 0,0); + shaper.translate(cameraSpeed, 0, 0); } if (Gdx.input.isKeyPressed(Input.Keys.UP)) { - shaper.translate(0, -cameraSpeed,0); + shaper.translate(0, -cameraSpeed, 0); } if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) { - shaper.translate(0, cameraSpeed,0); + shaper.translate(0, cameraSpeed, 0); } if (Gdx.input.isKeyJustPressed(Input.Keys.PLUS)) { - shaper.scale(0.3f, 0.3f, 1); + shaper.scale(0.5f, 0.5f, 1); } if (Gdx.input.isKeyJustPressed(Input.Keys.MINUS)) { - shaper.scale(1f, 1f, 1); + shaper.scale(1.5f, 1.5f, 1); } // Update world.update(); @@ -55,7 +55,12 @@ public class Game extends ApplicationAdapter { shaper.setColor(1, 1, 1, 1); shaper.begin(ShapeRenderer.ShapeType.Line); for (Element e : world.getElements()) { - e.render(shaper); + try { + e.render(shaper); + } catch (ArrayIndexOutOfBoundsException ex) { + // No idea why it happens, but it's rendering so meh + //Log.log(Log.ERROR, ex+""); + } } shaper.setColor(0.3f, 0.3f, 0.3f, 1); shaper.rect(0, 0, world.getWidth(), world.getHeight()); diff --git a/core/src/logic/Creature.java b/core/src/logic/Creature.java index 16e7554..4be17d2 100644 --- a/core/src/logic/Creature.java +++ b/core/src/logic/Creature.java @@ -31,7 +31,7 @@ public class Creature extends Element { sightRange = 100; fov = (float) Math.PI / 2.5f; fitness = 0; - brain = new Brain(4, 3, 1, 6); + brain = new Brain(4, 3, 1, 8); } @Override diff --git a/core/src/logic/World.java b/core/src/logic/World.java index 87c0251..8f02706 100644 --- a/core/src/logic/World.java +++ b/core/src/logic/World.java @@ -18,8 +18,8 @@ import logic.neural.Brain; */ public class World { - public static final int creatPerGen = 10; private int width, height, generation = 0; + private final int nPlants, creatPerGen; public ArrayList elements; public ArrayList creatures; public ArrayList graveyard; @@ -31,6 +31,8 @@ public class World { this.height = height; elements = new ArrayList(); creatures = new ArrayList(); + creatPerGen = Math.min(Math.round(width * height / 20000), 50); + nPlants = Math.round(width * height / 5000); plants = new ArrayList(); deadPlants = new ArrayList(); graveyard = new ArrayList(); @@ -47,7 +49,7 @@ public class World { // All dead, next gen newGen(false); } - while (plants.size() < (width*height)/5000) { + while (plants.size() < nPlants) { spawnVegetable(); } for (Element e : elements) { diff --git a/desktop/src/com/mygdx/game/desktop/DesktopLauncher.java b/desktop/src/com/mygdx/game/desktop/DesktopLauncher.java index 3504c01..5a92449 100644 --- a/desktop/src/com/mygdx/game/desktop/DesktopLauncher.java +++ b/desktop/src/com/mygdx/game/desktop/DesktopLauncher.java @@ -7,6 +7,9 @@ import com.mygdx.game.Game; public class DesktopLauncher { public static void main (String[] arg) { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); + config.height = 600; + config.width = 800; + config.resizable = false; new LwjglApplication(new Game(), config); } }