Initial commit

This commit is contained in:
2026-04-05 17:17:46 -03:00
commit 2293dc29fb
33 changed files with 1644 additions and 0 deletions

16
shared/build.gradle Normal file
View File

@@ -0,0 +1,16 @@
plugins {
id 'java-library'
}
group = 'io.github.eldek0'
version = "$projectVersion"
repositories {
mavenCentral()
mavenLocal()
maven { url = 'https://jitpack.io' }
}
dependencies {
api "com.github.crykn:kryonet:$kryoNetVersion"
}

View File

@@ -0,0 +1,17 @@
package io.github.eldek0;
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
public static void main(String[] args) {
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
// to see how IntelliJ IDEA suggests fixing it.
System.out.printf("Hello and welcome!");
for (int i = 1; i <= 5; i++) {
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
System.out.println("i = " + i);
}
}
}

View File

@@ -0,0 +1,23 @@
package io.github.eldek0.network;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryonet.EndPoint;
import java.util.ArrayList;
public class Network {
public static final int TCP_PORT = 54555;
public static final int UDP_PORT = 54777;
public static void register(EndPoint endPoint) {
Kryo kryo = endPoint.getKryo();
kryo.register(NetworkPackets.Login.class);
kryo.register(NetworkPackets.PlayerConnected.class);
kryo.register(NetworkPackets.PlayerDisconnected.class);
kryo.register(NetworkPackets.PlayerMove.class);
kryo.register(NetworkPackets.WorldState.class);
kryo.register(NetworkPackets.PlayerState.class);
kryo.register(ArrayList.class);
}
}

View File

@@ -0,0 +1,36 @@
package io.github.eldek0.network;
public class NetworkPackets {
public static class Login {
public String name;
}
public static class PlayerConnected {
public int id;
public String name;
public float x;
public float y;
}
public static class PlayerDisconnected {
public int id;
}
public static class PlayerMove {
public int id;
public float x;
public float y;
}
public static class WorldState {
public java.util.ArrayList<PlayerState> players = new java.util.ArrayList<>();
}
public static class PlayerState {
public int id;
public String name;
public float x;
public float y;
}
}