Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aybabtme/bombjava
Java TCP client for bomberman,
https://github.com/aybabtme/bombjava
Last synced: about 1 month ago
JSON representation
Java TCP client for bomberman,
- Host: GitHub
- URL: https://github.com/aybabtme/bombjava
- Owner: aybabtme
- Created: 2014-03-18T06:19:58.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-03-30T18:09:24.000Z (over 10 years ago)
- Last Synced: 2023-03-30T06:25:58.668Z (over 1 year ago)
- Language: Java
- Size: 660 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bombjava
Java client [bomberman](https://github.com/aybabtme/bomberman) client.
# Quickstart
It’s dangerous to go alone! Take this [jar](https://github.com/aybabtme/bombjava/raw/master/dist/bombjava.jar).
Then
```java
// import the files
import im.antoine.bombjava.Client;
import im.antoine.bombjava.GameState;
import im.antoine.bombjava.PlayerState;
```Now use the client!
```java
// Prepare the client
Client c = new Client("127.0.0.1", 40000);// Open the client resources
c.open();// Read states till no more!
while (c.hasNext()) {
GameState state = c.nextState();
doMove(state, c);
}// Cleanup the client resources
c.close();
```You can then consume the `GameState` object any way you want - it's immutable - and
send commands to the game through the client.```java
private static void doMove(GameState state, Client c) throws IOException {PlayerState p = state.getPlayerState();
System.out.printf("I'm %s, at (%d, %d)\n", p.getName(), p.getX(), p.getY());
Random r = new Random(System.nanoTime());
switch (r.nextInt(4)) {
case 0:
c.goUp();
break;
case 1:
c.goDown();
break;
case 2:
c.goLeft();
break;
case 3:
c.goRight();
break;
}
}
```Prints
```
I'm p2, at (46, 15)
I'm p2, at (46, 15)
I'm p2, at (47, 15)
I'm p2, at (48, 15)
I'm p2, at (47, 15)
I'm p2, at (48, 15)
I'm p2, at (49, 15)
I'm p2, at (48, 15)
```# Docs
Javadocs aren't available at this time. However, the objects are pretty simple. Feel
free to submit docs in a PR if you feel like it.## `Client`
Each call to `Client` is a call to the network, so they will all block.
## `GameState`
All the values in `GameState` objects are actual values. They are also immutable.
No call to `GameState` will block.