commit 780a10d4daa88f4c51db69a520f3edad56d49b66 Author: echo Date: Sat Jul 13 23:01:16 2024 +0330 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cea3753 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +raylib +compile/linux +compile/web/index.* +compile/linux diff --git a/compile/.gitkeep b/compile/.gitkeep new file mode 100644 index 0000000..38540e5 --- /dev/null +++ b/compile/.gitkeep @@ -0,0 +1 @@ +https://github.com/Vendicated/Vencord/pull/1818 \ No newline at end of file diff --git a/compile/web/.gitkeep b/compile/web/.gitkeep new file mode 100644 index 0000000..38540e5 --- /dev/null +++ b/compile/web/.gitkeep @@ -0,0 +1 @@ +https://github.com/Vendicated/Vencord/pull/1818 \ No newline at end of file diff --git a/emscripten.html b/emscripten.html new file mode 100644 index 0000000..48f97dc --- /dev/null +++ b/emscripten.html @@ -0,0 +1,350 @@ + + + + + + + + emscripten is weird + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+
+ +
+ + + + + + + + + + {{{ SCRIPT }}} + + + + \ No newline at end of file diff --git a/game.c b/game.c new file mode 100644 index 0000000..bbb8a09 --- /dev/null +++ b/game.c @@ -0,0 +1,161 @@ +#include "raylib.h" +#include +#include +// #include +// #include + +struct level { + int currentlevel; + int neededpoint; +}; + +// const char *thefunny[] = {"keep it up!", "edging is very fun", "good job", +// "spam that spacebar!", ":3"}; +// int array_size = sizeof(thefunny) / sizeof(thefunny[0]); +int getlevel(int score); +int calculatepoint(int point, struct level lvl) { + int newpoint = point; + + if (IsKeyDown(KEY_SPACE) || IsMouseButtonDown(MOUSE_LEFT_BUTTON)) { + newpoint += 1 * lvl.currentlevel; + } else if (point > 0) { + newpoint -= 1 * lvl.currentlevel; + } + + return newpoint; +} + +int getscore(int point, bool lost, struct level lvl) { + if (lost) { + return 0; + } + if (point > 386) { + return 25 * (lvl.currentlevel * 2); + } else if (point > 354) { + return 12 * (lvl.currentlevel * 2); + } else if (point > 295) { + return 5 * (lvl.currentlevel * 2); + } else if (point > 236) { + return 2 * (lvl.currentlevel * 2); + } else if (point > 197) { + return 1 * (lvl.currentlevel * 2); + } + return 0; +} + +void congrats(int level, int *framecounter) { *framecounter = 100; } + +int getrequiredPoints(int level) { + int result = 0; + while (level >= 3) { + result += pow(5, 3); + level -= 3; + } + if (level > 0) { + result += pow(5, level); + } + return result; +} + +void updateLevel(struct level *lvl, int points, int *framecounter) { + int requiredPoints = 1000 * getrequiredPoints(lvl->currentlevel); + if (points >= requiredPoints) { + lvl->currentlevel++; + congrats(lvl->currentlevel, framecounter); + lvl->neededpoint = 1000 * getrequiredPoints(lvl->currentlevel); + } +} + +int main(void) { + const int windowWidth = 800; + const int windowHeight = 450; + InitWindow(windowWidth, windowHeight, "me edging my progressbar"); + + const char *title = "me edging my progressbar"; + const char *subtitle = "a game about edging progressbars"; + const char *losttext = "your progress was \"filled\""; + const char *sublosttext = "press e to try again (or just click, mf mobile users smh)"; + + SetTargetFPS(120); + int point = 0; + struct level playerLevel = {1, 5000}; + int score = 0; + bool lost = false; + int framecounter = 0; + while (!WindowShouldClose()) { + framecounter--; + BeginDrawing(); + ClearBackground(DARKGRAY); + if (framecounter > 0) { + DrawTextPro(GetFontDefault(), + TextFormat("advanced to lvl%d", playerLevel.currentlevel), + (Vector2){600, 180}, + (Vector2){MeasureText(TextFormat("advanced to lvl%d", + playerLevel.currentlevel), + 20) / + 2.0f, + 10.0f}, + 10, 20, 1, GRAY); + } + if (!lost) { + DrawText(title, (windowWidth - MeasureText(title, 40)) / 2, 20, 40, + LIGHTGRAY); + DrawText(subtitle, (windowWidth - MeasureText(subtitle, 20)) / 2, 90, 20, + LIGHTGRAY); + } else { + DrawText(losttext, (windowWidth - MeasureText(losttext, 40)) / 2, 20, 40, + LIGHTGRAY); + DrawText(sublosttext, (windowWidth - MeasureText(sublosttext, 20)) / 2, + 90, 20, LIGHTGRAY); + } + + if (lost && (IsKeyDown(KEY_E)|| IsMouseButtonDown(MOUSE_LEFT_BUTTON))) { + point = 0; + lost = false; + score = 0; + playerLevel.currentlevel = 1; + } + // srand(time(NULL)); + // if (rand() % 100000) { + // srand(time(NULL)); + // int random = rand() % array_size; + // DrawText(thefunny[random], 400 - MeasureText(thefunny[random], 26), 180, 26, LIGHTGRAY); + // } + + lost = (point >= 394); + if (!lost) { + point = calculatepoint(point, playerLevel); + } + + DrawText(TextFormat("score: %d", score), 100, 300, 20, LIGHTGRAY); + DrawText(TextFormat("level: %d", playerLevel.currentlevel), 100, 330, 20, + LIGHTGRAY); + DrawText(TextFormat("next level: %d points", playerLevel.neededpoint), + windowWidth - + MeasureText(TextFormat("next level: %d points", + playerLevel.neededpoint), + 20) - + 20, + 300, 20, LIGHTGRAY); + updateLevel(&playerLevel, score, &framecounter); + printf("needed: %d p: %d - s: %d - l: %d\n", playerLevel.neededpoint, point, + score, playerLevel.currentlevel); + score += getscore(point, lost, playerLevel); + + DrawRectangle(203, 203, point, 44, PINK); + + DrawRectangle(397, 203, 3, 44, (Color){255, 216, 167, 255}); + DrawRectangle(436, 203, 3, 44, (Color){246, 182, 182, 255}); + DrawRectangle(495, 203, 3, 44, (Color){227, 150, 204, 255}); + DrawRectangle(554, 203, 3, 44, (Color){209, 115, 227, 255}); + DrawRectangle(586, 203, 3, 44, (Color){171, 84, 231, 255}); + Rectangle rec1 = {200, 200, 400, 50}; + DrawRectangle(600, 200, 400, 70, DARKGRAY); + DrawRectangleLinesEx(rec1, 3, RED); + + EndDrawing(); + } + + CloseWindow(); + return 0; +} diff --git a/makefilebutbetter.sh b/makefilebutbetter.sh new file mode 100755 index 0000000..40f992d --- /dev/null +++ b/makefilebutbetter.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +if [ $# -eq 0 ]; then + echo "compiling for linux - assuming you have raylib installed" + gcc -o ./compile/linux game.c -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 +else + echo "im too lazy to check what you passed as the argument - assuming you want to compile for web" + echo "you need emscripten, and raylib compiled with it, firgure it out yourself idfk" + + emcc -o ./compile/web/index.html game.c -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -Os -I. -I \ + ./raylib/src/ -I ./raylib/src/external/ -L. -L\ + ./raylib/src -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=67108864\ + -s FORCE_FILESYSTEM=1 --shell-file ./emscripten.html ./raylib/src/web/libraylib.a\ + -DPLATFORM_WEB -s 'EXPORTED_FUNCTIONS=["_free","_malloc","_main"]'\ + -s EXPORTED_RUNTIME_METHODS=ccall +fi \ No newline at end of file