diff options
| author | nathan <nathansmith@disroot.org> | 2026-01-14 09:08:06 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2026-01-14 09:08:06 +0000 |
| commit | bbce25930d9910c715245f5d87a108ab1dac3426 (patch) | |
| tree | 2820245b8c6714a3ba69981a34cc7aafdbf8b8fb | |
| parent | 2ab36473a20ec33e8d3cae810384b4f28505b4f9 (diff) | |
| download | FindThings-bbce25930d9910c715245f5d87a108ab1dac3426.tar.gz FindThings-bbce25930d9910c715245f5d87a108ab1dac3426.tar.bz2 FindThings-bbce25930d9910c715245f5d87a108ab1dac3426.zip | |
Mad libs thingy working
| -rw-r--r-- | src/game.c | 13 | ||||
| -rw-r--r-- | src/mad-libs.c | 208 | ||||
| -rw-r--r-- | src/mad-libs.h | 31 | ||||
| -rw-r--r-- | src/utils.c | 4 | ||||
| -rw-r--r-- | src/utils.h | 6 | ||||
| -rw-r--r-- | src/world.h | 1 |
6 files changed, 258 insertions, 5 deletions
@@ -1,6 +1,9 @@ #include "game.h" #include "utils.h" +#include "mad-libs.h" +#include "time.h" + void resetScreenScale(Game* game) { Texture texture = game->screen.render.texture; @@ -99,6 +102,16 @@ void initGame(Game* game) initInventory(&game->inventory, &game->settings); disableGameCursor(game); + + /* char randomWord[MAD_LIBS_MAX]; */ + /* getRandomMapLibsWord(randomWord, '@', -time(NULL)); */ + /* printf("word thingy: %s\n", randomWord); */ + + char randomThingy[512]; + mapLibs(randomThingy, "I bet your a @j @n who likes to @v to pay for @n", 512, + -time(NULL)); + printf("hehehe: %s\n", randomThingy); + } void updateMainMenuScene(Game* game) diff --git a/src/mad-libs.c b/src/mad-libs.c new file mode 100644 index 0000000..3e6882c --- /dev/null +++ b/src/mad-libs.c @@ -0,0 +1,208 @@ +#include "mad-libs.h" + +// Yes, these are mostly made up and/or wrong. + +const char madLibsNouns[NOUN_COUNT][MAD_LIBS_MAX] = { + "infundibulum", + "bike", + "church", + "pinball", + "shark", + "finger", + "trolley", + "loo", + "khazi", + "science", + "philosophy", + "math", + "wingus", + "fartulum", + "gorilla", + "glue", + "turdus", + "acid", + "weed", + "fungus", + "algorithm", + "schrodinger", + "irregularist", + "bioliquidifeazion", + "arson", + "art", + "triangle", + "fuck", + "mold", + "wyoming", + "duck", + "goose", + "fish", + "wheel", + "gack", + "poop", + "vin-dit", + "duffle" +}; + +const char madLibsVerbs[VERB_COUNT][MAD_LIBS_MAX] = { + "conpockulate", + "vomit", + "ejackulate", + "dualmakulate", + "fart", + "run", + "hide", + "hiss", + "piss", + "walk", + "backwards", // Yes, backwards shall be a verb! + "forwards", // Again hehehe + "jump", + "fall", + "fly", + "sidewalk", + "slift", + "sniff", + "piff", + "conmanoulrlate", + "quack", + "yell", + "spin", + "spit", + "fuck" +}; + +const char madLibsAdverbs[ADVERB_COUNT][MAD_LIBS_MAX] = { + "speedi", + "pacedfullili", + "admorsfullili", + "analsisli", + "dupaleli", + "quickli", + "slowli", + "snailenleli", + "painfulli", + "very", + "torroe", + "eispfulli", + "gentli", + "badli", + "goodli", + "bearli", + "skilllessli" +}; + +const char madLibsAdjectives[ADJECTIVE_COUNT][MAD_LIBS_MAX] = { + "skibidi", + "neolimbpengintical", + "surreal", + "reverse", + "chrono-synclastic", + "purple", + "pink", + "nurple", + "macro", + "cracko", + "dualo", + "smelli", + "maximus", + "moronic", + "mundane", + "grandeural", + "neon", + "irregular", + "stuppa", + "fuck", + "blissfull", + "kind", + "bald", + "mini", + "idealistic", + "materialistic", + "nincompoop", + "granfalloon" +}; + +Seed getRandomMapLibsWord(char* outputString, char type, Seed seed) +{ + // Random type. + if (type == 'r') + { + char types[] = {'n', 'v', 'a', 'j'}; + type = types[FT_RANDOM16(seed) % sizeof(types)]; + } + + FT_RANDOM16(seed); + + switch (type) + { + case 'n': + strncpy(outputString, madLibsNouns[seed % NOUN_COUNT], MAD_LIBS_MAX); + break; + case 'v': + strncpy(outputString, madLibsVerbs[seed % VERB_COUNT], MAD_LIBS_MAX); + break; + case 'a': + strncpy(outputString, madLibsAdverbs[seed % ADVERB_COUNT], MAD_LIBS_MAX); + break; + case 'j': + strncpy(outputString, madLibsAdjectives[seed % ADJECTIVE_COUNT], + MAD_LIBS_MAX); + break; + case '@': + outputString[0] = '@'; + outputString[1] = '\0'; + break; + default: + outputString[0] = '\0'; + break; + } + + return seed; +} + +Seed mapLibs(char* outputString, const char* formatString, size_t maxSize, + Seed seed) +{ + int outputStringIndex = 0; + bool skipNext = false; + memset(outputString, 0, maxSize); + + for (int index = 0; index < maxSize; ++index) + { + if (formatString[index] == '\0') + { + break; + } + + if (!skipNext && formatString[index] == '@' && index < maxSize - 1) + { + skipNext = true; + char type = formatString[index + 1]; + char randomWord[MAD_LIBS_MAX]; + seed = getRandomMapLibsWord(randomWord, type, seed); + + for (int index2 = 0; index2 < MAD_LIBS_MAX; ++index2) + { + if (randomWord[index2] == '\0') + { + break; + } + + outputString[outputStringIndex] = randomWord[index2]; + ++outputStringIndex; + } + } + else + { + if (!skipNext) + { + outputString[outputStringIndex] = formatString[index]; + ++outputStringIndex; + } + + skipNext = false; + } + } + + return seed; +} diff --git a/src/mad-libs.h b/src/mad-libs.h new file mode 100644 index 0000000..cb996f4 --- /dev/null +++ b/src/mad-libs.h @@ -0,0 +1,31 @@ +#include "utils.h" + +#ifndef MAD_LIBS_H +#define MAD_LIBS_H + +/* + @n for noun + @v for verb + @a for adverb + @j for adjective + @r for random + @@ for normal @ +*/ + +#define MAD_LIBS_MAX 24 + +#define NOUN_COUNT 38 +#define VERB_COUNT 25 +#define ADVERB_COUNT 17 +#define ADJECTIVE_COUNT 28 + +extern const char madLibsNouns[NOUN_COUNT][MAD_LIBS_MAX]; +extern const char madLibsVerbs[VERB_COUNT][MAD_LIBS_MAX]; +extern const char madLibsAdverbs[ADVERB_COUNT][MAD_LIBS_MAX]; +extern const char madLibsAdjectives[ADJECTIVE_COUNT][MAD_LIBS_MAX]; + +Seed getRandomMapLibsWord(char* outputString, char type, Seed seed); +Seed mapLibs(char* outputString, const char* formatString, size_t maxSize, + Seed seed); + +#endif diff --git a/src/utils.c b/src/utils.c index e2e7d35..13de14f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,6 +1,6 @@ #include "utils.h" -Vector2 randomDirection2(int seed, int* nextSeed) +Vector2 randomDirection2(int seed, Seed* nextSeed) { Vector2 direction; direction.x = FT_RANDOM16(seed) % RANDOM_DIRECTION_UNITS; @@ -16,7 +16,7 @@ Vector2 randomDirection2(int seed, int* nextSeed) return Vector2Normalize(direction); } -Vector3 randomDirection3(int seed, int* nextSeed) +Vector3 randomDirection3(int seed, Seed* nextSeed) { Vector3 direction; direction.x = FT_RANDOM16(seed) % RANDOM_DIRECTION_UNITS; diff --git a/src/utils.h b/src/utils.h index 7947041..ffcc116 100644 --- a/src/utils.h +++ b/src/utils.h @@ -59,6 +59,8 @@ #define RANDOM_DIRECTION_UNITS 4096 +typedef int Seed; + // Typedef hackery. typedef struct Game Game; typedef struct World World; @@ -68,8 +70,8 @@ typedef enum FTError { FTSUCCESS = 0 } FTError; -Vector2 randomDirection2(int seed, int* nextSeed); -Vector3 randomDirection3(int seed, int* nextSeed); +Vector2 randomDirection2(int seed, Seed* nextSeed); +Vector3 randomDirection3(int seed, Seed* nextSeed); Image colorsToImage(Color* colors, int width, int height); diff --git a/src/world.h b/src/world.h index d714b29..c5cf182 100644 --- a/src/world.h +++ b/src/world.h @@ -42,7 +42,6 @@ // UID for anything in the world. typedef int16_t WorldUID; -typedef int Seed; // Places. enum { |
