From d3444c84f1bb34647142249eb92f45ef8bf18fc7 Mon Sep 17 00:00:00 2001 From: doyle Date: Sun, 24 Sep 2023 18:05:28 +1000 Subject: [PATCH] tely/asset: Load up the merchant --- Data/Textures/smoochie_resized_25%.png | 4 +- Data/Textures/smoochie_resized_25%.txt | 2 +- ...ttack_1.png => smoochie_attack_side_1.png} | 0 ...ttack_2.png => smoochie_attack_side_2.png} | 0 Data/Textures/sprite_spec.txt | 4 +- Data/Textures/terry_merchant_resized_25%.png | 3 + Data/Textures/terry_merchant_resized_25%.txt | 3 + .../terry_merchant_01.png | 3 + .../terry_merchant_02.png | 3 + Data/Textures/terry_resized_25%.png | 3 + Data/Textures/terry_resized_25%.txt | 3 + .../terry_resized_25%/terry_attack_down_1.png | 3 + .../terry_resized_25%/terry_attack_down_2.png | 3 + .../terry_resized_25%/terry_attack_down_3.png | 3 + .../terry_resized_25%/terry_attack_side_1.png | 3 + .../terry_resized_25%/terry_attack_side_2.png | 3 + .../terry_resized_25%/terry_attack_side_3.png | 3 + .../terry_resized_25%/terry_attack_up_1.png | 3 + .../terry_resized_25%/terry_attack_up_2.png | 3 + .../terry_resized_25%/terry_attack_up_3.png | 3 + .../terry_walk_down_1.png | 0 .../terry_walk_down_2.png | 0 .../terry_walk_down_3.png | 0 .../terry_walk_down_4.png | 0 .../terry_walk_down_5.png | 0 .../terry_walk_down_6.png | 0 .../terry_walk_down_7.png | 0 .../terry_walk_idle_1.png | 0 .../terry_walk_idle_2.png | 0 .../terry_walk_idle_3.png | 0 .../terry_walk_idle_4.png | 0 .../terry_walk_idle_5.png | 0 .../terry_walk_idle_6.png | 0 .../terry_walk_idle_7.png | 0 .../terry_walk_idle_8.png | 0 .../terry_walk_left_1.png | 0 .../terry_walk_left_2.png | 0 .../terry_walk_left_3.png | 0 .../terry_walk_left_4.png | 0 .../terry_walk_left_5.png | 0 .../terry_walk_left_6.png | 0 .../terry_walk_left_7.png | 0 .../terry_walk_right_1.png | 0 .../terry_walk_right_2.png | 0 .../terry_walk_right_3.png | 0 .../terry_walk_right_4.png | 0 .../terry_walk_right_5.png | 0 .../terry_walk_right_6.png | 0 .../terry_walk_right_7.png | 0 .../terry_walk_up_1.png | 0 .../terry_walk_up_2.png | 0 .../terry_walk_up_3.png | 0 .../terry_walk_up_4.png | 0 .../terry_walk_up_5.png | 0 .../terry_walk_up_6.png | 0 Data/Textures/terry_walk_resized_25%.png | 3 - Data/Textures/terry_walk_resized_25%.txt | 3 - build_assets.bat | 5 +- feely_pona.cpp | 653 +++++------------- feely_pona_game.h | 33 +- feely_pona_misc.cpp | 431 ++++++++++++ feely_pona_unity.h | 1 + 62 files changed, 665 insertions(+), 519 deletions(-) rename Data/Textures/smoochie_resized_25%/{smoochie_side_attack_1.png => smoochie_attack_side_1.png} (100%) rename Data/Textures/smoochie_resized_25%/{smoochie_side_attack_2.png => smoochie_attack_side_2.png} (100%) create mode 100644 Data/Textures/terry_merchant_resized_25%.png create mode 100644 Data/Textures/terry_merchant_resized_25%.txt create mode 100644 Data/Textures/terry_merchant_resized_25%/terry_merchant_01.png create mode 100644 Data/Textures/terry_merchant_resized_25%/terry_merchant_02.png create mode 100644 Data/Textures/terry_resized_25%.png create mode 100644 Data/Textures/terry_resized_25%.txt create mode 100644 Data/Textures/terry_resized_25%/terry_attack_down_1.png create mode 100644 Data/Textures/terry_resized_25%/terry_attack_down_2.png create mode 100644 Data/Textures/terry_resized_25%/terry_attack_down_3.png create mode 100644 Data/Textures/terry_resized_25%/terry_attack_side_1.png create mode 100644 Data/Textures/terry_resized_25%/terry_attack_side_2.png create mode 100644 Data/Textures/terry_resized_25%/terry_attack_side_3.png create mode 100644 Data/Textures/terry_resized_25%/terry_attack_up_1.png create mode 100644 Data/Textures/terry_resized_25%/terry_attack_up_2.png create mode 100644 Data/Textures/terry_resized_25%/terry_attack_up_3.png rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_down_1.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_down_2.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_down_3.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_down_4.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_down_5.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_down_6.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_down_7.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_idle_1.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_idle_2.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_idle_3.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_idle_4.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_idle_5.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_idle_6.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_idle_7.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_idle_8.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_left_1.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_left_2.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_left_3.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_left_4.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_left_5.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_left_6.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_left_7.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_right_1.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_right_2.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_right_3.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_right_4.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_right_5.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_right_6.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_right_7.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_up_1.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_up_2.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_up_3.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_up_4.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_up_5.png (100%) rename Data/Textures/{terry_walk_resized_25% => terry_resized_25%}/terry_walk_up_6.png (100%) delete mode 100644 Data/Textures/terry_walk_resized_25%.png delete mode 100644 Data/Textures/terry_walk_resized_25%.txt create mode 100644 feely_pona_misc.cpp diff --git a/Data/Textures/smoochie_resized_25%.png b/Data/Textures/smoochie_resized_25%.png index 7fb6f77..5b9e967 100644 --- a/Data/Textures/smoochie_resized_25%.png +++ b/Data/Textures/smoochie_resized_25%.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58a577a5d120a92819aa057647ae2e4132b488597c7b4478e4220e00e4193c5b -size 1753245 +oid sha256:06112eecf7cd2ee33610864aaf8c365348960f304bc5bcdf796fd5f1ff7298f1 +size 1753854 diff --git a/Data/Textures/smoochie_resized_25%.txt b/Data/Textures/smoochie_resized_25%.txt index 6847ada..acb05d0 100644 --- a/Data/Textures/smoochie_resized_25%.txt +++ b/Data/Textures/smoochie_resized_25%.txt @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c962c735f3d12d6dc8c1c51a6c26f0d30170b0071bbaa147bd65df9071a784b7 +oid sha256:bda589dba1308d987ebe213f91b876a0ded6bc43305322902488fb4802598985 size 713 diff --git a/Data/Textures/smoochie_resized_25%/smoochie_side_attack_1.png b/Data/Textures/smoochie_resized_25%/smoochie_attack_side_1.png similarity index 100% rename from Data/Textures/smoochie_resized_25%/smoochie_side_attack_1.png rename to Data/Textures/smoochie_resized_25%/smoochie_attack_side_1.png diff --git a/Data/Textures/smoochie_resized_25%/smoochie_side_attack_2.png b/Data/Textures/smoochie_resized_25%/smoochie_attack_side_2.png similarity index 100% rename from Data/Textures/smoochie_resized_25%/smoochie_side_attack_2.png rename to Data/Textures/smoochie_resized_25%/smoochie_attack_side_2.png diff --git a/Data/Textures/sprite_spec.txt b/Data/Textures/sprite_spec.txt index 4a8b201..91b6506 100644 --- a/Data/Textures/sprite_spec.txt +++ b/Data/Textures/sprite_spec.txt @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:30a67bd9a2d5132753fc6ba26ba95da3b3dda9270c89c8f7628b16f76ba7e589 -size 269 +oid sha256:39887e579aa5d7d46f033445b0b4335b84b567c3b67583e15c346b9fe69d1bd1 +size 350 diff --git a/Data/Textures/terry_merchant_resized_25%.png b/Data/Textures/terry_merchant_resized_25%.png new file mode 100644 index 0000000..6b20093 --- /dev/null +++ b/Data/Textures/terry_merchant_resized_25%.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a2863de9dcb2e1efdcb81dc9fb8aedde29d7efb76fa29e399f81e38b7fdb471 +size 1160471 diff --git a/Data/Textures/terry_merchant_resized_25%.txt b/Data/Textures/terry_merchant_resized_25%.txt new file mode 100644 index 0000000..1492185 --- /dev/null +++ b/Data/Textures/terry_merchant_resized_25%.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d75581f98212215bdea5fd6c3350ee6736a2544c980a55fd0c1c48e92448bbcb +size 94 diff --git a/Data/Textures/terry_merchant_resized_25%/terry_merchant_01.png b/Data/Textures/terry_merchant_resized_25%/terry_merchant_01.png new file mode 100644 index 0000000..71e1bfc --- /dev/null +++ b/Data/Textures/terry_merchant_resized_25%/terry_merchant_01.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a4064a045b0ebaee434597e1e2c5ac31a37b6064991be21dc61b408145de39a +size 373737 diff --git a/Data/Textures/terry_merchant_resized_25%/terry_merchant_02.png b/Data/Textures/terry_merchant_resized_25%/terry_merchant_02.png new file mode 100644 index 0000000..09dfc98 --- /dev/null +++ b/Data/Textures/terry_merchant_resized_25%/terry_merchant_02.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:705bddca4e4402d122675d7b8dcb82741bd80d9848c5adb0096efec38731e693 +size 374327 diff --git a/Data/Textures/terry_resized_25%.png b/Data/Textures/terry_resized_25%.png new file mode 100644 index 0000000..d95d931 --- /dev/null +++ b/Data/Textures/terry_resized_25%.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ae62465989ca3a2852994b82999008547530bbaefe1ba6aa6c8acdb68b7951b +size 4640183 diff --git a/Data/Textures/terry_resized_25%.txt b/Data/Textures/terry_resized_25%.txt new file mode 100644 index 0000000..ddff388 --- /dev/null +++ b/Data/Textures/terry_resized_25%.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:190670607e18fd2dc7f7c986ebb26a3c8320cef5280b2cd8b80a4587e83c9683 +size 991 diff --git a/Data/Textures/terry_resized_25%/terry_attack_down_1.png b/Data/Textures/terry_resized_25%/terry_attack_down_1.png new file mode 100644 index 0000000..179eab6 --- /dev/null +++ b/Data/Textures/terry_resized_25%/terry_attack_down_1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:521164d2a849266ca3400ef363b73aabc4d336eff01af2584643591ab51c0bb7 +size 141922 diff --git a/Data/Textures/terry_resized_25%/terry_attack_down_2.png b/Data/Textures/terry_resized_25%/terry_attack_down_2.png new file mode 100644 index 0000000..b0d05d5 --- /dev/null +++ b/Data/Textures/terry_resized_25%/terry_attack_down_2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f01467d91590bad649a3d19e8f0b6d5f38c51abfecb95b653ec414ad3b36c388 +size 162465 diff --git a/Data/Textures/terry_resized_25%/terry_attack_down_3.png b/Data/Textures/terry_resized_25%/terry_attack_down_3.png new file mode 100644 index 0000000..92af5d6 --- /dev/null +++ b/Data/Textures/terry_resized_25%/terry_attack_down_3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fffd4d6ddfff905345d7d0add7744ad1429cc89daeda2a556171fea4856549e0 +size 133346 diff --git a/Data/Textures/terry_resized_25%/terry_attack_side_1.png b/Data/Textures/terry_resized_25%/terry_attack_side_1.png new file mode 100644 index 0000000..e15cff2 --- /dev/null +++ b/Data/Textures/terry_resized_25%/terry_attack_side_1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42d198cdc0ed0584924946481b796443dade0ef921398b8758a17caf586c310f +size 126378 diff --git a/Data/Textures/terry_resized_25%/terry_attack_side_2.png b/Data/Textures/terry_resized_25%/terry_attack_side_2.png new file mode 100644 index 0000000..61e28d0 --- /dev/null +++ b/Data/Textures/terry_resized_25%/terry_attack_side_2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e4e2dd04c0da21a763ca16ff03a6ec900e3866d295f9692fef68ff2024c9936 +size 125910 diff --git a/Data/Textures/terry_resized_25%/terry_attack_side_3.png b/Data/Textures/terry_resized_25%/terry_attack_side_3.png new file mode 100644 index 0000000..fd12834 --- /dev/null +++ b/Data/Textures/terry_resized_25%/terry_attack_side_3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d47bce7ff6212f76da32595ad7bc6801382d14e2d9a22058791376a6f639dab7 +size 111513 diff --git a/Data/Textures/terry_resized_25%/terry_attack_up_1.png b/Data/Textures/terry_resized_25%/terry_attack_up_1.png new file mode 100644 index 0000000..e7a6f82 --- /dev/null +++ b/Data/Textures/terry_resized_25%/terry_attack_up_1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:113aec63ea73c291bb392feae41f9dd558a228054185abf9ddaff74d2f325647 +size 71259 diff --git a/Data/Textures/terry_resized_25%/terry_attack_up_2.png b/Data/Textures/terry_resized_25%/terry_attack_up_2.png new file mode 100644 index 0000000..291c80e --- /dev/null +++ b/Data/Textures/terry_resized_25%/terry_attack_up_2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4af71a405ee67fdae32e6cd87a0e8d031ed6b91e98da9307a8dbe419a7703d97 +size 104085 diff --git a/Data/Textures/terry_resized_25%/terry_attack_up_3.png b/Data/Textures/terry_resized_25%/terry_attack_up_3.png new file mode 100644 index 0000000..5d74295 --- /dev/null +++ b/Data/Textures/terry_resized_25%/terry_attack_up_3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a5200bf885ff6380c154d52ed5c30635c8ae024981a316c5ca935d827d6a2594 +size 105544 diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_down_1.png b/Data/Textures/terry_resized_25%/terry_walk_down_1.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_down_1.png rename to Data/Textures/terry_resized_25%/terry_walk_down_1.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_down_2.png b/Data/Textures/terry_resized_25%/terry_walk_down_2.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_down_2.png rename to Data/Textures/terry_resized_25%/terry_walk_down_2.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_down_3.png b/Data/Textures/terry_resized_25%/terry_walk_down_3.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_down_3.png rename to Data/Textures/terry_resized_25%/terry_walk_down_3.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_down_4.png b/Data/Textures/terry_resized_25%/terry_walk_down_4.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_down_4.png rename to Data/Textures/terry_resized_25%/terry_walk_down_4.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_down_5.png b/Data/Textures/terry_resized_25%/terry_walk_down_5.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_down_5.png rename to Data/Textures/terry_resized_25%/terry_walk_down_5.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_down_6.png b/Data/Textures/terry_resized_25%/terry_walk_down_6.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_down_6.png rename to Data/Textures/terry_resized_25%/terry_walk_down_6.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_down_7.png b/Data/Textures/terry_resized_25%/terry_walk_down_7.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_down_7.png rename to Data/Textures/terry_resized_25%/terry_walk_down_7.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_idle_1.png b/Data/Textures/terry_resized_25%/terry_walk_idle_1.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_idle_1.png rename to Data/Textures/terry_resized_25%/terry_walk_idle_1.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_idle_2.png b/Data/Textures/terry_resized_25%/terry_walk_idle_2.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_idle_2.png rename to Data/Textures/terry_resized_25%/terry_walk_idle_2.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_idle_3.png b/Data/Textures/terry_resized_25%/terry_walk_idle_3.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_idle_3.png rename to Data/Textures/terry_resized_25%/terry_walk_idle_3.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_idle_4.png b/Data/Textures/terry_resized_25%/terry_walk_idle_4.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_idle_4.png rename to Data/Textures/terry_resized_25%/terry_walk_idle_4.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_idle_5.png b/Data/Textures/terry_resized_25%/terry_walk_idle_5.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_idle_5.png rename to Data/Textures/terry_resized_25%/terry_walk_idle_5.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_idle_6.png b/Data/Textures/terry_resized_25%/terry_walk_idle_6.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_idle_6.png rename to Data/Textures/terry_resized_25%/terry_walk_idle_6.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_idle_7.png b/Data/Textures/terry_resized_25%/terry_walk_idle_7.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_idle_7.png rename to Data/Textures/terry_resized_25%/terry_walk_idle_7.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_idle_8.png b/Data/Textures/terry_resized_25%/terry_walk_idle_8.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_idle_8.png rename to Data/Textures/terry_resized_25%/terry_walk_idle_8.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_left_1.png b/Data/Textures/terry_resized_25%/terry_walk_left_1.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_left_1.png rename to Data/Textures/terry_resized_25%/terry_walk_left_1.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_left_2.png b/Data/Textures/terry_resized_25%/terry_walk_left_2.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_left_2.png rename to Data/Textures/terry_resized_25%/terry_walk_left_2.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_left_3.png b/Data/Textures/terry_resized_25%/terry_walk_left_3.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_left_3.png rename to Data/Textures/terry_resized_25%/terry_walk_left_3.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_left_4.png b/Data/Textures/terry_resized_25%/terry_walk_left_4.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_left_4.png rename to Data/Textures/terry_resized_25%/terry_walk_left_4.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_left_5.png b/Data/Textures/terry_resized_25%/terry_walk_left_5.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_left_5.png rename to Data/Textures/terry_resized_25%/terry_walk_left_5.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_left_6.png b/Data/Textures/terry_resized_25%/terry_walk_left_6.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_left_6.png rename to Data/Textures/terry_resized_25%/terry_walk_left_6.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_left_7.png b/Data/Textures/terry_resized_25%/terry_walk_left_7.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_left_7.png rename to Data/Textures/terry_resized_25%/terry_walk_left_7.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_right_1.png b/Data/Textures/terry_resized_25%/terry_walk_right_1.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_right_1.png rename to Data/Textures/terry_resized_25%/terry_walk_right_1.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_right_2.png b/Data/Textures/terry_resized_25%/terry_walk_right_2.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_right_2.png rename to Data/Textures/terry_resized_25%/terry_walk_right_2.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_right_3.png b/Data/Textures/terry_resized_25%/terry_walk_right_3.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_right_3.png rename to Data/Textures/terry_resized_25%/terry_walk_right_3.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_right_4.png b/Data/Textures/terry_resized_25%/terry_walk_right_4.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_right_4.png rename to Data/Textures/terry_resized_25%/terry_walk_right_4.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_right_5.png b/Data/Textures/terry_resized_25%/terry_walk_right_5.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_right_5.png rename to Data/Textures/terry_resized_25%/terry_walk_right_5.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_right_6.png b/Data/Textures/terry_resized_25%/terry_walk_right_6.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_right_6.png rename to Data/Textures/terry_resized_25%/terry_walk_right_6.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_right_7.png b/Data/Textures/terry_resized_25%/terry_walk_right_7.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_right_7.png rename to Data/Textures/terry_resized_25%/terry_walk_right_7.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_up_1.png b/Data/Textures/terry_resized_25%/terry_walk_up_1.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_up_1.png rename to Data/Textures/terry_resized_25%/terry_walk_up_1.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_up_2.png b/Data/Textures/terry_resized_25%/terry_walk_up_2.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_up_2.png rename to Data/Textures/terry_resized_25%/terry_walk_up_2.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_up_3.png b/Data/Textures/terry_resized_25%/terry_walk_up_3.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_up_3.png rename to Data/Textures/terry_resized_25%/terry_walk_up_3.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_up_4.png b/Data/Textures/terry_resized_25%/terry_walk_up_4.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_up_4.png rename to Data/Textures/terry_resized_25%/terry_walk_up_4.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_up_5.png b/Data/Textures/terry_resized_25%/terry_walk_up_5.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_up_5.png rename to Data/Textures/terry_resized_25%/terry_walk_up_5.png diff --git a/Data/Textures/terry_walk_resized_25%/terry_walk_up_6.png b/Data/Textures/terry_resized_25%/terry_walk_up_6.png similarity index 100% rename from Data/Textures/terry_walk_resized_25%/terry_walk_up_6.png rename to Data/Textures/terry_resized_25%/terry_walk_up_6.png diff --git a/Data/Textures/terry_walk_resized_25%.png b/Data/Textures/terry_walk_resized_25%.png deleted file mode 100644 index 492cdb4..0000000 --- a/Data/Textures/terry_walk_resized_25%.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:91c9d36212297f42aed545a504d9c092cecda2b4cd8d24dfd7f3c26bdd91a88b -size 2983393 diff --git a/Data/Textures/terry_walk_resized_25%.txt b/Data/Textures/terry_walk_resized_25%.txt deleted file mode 100644 index 3eab69a..0000000 --- a/Data/Textures/terry_walk_resized_25%.txt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:18ad5298c48d3138a149596920d5d3c321bf62b69a3dc20d7e9cc15477c4fe07 -size 731 diff --git a/build_assets.bat b/build_assets.bat index c418f83..868390b 100644 --- a/build_assets.bat +++ b/build_assets.bat @@ -10,5 +10,6 @@ if not exist "%sprite_packer%" ( exit /B 1 ) -%sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\terry_walk_resized_25%% -%sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\smoochie_resized_25%% +%sprite_packer% 4096x4096 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\terry_resized_25%% || exit /b 1 +%sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\terry_merchant_resized_25%% || exit /b 1 +%sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\smoochie_resized_25%% || exit /b 1 diff --git a/feely_pona.cpp b/feely_pona.cpp index 23a76eb..4ebf06f 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -5,18 +5,23 @@ struct FP_GlobalAnimations { - Dqn_String8 terry_walk_idle = DQN_STRING8("terry_walk_idle"); - Dqn_String8 terry_walk_up = DQN_STRING8("terry_walk_up"); - Dqn_String8 terry_walk_down = DQN_STRING8("terry_walk_down"); - Dqn_String8 terry_walk_left = DQN_STRING8("terry_walk_left"); - Dqn_String8 terry_walk_right = DQN_STRING8("terry_walk_right"); - - Dqn_String8 smoochie_walk_up = DQN_STRING8("smoochie_walk_up"); - Dqn_String8 smoochie_walk_down = DQN_STRING8("smoochie_walk_down"); - Dqn_String8 smoochie_walk_left = DQN_STRING8("smoochie_walk_left"); - Dqn_String8 smoochie_walk_right = DQN_STRING8("smoochie_walk_right"); - Dqn_String8 smoochie_attack = DQN_STRING8("smoochie_attack"); - Dqn_String8 smoochie_death = DQN_STRING8("smoochie_death"); + Dqn_String8 terry_walk_idle = DQN_STRING8("terry_walk_idle"); + Dqn_String8 terry_walk_up = DQN_STRING8("terry_walk_up"); + Dqn_String8 terry_walk_down = DQN_STRING8("terry_walk_down"); + Dqn_String8 terry_walk_left = DQN_STRING8("terry_walk_left"); + Dqn_String8 terry_walk_right = DQN_STRING8("terry_walk_right"); + Dqn_String8 terry_attack_up = DQN_STRING8("terry_attack_up"); + Dqn_String8 terry_attack_side = DQN_STRING8("terry_attack_side"); + Dqn_String8 terry_attack_down = DQN_STRING8("terry_attack_down"); + Dqn_String8 terry_merchant = DQN_STRING8("terry_merchant"); + Dqn_String8 smoochie_walk_up = DQN_STRING8("smoochie_walk_up"); + Dqn_String8 smoochie_walk_down = DQN_STRING8("smoochie_walk_down"); + Dqn_String8 smoochie_walk_left = DQN_STRING8("smoochie_walk_left"); + Dqn_String8 smoochie_walk_right = DQN_STRING8("smoochie_walk_right"); + Dqn_String8 smoochie_attack_down = DQN_STRING8("smoochie_attack"); + Dqn_String8 smoochie_attack_side = DQN_STRING8("smoochie_attack_side"); + Dqn_String8 smoochie_attack_heart = DQN_STRING8("smoochie_attack_heart"); + Dqn_String8 smoochie_death = DQN_STRING8("smoochie_death"); } g_anim_names; @@ -117,352 +122,13 @@ void TELY_DLL_Init(void *user_data) TELY_Platform *platform = DQN_CAST(TELY_Platform *)user_data; TELY_DLL_Reload(user_data); - { - uint32_t array[] = {1}; - Dqn_BinarySearchResult result = {}; - - // NOTE: Match ============================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 1); - - // NOTE: Lower bound ======================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 1); - - // NOTE: Upper bound ======================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 1); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 1); - } - - { - uint32_t array[] = {1, 2}; - - // NOTE: Match ============================================================================= - Dqn_BinarySearchResult result = {}; - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 1); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 2); - - // NOTE: Lower bound ======================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 1); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 2); - - // NOTE: Upper bound ======================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 1); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 2); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 2); - } - - { - uint32_t array[] = {1, 2, 3}; - Dqn_BinarySearchResult result = {}; - - // NOTE: Match ============================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 1); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 2); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 3); - - // NOTE: Lower bound ======================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 1); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 2); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 3); - - // NOTE: Upper bound ======================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 1); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 2); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 3); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 3); - } - - { - uint32_t array[] = {1, 2, 3, 4}; - Dqn_BinarySearchResult result = {}; - - // NOTE: Match ============================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 1); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 2); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 3); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 5U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 4); - - // NOTE: Lower bound ======================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 1); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 2); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 3); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 5U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 4); - - // NOTE: Upper bound ======================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 1); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 2); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 3); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 4); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 5U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 4); - } - - { - uint32_t array[] = {1, 1, 2, 2, 3}; - Dqn_BinarySearchResult result = {}; - - // NOTE: Match ============================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 2); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 4); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_Match); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 5); - - // NOTE: Lower bound ======================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 2); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 4); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_LowerBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 5); - - // NOTE: Upper bound ======================================================================= - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 0); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 2); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(result.found); - DQN_ASSERT(result.index == 4); - - result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_UpperBound); - DQN_ASSERT(!result.found); - DQN_ASSERT(result.index == 5); - } - - { - Dqn_Arena_TempMemoryScope(&platform->arena); - TELY_ChunkPool pool = {}; - pool.arena = &platform->arena; - - void *bytes16 = TELY_ChunkPool_Alloc(&pool, 16); - TELY_ChunkPool_Dealloc(&pool, bytes16); - DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_16b] == DQN_CAST(void *)(DQN_CAST(char *)bytes16 - sizeof(TELY_ChunkPoolSlot))); - DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_16b]->next == nullptr); - - void *bytes17 = TELY_ChunkPool_Alloc(&pool, 17); - TELY_ChunkPool_Dealloc(&pool, bytes17); - DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_32b] == DQN_CAST(void *)(DQN_CAST(char *)bytes17 - sizeof(TELY_ChunkPoolSlot))); - DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_32b]->next == nullptr); - - void *bytes1 = TELY_ChunkPool_Alloc(&pool, 1); - void *bytes2 = TELY_ChunkPool_Alloc(&pool, 1); - TELY_ChunkPool_Dealloc(&pool, bytes1); - TELY_ChunkPool_Dealloc(&pool, bytes2); - DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_16b] == DQN_CAST(void *)(DQN_CAST(char *)bytes2 - sizeof(TELY_ChunkPoolSlot))); - DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_16b]->next == DQN_CAST(void *)(DQN_CAST(char *)bytes1 - sizeof(TELY_ChunkPoolSlot))); - - void *bytes128k = TELY_ChunkPool_Alloc(&pool, DQN_KILOBYTES(128)); - TELY_ChunkPool_Dealloc(&pool, bytes128k); - DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_128k] == DQN_CAST(void *)(DQN_CAST(char *)bytes128k - sizeof(TELY_ChunkPoolSlot))); - DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_128k]->next == nullptr); - } + FP_UnitTests(platform); // NOTE: TELY Game ============================================================================= - TELY_Assets *assets = &platform->assets; FP_Game *game = Dqn_Arena_New(&platform->arena, FP_Game, Dqn_ZeroMem_Yes); game->chunk_pool = &platform->chunk_pool; - platform->user_data = game; + platform->user_data = game; { TELY_AssetSpriteSheet *sheet = &game->hero_sprite_sheet; Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr); @@ -501,24 +167,34 @@ void TELY_DLL_Init(void *user_data) // NOTE: Load sprite sheets ==================================================================== { - game->terry_sprite_sheet = FP_LoadSpriteSheetFromSpec(platform, assets, &platform->arena, DQN_STRING8("terry_walk_resized_25%")); + game->terry_sprite_sheet = FP_LoadSpriteSheetFromSpec(platform, assets, &platform->arena, DQN_STRING8("terry_resized_25%")); game->terry_action_mappings = Dqn_Slice_CopyArray(&platform->arena, { - {FP_ActionType_Idle, &game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_walk_idle)}, - {FP_ActionType_WalkUp, &game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_walk_up)}, - {FP_ActionType_WalkDown, &game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_walk_down)}, - {FP_ActionType_WalkLeft, &game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_walk_left)}, - {FP_ActionType_WalkRight, &game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_walk_right)}, + {&game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_walk_idle)}, + {&game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_walk_up)}, + {&game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_walk_down)}, + {&game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_walk_left)}, + {&game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_walk_right)}, + {&game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_attack_up)}, + {&game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_attack_side)}, + {&game->terry_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_sprite_sheet, g_anim_names.terry_attack_down)}, + }); + + game->terry_merchant_sprite_sheet = FP_LoadSpriteSheetFromSpec(platform, assets, &platform->arena, DQN_STRING8("terry_merchant_resized_25%")); + game->terry_merchant_action_mappings = Dqn_Slice_CopyArray(&platform->arena, { + {&game->terry_merchant_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->terry_merchant_sprite_sheet, g_anim_names.terry_merchant)}, }); game->smoochie_sprite_sheet = FP_LoadSpriteSheetFromSpec(platform, assets, &platform->arena, DQN_STRING8("smoochie_resized_25%")); game->smoochie_action_mappings = Dqn_Slice_CopyArray(&platform->arena, { - {FP_ActionType_Idle, &game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_walk_down)}, - {FP_ActionType_WalkUp, &game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_walk_up)}, - {FP_ActionType_WalkDown, &game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_walk_down)}, - {FP_ActionType_WalkLeft, &game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_walk_left)}, - {FP_ActionType_WalkRight, &game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_walk_right)}, - {FP_ActionType_Attack, &game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_attack)}, - {FP_ActionType_Death, &game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_death)}, + {&game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_walk_down)}, + {&game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_walk_up)}, + {&game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_walk_down)}, + {&game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_walk_left)}, + {&game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_walk_right)}, + {&game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_attack_down)}, + {&game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_attack_side)}, + {&game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_attack_heart)}, + {&game->smoochie_sprite_sheet, TELY_Asset_GetSpriteAnimation(&game->smoochie_sprite_sheet, g_anim_names.smoochie_death)}, }); } @@ -526,80 +202,6 @@ void TELY_DLL_Init(void *user_data) game->root_entity = Dqn_VArray_Make(&game->entities, Dqn_ZeroMem_No); Dqn_FArray_Add(&game->parent_entity_stack, game->root_entity->handle); - // NOTE: Unit test DFS pre-order and post-order walk - { - // NOTE: Setup entity-tree ================================================================= - - FP_GameEntity *f = FP_Game_MakeEntityPointerF(game, "F"); - FP_Game_PushParentEntity(game, f->handle); - FP_GameEntity *b = FP_Game_MakeEntityPointerF(game, "B"); - FP_GameEntity *g = FP_Game_MakeEntityPointerF(game, "G"); - FP_Game_PushParentEntity(game, b->handle); - FP_GameEntity *a = FP_Game_MakeEntityPointerF(game, "A"); - FP_GameEntity *d = FP_Game_MakeEntityPointerF(game, "D"); - FP_Game_PushParentEntity(game, d->handle); - FP_GameEntity *c = FP_Game_MakeEntityPointerF(game, "C"); - FP_GameEntity *e = FP_Game_MakeEntityPointerF(game, "E"); - FP_Game_PopParentEntity(game); - FP_Game_PopParentEntity(game); - - FP_Game_PushParentEntity(game, g->handle); - FP_GameEntity *i = FP_Game_MakeEntityPointerF(game, "I"); - FP_Game_PushParentEntity(game, i->handle); - FP_GameEntity *h = FP_Game_MakeEntityPointerF(game, "H"); - FP_Game_PopParentEntity(game); - FP_Game_PopParentEntity(game); - FP_Game_PopParentEntity(game); - - // NOTE: Pre order test ==================================================================== - - FP_GameEntity *pre_order_walk[9] = {}; - Dqn_usize pre_order_walk_count = 0; - for (FP_GameEntityIterator it = {}; FP_Game_DFSPreOrderWalkEntityTree(game, &it, game->root_entity);) { - DQN_ASSERT(pre_order_walk_count < DQN_ARRAY_UCOUNT(pre_order_walk)); - pre_order_walk[pre_order_walk_count++] = it.entity; - } - - DQN_ASSERT(pre_order_walk_count == DQN_ARRAY_UCOUNT(pre_order_walk)); - DQN_ASSERT(pre_order_walk[0] == f); - DQN_ASSERT(pre_order_walk[1] == b); - DQN_ASSERT(pre_order_walk[2] == a); - DQN_ASSERT(pre_order_walk[3] == d); - DQN_ASSERT(pre_order_walk[4] == c); - DQN_ASSERT(pre_order_walk[5] == e); - DQN_ASSERT(pre_order_walk[6] == g); - DQN_ASSERT(pre_order_walk[7] == i); - DQN_ASSERT(pre_order_walk[8] == h); - - // NOTE: Post order test =================================================================== - - FP_GameEntity *post_order_walk[9] = {}; - Dqn_usize post_order_walk_count = 0; - for (FP_GameEntityIterator it = {}; FP_Game_DFSPostOrderWalkEntityTree(game, &it, game->root_entity);) { - DQN_ASSERT(post_order_walk_count < DQN_ARRAY_UCOUNT(post_order_walk)); - post_order_walk[post_order_walk_count++] = it.entity; - } - - DQN_ASSERT(post_order_walk_count == DQN_ARRAY_UCOUNT(post_order_walk)); - DQN_ASSERT(post_order_walk[0] == a); - DQN_ASSERT(post_order_walk[1] == c); - DQN_ASSERT(post_order_walk[2] == e); - DQN_ASSERT(post_order_walk[3] == d); - DQN_ASSERT(post_order_walk[4] == b); - DQN_ASSERT(post_order_walk[5] == h); - DQN_ASSERT(post_order_walk[6] == i); - DQN_ASSERT(post_order_walk[7] == g); - DQN_ASSERT(post_order_walk[8] == f); - - // NOTE: Cleanup =========================================================================== - FP_Game_DeleteEntity(game, game->root_entity->handle); - DQN_ASSERT(game->root_entity->first_child == nullptr); - DQN_ASSERT(game->root_entity->last_child == nullptr); - DQN_ASSERT(game->root_entity->next == nullptr); - DQN_ASSERT(game->root_entity->prev == nullptr); - DQN_ASSERT(game->root_entity->parent == nullptr); - } - // NOTE: Hero { TELY_AssetSpriteSheet *sheet = &game->terry_sprite_sheet; @@ -607,7 +209,7 @@ void TELY_DLL_Init(void *user_data) entity->local_pos = Dqn_V2_InitNx2(1334, 396); entity->action_to_anim_mapping = game->terry_action_mappings; entity->size_scale = Dqn_V2_InitNx1(0.25f); - entity->local_hit_box_size = Dqn_V2_InitV2I(sheet->sprite_size); + entity->local_hit_box_size = Dqn_V2_InitNx2(428, 471) * entity->size_scale; entity->flags |= FP_GameEntityFlag_Clickable; entity->flags |= FP_GameEntityFlag_MoveByKeyboard; entity->flags |= FP_GameEntityFlag_MoveByMouse; @@ -618,6 +220,21 @@ void TELY_DLL_Init(void *user_data) game->player = entity->handle; } + // NOTE: Merchant + { + FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, "Merchant"); + entity->type = FP_GameEntityType_Merchant; + entity->local_pos = Dqn_V2_InitNx2(1000, 124); + entity->local_hit_box_size = Dqn_V2_InitNx2(50, 50); + entity->size_scale = Dqn_V2_InitNx1(0.25f); + entity->action_to_anim_mapping = game->terry_merchant_action_mappings; + entity->flags |= FP_GameEntityFlag_Clickable; + entity->flags |= FP_GameEntityFlag_MoveByKeyboard; + entity->flags |= FP_GameEntityFlag_MoveByMouse; + entity->flags |= FP_GameEntityFlag_MoveByGamepad; + entity->flags |= FP_GameEntityFlag_NonTraversable; + } + game->tile_size = 37; Dqn_V2I max_tile = platform->core.window_size / game->tile_size; @@ -684,19 +301,6 @@ void TELY_DLL_Init(void *user_data) game->test_audio = platform->func_load_audio(assets, DQN_STRING8("Test Audio"), DQN_STRING8("Data/Audio/Purrple Cat - Moonwinds.qoa")); } -FP_ActionToAnimationMapping FP_Game_GetActionAnimMappingForType(FP_Game *game, FP_GameEntityHandle entity_handle, FP_ActionType type) -{ - FP_GameEntity *entity = FP_Game_GetEntity(game, entity_handle); - FP_ActionToAnimationMapping result = {}; - for (FP_ActionToAnimationMapping const &mapping : entity->action_to_anim_mapping) { - if (mapping.action_type == type) { - result = mapping; - break; - } - } - return result; -} - FP_ActionToAnimationMapping FP_Game_GetActionAnimMappingWithName(FP_Game *game, FP_GameEntityHandle entity_handle, Dqn_String8 name) { FP_GameEntity *entity = FP_Game_GetEntity(game, entity_handle); @@ -710,7 +314,6 @@ FP_ActionToAnimationMapping FP_Game_GetActionAnimMappingWithName(FP_Game *game, return result; } - FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_PlatformInput *input, FP_GameEntity *entity, Dqn_V2 dir_vector) { FP_GameEntityAction *action = &entity->action; @@ -733,22 +336,43 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat } else if (we_are_clicked_entity) { if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) || TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) { - FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackA); + switch (entity->direction) { + case FP_GameDirection_Up: { + FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackUp); + } break; + + case FP_GameDirection_Left: { + FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackSide); + } break; + + case FP_GameDirection_Right: { + FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackSide); + } break; + + case FP_GameDirection_Down: { + FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackDown); + } break; + } } else if (dir_vector.x || dir_vector.y) { FP_Game_EntityActionSetState(action, FP_GameTerryState_Run); } } } - if (*state == FP_GameTerryState_AttackA) { - result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_walk_right); + if (*state == FP_GameTerryState_AttackSide) { + result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_attack_side); + action->flip_on_x = entity->direction == FP_GameDirection_Right; if (action->flags & FP_GameEntityActionFlag_StateTransition) { FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result); } else if (action_has_finished) { FP_Game_EntityActionSetState(action, FP_GameTerryState_Idle); - } else if (!FP_Game_EntityActionHasFailed(action) && we_are_clicked_entity) { - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) || + action->flip_on_x = false; + } + + #if 0 + else if (!FP_Game_EntityActionHasFailed(action) && we_are_clicked_entity) { + if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) || TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) { Dqn_f32 t01 = action->timer_s / action->end_at_s; if (t01 > 0.5f) @@ -757,30 +381,20 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat action->flags |= FP_GameEntityActionFlag_Failed; } } + #endif } - if (*state == FP_GameTerryState_AttackB) { - result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_walk_right); - + if (*state == FP_GameTerryState_AttackUp) { + result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_attack_up); if (action->flags & FP_GameEntityActionFlag_StateTransition) { FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result); } else if (action_has_finished) { FP_Game_EntityActionSetState(action, FP_GameTerryState_Idle); - } else if (!FP_Game_EntityActionHasFailed(action) && we_are_clicked_entity) { - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) || - TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) { - Dqn_f32 t01 = action->timer_s / action->end_at_s; - if (t01 > 0.5f) - FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackC); - else - action->flags |= FP_GameEntityActionFlag_Failed; - } } } - if (*state == FP_GameTerryState_AttackC) { - result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_walk_right); - + if (*state == FP_GameTerryState_AttackDown) { + result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_attack_down); if (action->flags & FP_GameEntityActionFlag_StateTransition) { FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result); } else if (action_has_finished) { @@ -801,7 +415,23 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat if (we_are_clicked_entity) { if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) || TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) { - FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackA); + switch (entity->direction) { + case FP_GameDirection_Up: { + FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackUp); + } break; + + case FP_GameDirection_Left: { + FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackSide); + } break; + + case FP_GameDirection_Right: { + FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackSide); + } break; + + case FP_GameDirection_Down: { + FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackDown); + } break; + } } else if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_LeftShift) || TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_A)) { FP_Game_EntityActionSetState(action, FP_GameTerryState_Dash); @@ -809,7 +439,7 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat } // NOTE: Also handles state transition - if (action->mapping.action_type != result.action_type) { + if (action->mapping.anim.label != result.anim.label) { FP_Game_EntityActionReset(action, FP_GAME_ENTITY_ACTION_INFINITE_TIMER, result); } @@ -846,9 +476,9 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat } } - if (*state == FP_GameTerryState_AttackA || - *state == FP_GameTerryState_AttackB || - *state == FP_GameTerryState_AttackC) { + if (*state == FP_GameTerryState_AttackUp || + *state == FP_GameTerryState_AttackDown || + *state == FP_GameTerryState_AttackSide) { entity->attack_box_size = entity->local_hit_box_size; // NOTE: Position the attack box @@ -877,16 +507,26 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat } else if (we_are_clicked_entity) { if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) || TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) { - FP_Game_EntityActionSetState(action, FP_GameSmoochieState_Attack); + + switch (entity->direction) { + case FP_GameDirection_Up: /*FALLTHRU*/ + case FP_GameDirection_Right: /*FALLTHRU*/ + case FP_GameDirection_Left: { + FP_Game_EntityActionSetState(action, FP_GameSmoochieState_AttackSide); + } break; + + case FP_GameDirection_Down: { + FP_Game_EntityActionSetState(action, FP_GameSmoochieState_AttackDown); + } break; + } } else if (dir_vector.x || dir_vector.y) { FP_Game_EntityActionSetState(action, FP_GameSmoochieState_Run); } } } - if (*state == FP_GameSmoochieState_Attack) { - result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.smoochie_attack); - + if (*state == FP_GameSmoochieState_AttackDown) { + result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.smoochie_attack_down); if (action->flags & FP_GameEntityActionFlag_StateTransition) { FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result); } else if (action_has_finished) { @@ -894,6 +534,17 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat } } + if (*state == FP_GameSmoochieState_AttackSide) { + result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.smoochie_attack_side); + action->flip_on_x = entity->direction == FP_GameDirection_Right; + if (action->flags & FP_GameEntityActionFlag_StateTransition) { + FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result); + } else if (action_has_finished) { + FP_Game_EntityActionSetState(action, FP_GameSmoochieState_Idle); + action->flip_on_x = false; + } + } + if (*state == FP_GameSmoochieState_Run) { Dqn_String8 desired_action_name = {}; switch (entity->direction) { @@ -907,12 +558,23 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat if (we_are_clicked_entity) { if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) || TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) { - FP_Game_EntityActionSetState(action, FP_GameSmoochieState_Attack); + + switch (entity->direction) { + case FP_GameDirection_Up: /*FALLTHRU*/ + case FP_GameDirection_Right: /*FALLTHRU*/ + case FP_GameDirection_Left: { + FP_Game_EntityActionSetState(action, FP_GameSmoochieState_AttackSide); + } break; + + case FP_GameDirection_Down: { + FP_Game_EntityActionSetState(action, FP_GameSmoochieState_AttackDown); + } break; + } } } // NOTE: Also handles state transition - if (action->mapping.action_type != result.action_type) { + if (action->mapping.anim.label != result.anim.label) { FP_Game_EntityActionReset(action, FP_GAME_ENTITY_ACTION_INFINITE_TIMER, result); } @@ -921,7 +583,7 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat } } - if (*state == FP_GameSmoochieState_Attack) { + if (*state == FP_GameSmoochieState_AttackSide || *state == FP_GameSmoochieState_AttackDown) { entity->attack_box_size = entity->local_hit_box_size; // NOTE: Position the attack box if (entity->direction == FP_GameDirection_Left) { @@ -936,6 +598,19 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat } } break; + + case FP_GameEntityType_Merchant: { + FP_GameTerryMerchantState *state = DQN_CAST(FP_GameTerryMerchantState *)&action->state; + if (*state == FP_GameTerryMerchantState_Nil) + FP_Game_EntityActionSetState(action, FP_GameTerryMerchantState_Idle); + + if (*state == FP_GameTerryMerchantState_Idle) { + result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_merchant); + if (action->flags & FP_GameEntityActionFlag_StateTransition) { + FP_Game_EntityActionReset(action, FP_GAME_ENTITY_ACTION_INFINITE_TIMER, result); + } + } + } break; } // NOTE: Tick entity action ================================================================ @@ -1330,10 +1005,8 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer) dest_rect.size = src_rect.size * entity->size_scale; dest_rect.pos = world_pos - (dest_rect.size * .5f); - #if 0 - if (entity->direction == FP_GameDirection_Left) + if (action->flip_on_x) dest_rect.size.w *= -1.f; // NOTE: Flip the texture horizontally - #endif TELY_Render_TextureColourV4(renderer, sprite_sheet->tex_handle, src_rect, dest_rect, TELY_COLOUR_WHITE_V4); } diff --git a/feely_pona_game.h b/feely_pona_game.h index 4049980..99d5510 100644 --- a/feely_pona_game.h +++ b/feely_pona_game.h @@ -58,20 +58,8 @@ enum FP_GameEntityActionFlag FP_GameEntityActionFlag_Failed = 1 << 1, }; -enum FP_ActionType -{ - FP_ActionType_Idle, - FP_ActionType_Attack, - FP_ActionType_WalkUp, - FP_ActionType_WalkDown, - FP_ActionType_WalkLeft, - FP_ActionType_WalkRight, - FP_ActionType_Death, -}; - struct FP_ActionToAnimationMapping { - FP_ActionType action_type; TELY_AssetSpriteSheet *sheet; TELY_AssetSpriteAnimation anim; }; @@ -79,6 +67,7 @@ struct FP_ActionToAnimationMapping Dqn_f32 const FP_GAME_ENTITY_ACTION_INFINITE_TIMER = -1.f; struct FP_GameEntityAction { + bool flip_on_x; uint32_t state; uint32_t flags; // Bit flags corresponding with `FP_GameEntityActionFlag` FP_ActionToAnimationMapping mapping; @@ -98,15 +87,16 @@ enum FP_GameEntityType { FP_GameEntityType_Terry, FP_GameEntityType_Smoochie, + FP_GameEntityType_Merchant, }; enum FP_GameTerryState { FP_GameTerryState_Nil, FP_GameTerryState_Idle, - FP_GameTerryState_AttackA, - FP_GameTerryState_AttackB, - FP_GameTerryState_AttackC, + FP_GameTerryState_AttackUp, + FP_GameTerryState_AttackDown, + FP_GameTerryState_AttackSide, FP_GameTerryState_Run, FP_GameTerryState_Dash, }; @@ -115,10 +105,18 @@ enum FP_GameSmoochieState { FP_GameSmoochieState_Nil, FP_GameSmoochieState_Idle, - FP_GameSmoochieState_Attack, + FP_GameSmoochieState_AttackDown, + FP_GameSmoochieState_AttackSide, + FP_GameSmoochieState_AttackHeart, FP_GameSmoochieState_Run, }; +enum FP_GameTerryMerchantState +{ + FP_GameTerryMerchantState_Nil, + FP_GameTerryMerchantState_Idle, +}; + struct FP_GameEntity { FP_GameEntity *next; @@ -199,6 +197,9 @@ struct FP_Game TELY_AssetSpriteSheet smoochie_sprite_sheet; Dqn_Slice smoochie_action_mappings; + TELY_AssetSpriteSheet terry_merchant_sprite_sheet; + Dqn_Slice terry_merchant_action_mappings; + FP_GameEntity *root_entity; FP_GameEntity *entity_free_list; diff --git a/feely_pona_misc.cpp b/feely_pona_misc.cpp new file mode 100644 index 0000000..123c37f --- /dev/null +++ b/feely_pona_misc.cpp @@ -0,0 +1,431 @@ +#if defined(__clang__) +#pragma once +#include "feely_pona_unity.h" +#endif + +void FP_UnitTests(TELY_Platform *platform) +{ + { + uint32_t array[] = {1}; + Dqn_BinarySearchResult result = {}; + + // NOTE: Match ============================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 1); + + // NOTE: Lower bound ======================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 1); + + // NOTE: Upper bound ======================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 1); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 1); + } + + { + uint32_t array[] = {1, 2}; + + // NOTE: Match ============================================================================= + Dqn_BinarySearchResult result = {}; + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 1); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 2); + + // NOTE: Lower bound ======================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 1); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 2); + + // NOTE: Upper bound ======================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 1); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 2); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 2); + } + + { + uint32_t array[] = {1, 2, 3}; + Dqn_BinarySearchResult result = {}; + + // NOTE: Match ============================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 1); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 2); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 3); + + // NOTE: Lower bound ======================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 1); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 2); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 3); + + // NOTE: Upper bound ======================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 1); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 2); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 3); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 3); + } + + { + uint32_t array[] = {1, 2, 3, 4}; + Dqn_BinarySearchResult result = {}; + + // NOTE: Match ============================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 1); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 2); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 3); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 5U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 4); + + // NOTE: Lower bound ======================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 1); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 2); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 3); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 5U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 4); + + // NOTE: Upper bound ======================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 1); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 2); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 3); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 4); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 5U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 4); + } + + { + uint32_t array[] = {1, 1, 2, 2, 3}; + Dqn_BinarySearchResult result = {}; + + // NOTE: Match ============================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 2); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 4); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_Match); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 5); + + // NOTE: Lower bound ======================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 2); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 4); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 4U /*find*/, Dqn_BinarySearchType_LowerBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 5); + + // NOTE: Upper bound ======================================================================= + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 0U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 0); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 1U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 2); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 2U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(result.found); + DQN_ASSERT(result.index == 4); + + result = Dqn_BinarySearch(array, DQN_ARRAY_UCOUNT(array), 3U /*find*/, Dqn_BinarySearchType_UpperBound); + DQN_ASSERT(!result.found); + DQN_ASSERT(result.index == 5); + } + + { + Dqn_Arena_TempMemoryScope(&platform->arena); + TELY_ChunkPool pool = {}; + pool.arena = &platform->arena; + + void *bytes16 = TELY_ChunkPool_Alloc(&pool, 16); + TELY_ChunkPool_Dealloc(&pool, bytes16); + DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_16b] == DQN_CAST(void *)(DQN_CAST(char *)bytes16 - sizeof(TELY_ChunkPoolSlot))); + DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_16b]->next == nullptr); + + void *bytes17 = TELY_ChunkPool_Alloc(&pool, 17); + TELY_ChunkPool_Dealloc(&pool, bytes17); + DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_32b] == DQN_CAST(void *)(DQN_CAST(char *)bytes17 - sizeof(TELY_ChunkPoolSlot))); + DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_32b]->next == nullptr); + + void *bytes1 = TELY_ChunkPool_Alloc(&pool, 1); + void *bytes2 = TELY_ChunkPool_Alloc(&pool, 1); + TELY_ChunkPool_Dealloc(&pool, bytes1); + TELY_ChunkPool_Dealloc(&pool, bytes2); + DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_16b] == DQN_CAST(void *)(DQN_CAST(char *)bytes2 - sizeof(TELY_ChunkPoolSlot))); + DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_16b]->next == DQN_CAST(void *)(DQN_CAST(char *)bytes1 - sizeof(TELY_ChunkPoolSlot))); + + void *bytes128k = TELY_ChunkPool_Alloc(&pool, DQN_KILOBYTES(128)); + TELY_ChunkPool_Dealloc(&pool, bytes128k); + DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_128k] == DQN_CAST(void *)(DQN_CAST(char *)bytes128k - sizeof(TELY_ChunkPoolSlot))); + DQN_ASSERT(pool.slots[TELY_ChunkPoolSlotSize_128k]->next == nullptr); + } + + // NOTE: Unit test DFS pre-order and post-order walk + Dqn_Arena_TempMemoryScope(&platform->arena); + TELY_ChunkPool chunk_pool = {}; + chunk_pool.arena = &platform->arena; + + FP_Game *game = Dqn_Arena_New(&platform->arena, FP_Game, Dqn_ZeroMem_Yes); + game->chunk_pool = &chunk_pool; + game->entities = Dqn_VArray_Init(&platform->arena, 1024 * 8); + game->root_entity = Dqn_VArray_Make(&game->entities, Dqn_ZeroMem_No); + Dqn_FArray_Add(&game->parent_entity_stack, game->root_entity->handle); + + { + // NOTE: Setup entity-tree ================================================================= + + FP_GameEntity *f = FP_Game_MakeEntityPointerF(game, "F"); + FP_Game_PushParentEntity(game, f->handle); + FP_GameEntity *b = FP_Game_MakeEntityPointerF(game, "B"); + FP_GameEntity *g = FP_Game_MakeEntityPointerF(game, "G"); + FP_Game_PushParentEntity(game, b->handle); + FP_GameEntity *a = FP_Game_MakeEntityPointerF(game, "A"); + FP_GameEntity *d = FP_Game_MakeEntityPointerF(game, "D"); + FP_Game_PushParentEntity(game, d->handle); + FP_GameEntity *c = FP_Game_MakeEntityPointerF(game, "C"); + FP_GameEntity *e = FP_Game_MakeEntityPointerF(game, "E"); + FP_Game_PopParentEntity(game); + FP_Game_PopParentEntity(game); + + FP_Game_PushParentEntity(game, g->handle); + FP_GameEntity *i = FP_Game_MakeEntityPointerF(game, "I"); + FP_Game_PushParentEntity(game, i->handle); + FP_GameEntity *h = FP_Game_MakeEntityPointerF(game, "H"); + FP_Game_PopParentEntity(game); + FP_Game_PopParentEntity(game); + FP_Game_PopParentEntity(game); + + // NOTE: Pre order test ==================================================================== + + FP_GameEntity *pre_order_walk[9] = {}; + Dqn_usize pre_order_walk_count = 0; + for (FP_GameEntityIterator it = {}; FP_Game_DFSPreOrderWalkEntityTree(game, &it, game->root_entity);) { + DQN_ASSERT(pre_order_walk_count < DQN_ARRAY_UCOUNT(pre_order_walk)); + pre_order_walk[pre_order_walk_count++] = it.entity; + } + + DQN_ASSERT(pre_order_walk_count == DQN_ARRAY_UCOUNT(pre_order_walk)); + DQN_ASSERT(pre_order_walk[0] == f); + DQN_ASSERT(pre_order_walk[1] == b); + DQN_ASSERT(pre_order_walk[2] == a); + DQN_ASSERT(pre_order_walk[3] == d); + DQN_ASSERT(pre_order_walk[4] == c); + DQN_ASSERT(pre_order_walk[5] == e); + DQN_ASSERT(pre_order_walk[6] == g); + DQN_ASSERT(pre_order_walk[7] == i); + DQN_ASSERT(pre_order_walk[8] == h); + + // NOTE: Post order test =================================================================== + + FP_GameEntity *post_order_walk[9] = {}; + Dqn_usize post_order_walk_count = 0; + for (FP_GameEntityIterator it = {}; FP_Game_DFSPostOrderWalkEntityTree(game, &it, game->root_entity);) { + DQN_ASSERT(post_order_walk_count < DQN_ARRAY_UCOUNT(post_order_walk)); + post_order_walk[post_order_walk_count++] = it.entity; + } + + DQN_ASSERT(post_order_walk_count == DQN_ARRAY_UCOUNT(post_order_walk)); + DQN_ASSERT(post_order_walk[0] == a); + DQN_ASSERT(post_order_walk[1] == c); + DQN_ASSERT(post_order_walk[2] == e); + DQN_ASSERT(post_order_walk[3] == d); + DQN_ASSERT(post_order_walk[4] == b); + DQN_ASSERT(post_order_walk[5] == h); + DQN_ASSERT(post_order_walk[6] == i); + DQN_ASSERT(post_order_walk[7] == g); + DQN_ASSERT(post_order_walk[8] == f); + + // NOTE: Cleanup =========================================================================== + FP_Game_DeleteEntity(game, game->root_entity->handle); + DQN_ASSERT(game->root_entity->first_child == nullptr); + DQN_ASSERT(game->root_entity->last_child == nullptr); + DQN_ASSERT(game->root_entity->next == nullptr); + DQN_ASSERT(game->root_entity->prev == nullptr); + DQN_ASSERT(game->root_entity->parent == nullptr); + } +} diff --git a/feely_pona_unity.h b/feely_pona_unity.h index 91f40c2..f8a9995 100644 --- a/feely_pona_unity.h +++ b/feely_pona_unity.h @@ -65,4 +65,5 @@ DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with inte #include "feely_pona.h" #include "feely_pona_game.cpp" +#include "feely_pona_misc.cpp" #include "feely_pona.cpp"