commit e2fe4b565956d59c57ed62cbb80a6b3bd1103825 Author: Felisp Date: Sat Jan 20 03:00:20 2024 +0100 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..fe47a4f --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# TwiEyes + +

XEyes but with Twilight Sprakle!

+ +Made as simple RayLib try-out project + +Currently needs mouse cursor inside the window to track your mouse, will be remade to use X11 in the future + +#### How it looks + +![TwiEyes](res/twiEyes.gif) + +#### Used art + +- Twilight + - [PP](https://ponerpics.org/images/1201365) + - [PB](https://ponybooru.org/images/1746069) + - [DB](https://derpibooru.org/images/1201365) + - [TB](https://twibooru.org/933923) +- Twilights Eye + - [kindpng](https://www.kindpng.com/imgv/oixoJx_pony-clipart-eye-twilight-sparkle-my-little-pony/) + diff --git a/res/twiEyes.gif b/res/twiEyes.gif new file mode 100644 index 0000000..625defc Binary files /dev/null and b/res/twiEyes.gif differ diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..440167c --- /dev/null +++ b/src/Makefile @@ -0,0 +1,2 @@ +all: + gcc main.c -lraylib diff --git a/src/eyeLeft.png b/src/eyeLeft.png new file mode 100644 index 0000000..cdb95ae Binary files /dev/null and b/src/eyeLeft.png differ diff --git a/src/eyeRight.png b/src/eyeRight.png new file mode 100644 index 0000000..b73d3c3 Binary files /dev/null and b/src/eyeRight.png differ diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..ac4fd74 --- /dev/null +++ b/src/main.c @@ -0,0 +1,48 @@ +#include +#include +#include "raylib.h" + +// Won't move eyes past than this limit +const int maxShiftX = 40, maxShiftY = 80; + +/**Calculates new EyePosition*/ +void newEyePos(const Vector2* const baseEyePos, const Vector2* const mouse, Vector2* eye) { + + int shiftX = (mouse->x - baseEyePos->x) /4; + shiftX = shiftX > maxShiftX ? maxShiftX : (abs(shiftX) > maxShiftX) ? -maxShiftX : shiftX; + int shiftY = (mouse->y - baseEyePos->y) /4; + shiftY = shiftY > maxShiftY ? maxShiftY : (abs(shiftY) > maxShiftY) ? -maxShiftY : shiftY; + + eye->y = baseEyePos->y + shiftY; + eye->x = baseEyePos->x + shiftX; +} + +int main(int argc, char* argv[]) { + const Vector2 leftCenter = {120, 375}; + const Vector2 rightCenter = {300, 375}; + + Image softTwi = LoadImage("./twi.png"); + InitWindow(softTwi.width/2, softTwi.height/2, "TwiEyes"); + Texture2D twi = LoadTextureFromImage(softTwi); + + Vector2 twiPos = {0, 0 }; + Vector2 rightEyePos = rightCenter, leftEyePos = leftCenter; + + Texture2D leftEye = LoadTexture("eyeLeft.png"); + Texture2D rightEye = LoadTexture("eyeRight.png"); + + Vector2 mousePos; + while (!WindowShouldClose()) { + mousePos = GetMousePosition(); + newEyePos(&leftCenter, &mousePos, &leftEyePos); + newEyePos(&rightCenter, &mousePos, &rightEyePos); + BeginDrawing(); + ClearBackground(WHITE); + DrawTextureEx(leftEye, leftEyePos, 0, 0.19, WHITE); + DrawTextureEx(rightEye, rightEyePos, 0, 0.19, WHITE); + DrawTextureEx(twi, twiPos, 0, 0.5, WHITE); + EndDrawing(); + } + CloseWindow(); + return 0; +} diff --git a/src/twi.png b/src/twi.png new file mode 100644 index 0000000..3ae4f5d Binary files /dev/null and b/src/twi.png differ