merge again #2
BIN
core/assets/music.mp3
Normal file
BIN
core/assets/music.mp3
Normal file
Binary file not shown.
@@ -1,7 +1,11 @@
|
|||||||
package netwerkprog.game;
|
package netwerkprog.game;
|
||||||
|
|
||||||
import com.badlogic.gdx.ApplicationAdapter;
|
import com.badlogic.gdx.ApplicationAdapter;
|
||||||
|
import com.badlogic.gdx.Files;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.audio.Music;
|
||||||
|
import com.badlogic.gdx.backends.lwjgl.audio.Mp3;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
@@ -21,11 +25,17 @@ public class MainGame extends ApplicationAdapter {
|
|||||||
float ratio = (float) Gdx.graphics.getWidth() / Gdx.graphics.getHeight();
|
float ratio = (float) Gdx.graphics.getWidth() / Gdx.graphics.getHeight();
|
||||||
xUpdate = ratio;
|
xUpdate = ratio;
|
||||||
yUpdate = ratio;
|
yUpdate = ratio;
|
||||||
|
|
||||||
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
Gdx.gl.glClearColor(1, 0, 0, 1);
|
Gdx.gl.glClearColor(xPos/Gdx.graphics.getWidth(), 0, 0, 1);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
updatePos();
|
updatePos();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.io.IOException;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
//TODO rewrite with GDX library https://www.gamefromscratch.com/post/2014/03/11/LibGDX-Tutorial-10-Basic-networking.aspx
|
||||||
public class Client {
|
public class Client {
|
||||||
private int port;
|
private int port;
|
||||||
private String hostname;
|
private String hostname;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package netwerkprog.game.server;
|
package netwerkprog.game.server;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Net;
|
||||||
|
import com.badlogic.gdx.net.ServerSocketHints;
|
||||||
|
import com.badlogic.gdx.net.SocketHints;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -8,6 +13,7 @@ import java.net.Socket;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
//TODO rewrite this with the GDX library https://www.gamefromscratch.com/post/2014/03/11/LibGDX-Tutorial-10-Basic-networking.aspx
|
||||||
public class Server {
|
public class Server {
|
||||||
private ServerSocket serverSocket;
|
private ServerSocket serverSocket;
|
||||||
private static final int PORT = 8000;
|
private static final int PORT = 8000;
|
||||||
@@ -17,6 +23,7 @@ public class Server {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
server.connect();
|
server.connect();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect() {
|
public void connect() {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
|
||||||
|
//TODO rewrite with GDX library https://www.gamefromscratch.com/post/2014/03/11/LibGDX-Tutorial-10-Basic-networking.aspx
|
||||||
public class ServerClient implements Runnable {
|
public class ServerClient implements Runnable {
|
||||||
private DataInputStream in;
|
private DataInputStream in;
|
||||||
private DataOutputStream out;
|
private DataOutputStream out;
|
||||||
|
|||||||
Reference in New Issue
Block a user