Skip to content

Commit

Permalink
Minor improvements to WFCDemo usability.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tommyettinger committed Jan 14, 2025
1 parent eadb192 commit a9a05b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions WFCDemo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# WFC Demo using Tiled

## Controls

They're simple! Press `q` or `Esc` to exit. Press `r` to randomize the map.
Press `PrintScreen` to do nothing and let the OS handle taking a screenshot.
Press any other key to generate the next map in order.

This starts with a fixed seed so the first result will always be the same.
Unless you press `r`, other maps generated will follow a specific order,
the same every time. Pressing `r` will randomize and generate the next map.

## Examples

![Example generated map](https://i.imgur.com/7Q1gYyl.png)

![Example generated map](https://i.imgur.com/KGtiV9V.png)
8 changes: 8 additions & 0 deletions WFCDemo/core/src/main/java/com/squidpony/demo/WFCDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
import com.badlogic.gdx.utils.NumberUtils;
import jagd.MimicWFC;
import jagd.RNG;

Expand Down Expand Up @@ -60,6 +61,13 @@ public boolean keyUp(int keycode) {
case Input.Keys.ESCAPE:
Gdx.app.exit();
break;
case Input.Keys.PRINT_SCREEN:
System.out.println("Printing screen.");
break;
case Input.Keys.R:
System.out.println("Now using initial state " +
(rng.state = NumberUtils.doubleToLongBits(Math.random()) ^ NumberUtils.doubleToLongBits(Math.random()) >>> 32));
// FALLTHROUGH
default:
remake();
renderer.setMap(tiledMap);
Expand Down

0 comments on commit a9a05b3

Please sign in to comment.