Skip to content

Commit e2990d1

Browse files
Merge pull request #9 from radovanmoncek/development
Development
2 parents 3e27d62 + ad78f59 commit e2990d1

File tree

6 files changed

+67
-30
lines changed

6 files changed

+67
-30
lines changed

README.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,42 @@
1-
## TODO: title
1+
### example nettgame server game
22

3-
is an example game for my example nettgame server.
3+
is an example game to showcase my example nettgame server.
44

5-
### Synopsis
5+
#### In action
66

7-
TODO: title is a top-down shooter inspired by the game "Bulánci".
8-
The game is built using the popular libGDX game engine.
7+
![showcase](https://github.com/radovanmoncek/nettgame-client/blob/development/showcase.gif)
98

10-
### Controls
9+
#### Synopsis
1110

12-
- You can move with the W A S D keys
13-
- Shooting is controlled by pressing the SPACEBAR key.
11+
This example is supposed to resemble a top-down shooter inspired by the game "Bulánci".
12+
The game is built using the popular libGDX framework.
13+
14+
#### Controls
15+
16+
- You can move with the W A S D keys
1417

1518
#### How to build & run
1619

20+
- Make sure your device runs a recent version of JRE or JDK (optimally > 21)
21+
- Download the .jar artifact from releases
22+
- Run the .jar artifact
23+
24+
#### Dependencies
1725

26+
- libGDX
27+
- JUnit
28+
- FlatBuffers
29+
- <https://www.github.com/radovanmoncek/nettgame-tables>
1830

1931
*!!!! none of the assets used in this project are my own work,
2032
below is a list of their respective authors;
21-
all assets allow free noncommercial use; I highly encourage everyone to
33+
all assets allow free non-commercial use; I highly encourage everyone to
2234
visit the website of each author !!!!*
2335

24-
## Attributions:
25-
- character assets: TODO
36+
#### Attributions:
37+
- character assets: <https://rgsdev.itch.io/free-cc0-modular-animated-vector-characters-2d>
2638
- UI: <https://andelrodis.itch.io/1-bit-game-ui-pack>
39+
40+
#### Legal
41+
42+
The licence is **MIT**.

desktop/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ tasks.register('run', JavaExec) {
1717

1818
args += "--winmode"
1919
args += "true"
20+
args += "--server-address"
21+
args += "localhost"
2022

2123
if (OperatingSystem.current() == OperatingSystem.MAC_OS) {
2224
// Required to run on macOS

desktop/src/cz/radovanmoncek/nettgame/client/GameStateApplicationListener.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ public class GameStateApplicationListener implements ApplicationListener {
7272
/**
7373
* Source: <a href = https://gamefromscratch.com/libgdx-tutorial-10-basic-networking/>gfs</a>
7474
*/
75-
private GameStateApplicationListener() throws UnknownHostException {
75+
private GameStateApplicationListener(final String address) throws UnknownHostException {
7676

7777
gameServerPort = 4321;
78-
gameServerAddress = InetAddress.getByName("192.168.100.46")/*InetAddress.getLoopbackAddress()*/;
78+
gameServerAddress = InetAddress.getByName(address);
7979
gameStates = new ConcurrentLinkedQueue<>();
8080
disposables = new LinkedList<>();
8181
clientState = new AtomicReference<>();
@@ -333,8 +333,8 @@ public void resume() {
333333

334334
//https://stackoverflow.com/questions/6307648/change-global-setting-for-logger-instances
335335

336-
public static GameStateApplicationListener returnNewInstance() throws UnknownHostException {
336+
public static GameStateApplicationListener returnNewInstance(final String address) throws UnknownHostException {
337337

338-
return Objects.requireNonNullElse(instance, instance = new GameStateApplicationListener());
338+
return Objects.requireNonNullElse(instance, instance = new GameStateApplicationListener(address));
339339
}
340340
}

desktop/src/cz/radovanmoncek/nettgame/client/NettgameClientLauncher.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ public static void main(String[] args) throws UnknownHostException {
1414

1515
System.err.println("Window mode must be specified with the --winmode option");
1616

17-
Gdx
18-
.app
19-
.exit();
17+
System.exit(1);
2018

2119
return;
2220
}
@@ -25,13 +23,29 @@ public static void main(String[] args) throws UnknownHostException {
2523

2624
System.err.println("Invalid argument");
2725

28-
Gdx
29-
.app
30-
.exit();
26+
System.exit(1);
3127

3228
return;
3329
}
3430

31+
if (args.length > 2 && !args[2].equals("--server-address")) {
32+
33+
System.err.println("Server address must be specified using the --server-address option");
34+
35+
System.exit(1);
36+
37+
return;
38+
}
39+
40+
if (args.length < 4 || args[3] == null) {
41+
42+
System.err.println("Please specify a valid IP address or hostname");
43+
44+
System.exit(1);
45+
46+
return;
47+
}
48+
3549
final var config = new Lwjgl3ApplicationConfiguration();
3650

3751
config.setForegroundFPS(60);
@@ -41,6 +55,6 @@ public static void main(String[] args) throws UnknownHostException {
4155
if (!Boolean.parseBoolean(args[1]))
4256
config.setFullscreenMode(Lwjgl3ApplicationConfiguration.getDisplayMode());
4357

44-
new Lwjgl3Application(GameStateApplicationListener.returnNewInstance(), config);
58+
new Lwjgl3Application(GameStateApplicationListener.returnNewInstance(args[3]), config);
4559
}
4660
}

showcase.gif

14.4 MB
Loading

test/system/cz/radovanmoncek/nettgame/client/GameStateApplicationListenerTest.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
//todo: use position attributes in ALL tests !!!! !!!!
1414
/**
15-
* An integration test written, in part, to test containerized vs .jar performance of the Nettgame server.
15+
* A system test written, in part, to test containerized vs .jar performance of the Nettgame server.
1616
*
1717
* @author Radovan Monček
1818
* @since 1.0
@@ -28,13 +28,18 @@ static void setup() throws AWTException {
2828

2929
Executors
3030
.defaultThreadFactory()
31-
.newThread(() -> {
32-
try {
33-
NettgameClientLauncher.main(new String[]{"--winmode", "true"});
34-
}
35-
catch(UnknownHostException exception){
36-
Gdx.app.error("setup", "Unknown Host Exception", exception);
37-
}
31+
.newThread(() -> {
32+
33+
try {
34+
35+
NettgameClientLauncher.main(new String[]{"--winmode", "true", "--server-address", "localhost"});
36+
}
37+
catch(UnknownHostException exception){
38+
39+
Gdx
40+
.app
41+
.error("setup", "Unknown Host Exception", exception);
42+
}
3843
})
3944
.start();
4045

0 commit comments

Comments
 (0)