merge master
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package netwerkprog.game.client;
|
||||
|
||||
import netwerkprog.game.util.application.Controller;
|
||||
import netwerkprog.game.util.data.Data;
|
||||
import netwerkprog.game.util.data.DataParser;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -7,21 +11,25 @@ import java.net.Socket;
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Client extends Thread{
|
||||
public class Client extends Controller {
|
||||
private int port;
|
||||
private String hostname;
|
||||
private DataParser parser;
|
||||
private boolean isConnected = true;
|
||||
|
||||
|
||||
|
||||
public Client(String hostname) {
|
||||
this.port = Data.port();
|
||||
this.hostname = hostname;
|
||||
this.parser = new DataParser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.connect();
|
||||
}
|
||||
|
||||
public Client(String hostname, int port) {
|
||||
this.port = port;
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
public void connect() {
|
||||
System.out.println("[CLIENT] connecting to server on port " + port);
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
@@ -66,10 +74,12 @@ public class Client extends Thread{
|
||||
while (isConnected) {
|
||||
try {
|
||||
received = in.readUTF();
|
||||
System.out.println(received);
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("exception caught - " + e.getMessage());;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
151
core/src/netwerkprog/game/client/MainGame.java
Normal file
151
core/src/netwerkprog/game/client/MainGame.java
Normal file
@@ -0,0 +1,151 @@
|
||||
package netwerkprog.game.client;
|
||||
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
import com.badlogic.gdx.Files;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.InputProcessor;
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.graphics.Camera;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import netwerkprog.game.client.Client;
|
||||
import netwerkprog.game.client.game.map.Map;
|
||||
import netwerkprog.game.client.game.map.MapRenderer;
|
||||
import netwerkprog.game.client.map.GameInputProcessor;
|
||||
import netwerkprog.game.util.graphics.FrameRate;
|
||||
|
||||
public class MainGame extends ApplicationAdapter {
|
||||
SpriteBatch batch;
|
||||
float screenWidth;
|
||||
float screenHeight;
|
||||
private FrameRate frameRate;
|
||||
private Thread client;
|
||||
private OrthographicCamera camera;
|
||||
private GameInputProcessor gameInputProcessor;
|
||||
|
||||
private Map map;
|
||||
private MapRenderer mapRenderer;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
batch = new SpriteBatch();
|
||||
screenWidth = Gdx.graphics.getWidth();
|
||||
screenHeight = Gdx.graphics.getHeight();
|
||||
frameRate = new FrameRate();
|
||||
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
|
||||
|
||||
String[] strings = new String[]{
|
||||
"#########################",
|
||||
"#xxxx #",
|
||||
"# x #",
|
||||
"# xxxx #",
|
||||
"# xx #",
|
||||
"# x #",
|
||||
"# x #",
|
||||
"# x #",
|
||||
"# x #",
|
||||
"# xxxxxx #",
|
||||
"# x #",
|
||||
"# x xxxx x x #",
|
||||
"#########################"
|
||||
};
|
||||
map = new Map(strings);
|
||||
gameInputProcessor = new GameInputProcessor(camera, this);
|
||||
Gdx.input.setInputProcessor(gameInputProcessor);
|
||||
mapRenderer = new MapRenderer(map, 32, batch, camera);
|
||||
camera.position.set(screenWidth/2,screenHeight/2,0);
|
||||
camera.viewportWidth = screenWidth / 2;
|
||||
camera.viewportHeight = screenHeight / 2;
|
||||
camera.update();
|
||||
|
||||
|
||||
// playSong();
|
||||
|
||||
|
||||
// connectToServer();
|
||||
}
|
||||
|
||||
|
||||
private void playSong() {
|
||||
// play music
|
||||
Music music = Gdx.audio.newMusic(Gdx.files.getFileHandle("core/assets/music.mp3", Files.FileType.Internal));
|
||||
music.setVolume(.1f);
|
||||
music.play();
|
||||
music.setLooping(true);
|
||||
|
||||
connectToServer();
|
||||
}
|
||||
|
||||
|
||||
private void connectToServer() {
|
||||
client = new Thread(new Client("localhost"));
|
||||
try {
|
||||
client.start();
|
||||
} catch (Exception e) {
|
||||
System.out.println("There was an error connecting : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* render method that is called after the update method
|
||||
*/
|
||||
@Override
|
||||
public void render() {
|
||||
update();
|
||||
// clear screen
|
||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
mapRenderer.render();
|
||||
frameRate.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* update method that does all calculation before something is being drawn
|
||||
*/
|
||||
public void update() {
|
||||
frameRate.update();
|
||||
camera.update();
|
||||
this.gameInputProcessor.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
super.resize(width, height);
|
||||
screenHeight = height;
|
||||
screenWidth = width;
|
||||
frameRate.resize(width, height);
|
||||
mapRenderer.resize(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
super.resume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
batch.dispose();
|
||||
}
|
||||
|
||||
public float getScreenWidth() {
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
public float getScreenHeight() {
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
public int getVerticalTileAmount() {
|
||||
return map.getHeight();
|
||||
}
|
||||
|
||||
public int getHorizontalTileAmount() {
|
||||
return map.getWidth();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package netwerkprog.game.client.controllers;
|
||||
|
||||
import netwerkprog.game.util.Controller;
|
||||
|
||||
public class GraphicsController extends Controller {
|
||||
public GraphicsController() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package netwerkprog.game.client.controllers;
|
||||
|
||||
import netwerkprog.game.util.Controller;
|
||||
|
||||
public class LogicController extends Controller {
|
||||
|
||||
public LogicController() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package netwerkprog.game.client.controllers;
|
||||
|
||||
import netwerkprog.game.util.Controller;
|
||||
|
||||
public class SessionController extends Controller {
|
||||
public SessionController() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
15
core/src/netwerkprog/game/client/game/Game.java
Normal file
15
core/src/netwerkprog/game/client/game/Game.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package netwerkprog.game.client.game;
|
||||
|
||||
import netwerkprog.game.util.application.Controller;
|
||||
|
||||
public class Game extends Controller {
|
||||
|
||||
|
||||
public Game() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
14
core/src/netwerkprog/game/client/game/Graphics.java
Normal file
14
core/src/netwerkprog/game/client/game/Graphics.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package netwerkprog.game.client.game;
|
||||
|
||||
import netwerkprog.game.util.application.Controller;
|
||||
|
||||
public class Graphics extends Controller {
|
||||
public Graphics() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.client.game.characters;
|
||||
|
||||
public class DevTest1 {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.client.game.characters;
|
||||
|
||||
public class DevTest2 {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.client.game.characters.abilities;
|
||||
|
||||
public class BodySwap {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.client.game.characters.abilities;
|
||||
|
||||
public class Implant {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.client.game.characters.abilities;
|
||||
|
||||
public class MindControl {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.client.game.characters.abilities;
|
||||
|
||||
public class OverrideOrders {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.client.game.characters.abilities;
|
||||
|
||||
public class Scrambler {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.client.game.characters.abilities;
|
||||
|
||||
public class ServerHardening {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.client.game.characters.abilities;
|
||||
|
||||
public class Spyware {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.client.game.characters.abilities;
|
||||
|
||||
public class SystemicInfection {
|
||||
}
|
||||
15
core/src/netwerkprog/game/client/game/logic/Logic.java
Normal file
15
core/src/netwerkprog/game/client/game/logic/Logic.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package netwerkprog.game.client.game.logic;
|
||||
|
||||
import netwerkprog.game.util.application.Controller;
|
||||
|
||||
public class Logic extends Controller {
|
||||
|
||||
public Logic() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game.client.map;
|
||||
package netwerkprog.game.client.game.map;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package netwerkprog.game.client.map;
|
||||
package netwerkprog.game.client.game.map;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import netwerkprog.game.util.graphics.Renderable;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import netwerkprog.game.util.Renderable;
|
||||
|
||||
public class MapRenderer implements Renderable {
|
||||
private final OrthographicCamera camera;
|
||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.InputProcessor;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import netwerkprog.game.MainGame;
|
||||
import netwerkprog.game.client.MainGame;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
Reference in New Issue
Block a user