mirror of
https://github.com/fazo96/AIrium.git
synced 2025-03-29 21:18:39 +01:00
they evolve! for a while..
This commit is contained in:
parent
54e5dbb30f
commit
cc0ef33977
@ -12,6 +12,7 @@ package com.mygdx.game;
|
|||||||
public class Camera {
|
public class Camera {
|
||||||
|
|
||||||
private int x, y, speed;
|
private int x, y, speed;
|
||||||
|
private float scale = 1;
|
||||||
|
|
||||||
public Camera() {
|
public Camera() {
|
||||||
x = 0;
|
x = 0;
|
||||||
@ -24,6 +25,14 @@ public class Camera {
|
|||||||
y += deltaY;
|
y += deltaY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void zoomOut() {
|
||||||
|
scale -= 0.001f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void zoomIn() {
|
||||||
|
scale += 0.001f;
|
||||||
|
}
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
@ -48,4 +57,12 @@ public class Camera {
|
|||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getScale() {
|
||||||
|
return scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScale(float scale) {
|
||||||
|
this.scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,14 @@ public class Game extends ApplicationAdapter {
|
|||||||
|
|
||||||
private static Game game;
|
private static Game game;
|
||||||
ShapeRenderer shaper;
|
ShapeRenderer shaper;
|
||||||
private Camera camera;
|
|
||||||
private World world;
|
private World world;
|
||||||
|
private float cameraSpeed = 5;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
game = this;
|
game = this;
|
||||||
world = new World(1920, 1080);
|
world = new World(1920, 1080);
|
||||||
shaper = new ShapeRenderer();
|
shaper = new ShapeRenderer();
|
||||||
camera = new Camera();
|
|
||||||
//shaper.setAutoShapeType(true);
|
//shaper.setAutoShapeType(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,16 +30,22 @@ public class Game extends ApplicationAdapter {
|
|||||||
world.newGen(false);
|
world.newGen(false);
|
||||||
}
|
}
|
||||||
if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
|
if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
|
||||||
camera.translate(-camera.getSpeed(), 0);
|
shaper.translate(-cameraSpeed, 0,0);
|
||||||
}
|
}
|
||||||
if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
|
if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
|
||||||
camera.translate(1+camera.getSpeed(), 0);
|
shaper.translate(cameraSpeed, 0,0);
|
||||||
}
|
}
|
||||||
if (Gdx.input.isKeyPressed(Input.Keys.UP)) {
|
if (Gdx.input.isKeyPressed(Input.Keys.UP)) {
|
||||||
camera.translate(0, -camera.getSpeed());
|
shaper.translate(0, -cameraSpeed,0);
|
||||||
}
|
}
|
||||||
if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
|
if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
|
||||||
camera.translate(0, camera.getSpeed());
|
shaper.translate(0, cameraSpeed,0);
|
||||||
|
}
|
||||||
|
if (Gdx.input.isKeyJustPressed(Input.Keys.PLUS)) {
|
||||||
|
shaper.scale(0.3f, 0.3f, 1);
|
||||||
|
}
|
||||||
|
if (Gdx.input.isKeyJustPressed(Input.Keys.MINUS)) {
|
||||||
|
shaper.scale(1f, 1f, 1);
|
||||||
}
|
}
|
||||||
// Update
|
// Update
|
||||||
world.update();
|
world.update();
|
||||||
@ -53,7 +58,7 @@ public class Game extends ApplicationAdapter {
|
|||||||
e.render(shaper);
|
e.render(shaper);
|
||||||
}
|
}
|
||||||
shaper.setColor(0.3f, 0.3f, 0.3f, 1);
|
shaper.setColor(0.3f, 0.3f, 0.3f, 1);
|
||||||
shaper.rect(camera.getX(), camera.getY(), world.getWidth(), world.getHeight());
|
shaper.rect(0, 0, world.getWidth(), world.getHeight());
|
||||||
shaper.end();
|
shaper.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,10 +66,6 @@ public class Game extends ApplicationAdapter {
|
|||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Camera getCamera() {
|
|
||||||
return camera;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Game get() {
|
public static Game get() {
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ public class Creature extends Element {
|
|||||||
hp = 100;
|
hp = 100;
|
||||||
speed = 0;//(float) Math.random() * 3;
|
speed = 0;//(float) Math.random() * 3;
|
||||||
rotSpeed = 0;//(float) Math.random() - 0.5f;
|
rotSpeed = 0;//(float) Math.random() - 0.5f;
|
||||||
sightRange = 60;
|
sightRange = 100;
|
||||||
fov = (float) Math.PI / 1.5f;
|
fov = (float) Math.PI / 2.5f;
|
||||||
fitness = 0;
|
fitness = 0;
|
||||||
brain = new Brain(4, 3, 1, 6);
|
brain = new Brain(4, 3, 1, 6);
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ public class Creature extends Element {
|
|||||||
public void render(ShapeRenderer s) {
|
public void render(ShapeRenderer s) {
|
||||||
// Body
|
// Body
|
||||||
s.setColor(1 - (hp / 100), hp / 100, 0, 1);
|
s.setColor(1 - (hp / 100), hp / 100, 0, 1);
|
||||||
s.circle(getX() + Game.get().getCamera().getX(), getY() + Game.get().getCamera().getY(), getSize());
|
s.circle(getX() , getY(), getSize());
|
||||||
// Eye
|
// Eye
|
||||||
double relX = Math.cos(dir) * getSize(), relY = Math.sin(dir) * getSize();
|
double relX = Math.cos(dir) * getSize(), relY = Math.sin(dir) * getSize();
|
||||||
s.setColor(1, 1, 1, 1);
|
s.setColor(1, 1, 1, 1);
|
||||||
@ -126,12 +126,12 @@ public class Creature extends Element {
|
|||||||
s.setColor(0, c, 0, 1);
|
s.setColor(0, c, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.circle((float) relX + getX() + Game.get().getCamera().getX(), (float) relY + getY() + Game.get().getCamera().getY(), 3);
|
s.circle((float) relX + getX() , (float) relY + getY() , 3);
|
||||||
//FOV
|
//FOV
|
||||||
float degrees = fov * 180f / (float) Math.PI;
|
float degrees = fov * 180f / (float) Math.PI;
|
||||||
float orient = dir * 180f / (float) Math.PI - degrees / 2;
|
float orient = dir * 180f / (float) Math.PI - degrees / 2;
|
||||||
s.setColor(0.3f, 0.3f, 0.3f, 1);
|
s.setColor(0.3f, 0.3f, 0.3f, 1);
|
||||||
s.arc((float) relX + getX() + Game.get().getCamera().getX(), (float) relY + getY() + Game.get().getCamera().getY(), sightRange, orient, degrees);
|
s.arc((float) relX + getX() , (float) relY + getY() , sightRange, orient, degrees);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sight look() {
|
public Sight look() {
|
||||||
|
@ -31,6 +31,6 @@ public class Vegetable extends Element {
|
|||||||
@Override
|
@Override
|
||||||
public void render(ShapeRenderer s) {
|
public void render(ShapeRenderer s) {
|
||||||
s.setColor(1, 1, 1, 1);
|
s.setColor(1, 1, 1, 1);
|
||||||
s.circle(getX() + Game.get().getCamera().getX(), getY() + Game.get().getCamera().getY(), getSize());
|
s.circle(getX(), getY(), getSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user