aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-08-09 11:34:57 +0300
committerkartofen <mladenovnasko0@gmail.com>2022-08-09 11:34:57 +0300
commit00c3363ca258f160b875ec254e701017be0314db (patch)
treeb26354d65c93a093b750d0c44adb1f2905f9e160
parentb91c09a43b3191d719781fe717fc6d28fec58029 (diff)
add readme and demo image
-rw-r--r--README.md14
-rwxr-xr-xbuild.sh13
-rw-r--r--demo/demo.pngbin0 -> 301 bytes
-rwxr-xr-xppmtopng.sh1
-rw-r--r--src/main.c2
5 files changed, 27 insertions, 3 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e20a0ff
--- /dev/null
+++ b/README.md
@@ -0,0 +1,14 @@
+### Wave function collapse
+
+This an implementation of very primitive tile-based wave function collapse.
+It uses tiles to generate an image, similar to this:
+![Demo of the program](demo/demo.png)
+
+It generates the tiles as ppm, then generates the image, similar to the demo image as ppm. There is a script to turn the ppm files into png using imagemagick.
+
+All files including the tiles are saved in the files directory
+
+### Build
+
+To build use `./build.sh`
+To build and run use `./build.sh run`
diff --git a/build.sh b/build.sh
index 84a12e8..6c4860e 100755
--- a/build.sh
+++ b/build.sh
@@ -9,6 +9,12 @@ ODIR="obj"
BIN="bin"
VALGRND=""
+RUN=0
+
+function run {
+ RUN=1
+}
+
function leak {
VALGRND="valgrind --leak-check=full"
}
@@ -37,5 +43,8 @@ gcc -o $BIN/wfc $ODIR/main.o $ODIR/ppm.o $ODIR/tiles.o $FLAGS
gcc -o $BIN/gen_tiles $ODIR/gen_tiles.o $ODIR/ppm.o $FLAGS
-$VALGRND $BIN/gen_tiles
-$VALGRND $BIN/wfc
+if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null
+then
+ $VALGRND $BIN/gen_tiles
+ $VALGRND $BIN/wfc
+fi
diff --git a/demo/demo.png b/demo/demo.png
new file mode 100644
index 0000000..82498c6
--- /dev/null
+++ b/demo/demo.png
Binary files differ
diff --git a/ppmtopng.sh b/ppmtopng.sh
index e415a5f..df33236 100755
--- a/ppmtopng.sh
+++ b/ppmtopng.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+cd ${0%/*} # go to project root
set -xe
for i in files/file*.ppm
diff --git a/src/main.c b/src/main.c
index d4c1a47..c169326 100644
--- a/src/main.c
+++ b/src/main.c
@@ -120,7 +120,7 @@ int main(void)
{
time_t seed = time(0);
srand(seed);
- printf("seed %ld\n", seed);
+ printf("The Seed is %ld\n", seed);
init_tiles_board();