added test character drawing
This commit is contained in:
BIN
core/assets/characters.png
Normal file
BIN
core/assets/characters.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
@@ -6,11 +6,21 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
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.graphics.g2d.TextureRegion;
|
||||
import netwerkprog.game.client.game.characters.Agent;
|
||||
import netwerkprog.game.client.game.characters.Hacker;
|
||||
import netwerkprog.game.client.game.characters.abilities.BodySwap;
|
||||
import netwerkprog.game.client.game.characters.abilities.Implant;
|
||||
import netwerkprog.game.client.game.characters.abilities.Scrambler;
|
||||
import netwerkprog.game.client.game.map.Map;
|
||||
import netwerkprog.game.client.game.map.MapRenderer;
|
||||
import netwerkprog.game.client.game.map.GameInputProcessor;
|
||||
import netwerkprog.game.util.game.Character;
|
||||
import netwerkprog.game.util.graphics.FrameRate;
|
||||
import netwerkprog.game.util.tree.BST;
|
||||
|
||||
public class MainGame extends ApplicationAdapter{
|
||||
SpriteBatch batch;
|
||||
@@ -24,6 +34,9 @@ public class MainGame extends ApplicationAdapter{
|
||||
private Map map;
|
||||
public MapRenderer mapRenderer;
|
||||
|
||||
private BST<Character> tree;
|
||||
public Character testCharacter;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@@ -58,6 +71,9 @@ public class MainGame extends ApplicationAdapter{
|
||||
camera.viewportWidth = screenWidth / 2;
|
||||
camera.viewportHeight = screenHeight / 2;
|
||||
camera.update();
|
||||
this.tree = new BST<>();
|
||||
initCharaters();
|
||||
// this.tree.insert(new Hacker(,new BodySwap()));
|
||||
|
||||
|
||||
// playSong();
|
||||
@@ -66,6 +82,14 @@ public class MainGame extends ApplicationAdapter{
|
||||
// connectToServer();
|
||||
}
|
||||
|
||||
private void initCharaters() {
|
||||
Texture texture = new Texture(Gdx.files.internal("core/assets/characters.png"));
|
||||
TextureRegion[][] characters = TextureRegion.split(texture,32,32);
|
||||
this.testCharacter = new Hacker(characters[1][0],new BodySwap("test"));
|
||||
this.tree.insert(testCharacter);
|
||||
this.tree.insert(new Agent(characters[2][0],new Implant("test")));
|
||||
}
|
||||
|
||||
|
||||
private void playSong() {
|
||||
// play music
|
||||
@@ -144,5 +168,8 @@ public class MainGame extends ApplicationAdapter{
|
||||
return map.getWidth();
|
||||
}
|
||||
|
||||
public BST<Character> getTree() {
|
||||
return tree;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
12
core/src/netwerkprog/game/client/game/characters/Agent.java
Normal file
12
core/src/netwerkprog/game/client/game/characters/Agent.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package netwerkprog.game.client.game.characters;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import netwerkprog.game.util.game.Ability;
|
||||
import netwerkprog.game.util.game.Character;
|
||||
import netwerkprog.game.util.game.Faction;
|
||||
|
||||
public class Agent extends Character {
|
||||
public Agent(TextureRegion textureRegion, Ability... abilities) {
|
||||
super("Agent", Faction.MEGACORPORATION, textureRegion, abilities);
|
||||
}
|
||||
}
|
||||
12
core/src/netwerkprog/game/client/game/characters/Hacker.java
Normal file
12
core/src/netwerkprog/game/client/game/characters/Hacker.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package netwerkprog.game.client.game.characters;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import netwerkprog.game.util.game.Ability;
|
||||
import netwerkprog.game.util.game.Character;
|
||||
import netwerkprog.game.util.game.Faction;
|
||||
|
||||
public class Hacker extends Character {
|
||||
public Hacker(TextureRegion textureRegion, Ability... abilities) {
|
||||
super("Hacker", Faction.HACKER, textureRegion, abilities);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,14 @@
|
||||
package netwerkprog.game.client.game.characters.abilities;
|
||||
|
||||
public class BodySwap {
|
||||
import netwerkprog.game.util.game.Ability;
|
||||
|
||||
public class BodySwap extends Ability {
|
||||
public BodySwap(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommand() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
package netwerkprog.game.client.game.characters.abilities;
|
||||
|
||||
public class Implant {
|
||||
import netwerkprog.game.util.game.Ability;
|
||||
|
||||
public class Implant extends Ability {
|
||||
public Implant(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommand() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,6 +128,7 @@ public class GameInputProcessor implements InputProcessor {
|
||||
GameTile gameTile = game.mapRenderer.getGameTiles()[row][col];
|
||||
if (gameTile.contains(touchPoint.x, touchPoint.y)) {
|
||||
System.out.println(gameTile + " row: " + row + ", col: " + col);
|
||||
gameTile.setCharacter(this.game.testCharacter);
|
||||
//TODO make stuff happen with the tile
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class GameTile extends Rectangle {
|
||||
}
|
||||
|
||||
public boolean containsCharacter() {
|
||||
return character == null;
|
||||
return character != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,7 +97,7 @@ public class MapRenderer implements Renderable {
|
||||
GameTile cur = gameTileRow[col];
|
||||
batch.draw(cur.getTextureRegion(), cur.x, cur.y);
|
||||
if (cur.containsCharacter()) {
|
||||
batch.draw(cur.getCharacter().getTextureRegion(), x, y);
|
||||
batch.draw(cur.getCharacter().getTextureRegion(), cur.x, cur.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
public abstract class Character {
|
||||
public abstract class Character implements Comparable<Character> {
|
||||
protected String name;
|
||||
protected Faction faction;
|
||||
protected HashSet<Ability> abilities;
|
||||
@@ -39,9 +39,18 @@ public abstract class Character {
|
||||
return textureRegion;
|
||||
}
|
||||
|
||||
public void setTextureRegion(TextureRegion textureRegion) {
|
||||
this.textureRegion = textureRegion;
|
||||
}
|
||||
|
||||
public void render(float x, float y) {
|
||||
batch.begin();
|
||||
batch.draw(this.textureRegion, x, y);
|
||||
batch.end();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Character o) {
|
||||
return this.name.compareTo(o.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
package netwerkprog.game.util.game;
|
||||
|
||||
public enum Faction {
|
||||
HACKER,
|
||||
MEGACORPORATION
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user