Skip to content

Commit a9a05b3

Browse files
committed
Minor improvements to WFCDemo usability.
You can randomize the state by pressing r; pressing PrintScreen won't change the map state so you can take a picture of it. The README.md includes examples and controls.
1 parent eadb192 commit a9a05b3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

WFCDemo/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# WFC Demo using Tiled
2+
3+
## Controls
4+
5+
They're simple! Press `q` or `Esc` to exit. Press `r` to randomize the map.
6+
Press `PrintScreen` to do nothing and let the OS handle taking a screenshot.
7+
Press any other key to generate the next map in order.
8+
9+
This starts with a fixed seed so the first result will always be the same.
10+
Unless you press `r`, other maps generated will follow a specific order,
11+
the same every time. Pressing `r` will randomize and generate the next map.
12+
13+
## Examples
14+
15+
![Example generated map](https://i.imgur.com/7Q1gYyl.png)
16+
17+
![Example generated map](https://i.imgur.com/KGtiV9V.png)

WFCDemo/core/src/main/java/com/squidpony/demo/WFCDemo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
99
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
1010
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
11+
import com.badlogic.gdx.utils.NumberUtils;
1112
import jagd.MimicWFC;
1213
import jagd.RNG;
1314

@@ -60,6 +61,13 @@ public boolean keyUp(int keycode) {
6061
case Input.Keys.ESCAPE:
6162
Gdx.app.exit();
6263
break;
64+
case Input.Keys.PRINT_SCREEN:
65+
System.out.println("Printing screen.");
66+
break;
67+
case Input.Keys.R:
68+
System.out.println("Now using initial state " +
69+
(rng.state = NumberUtils.doubleToLongBits(Math.random()) ^ NumberUtils.doubleToLongBits(Math.random()) >>> 32));
70+
// FALLTHROUGH
6371
default:
6472
remake();
6573
renderer.setMap(tiledMap);

0 commit comments

Comments
 (0)