Mouse following thing and template fix
This commit is contained in:
parent
058a007265
commit
ee68131914
|
@ -1,7 +1,7 @@
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
InitWindow(__WINDOW_WIDTH, __WINDOW_HEIGHT, "__PROJECT_NAME");
|
InitWindow(__WINDOW_WIDTH, __WINDOW_HEIGHT, "__PROJECT");
|
||||||
|
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) {
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
follow-mouse
|
|
@ -0,0 +1,12 @@
|
||||||
|
CFLAGS += -Wall -Wextra `exec pkg-config --cflags raylib`
|
||||||
|
LDFLAGS := -lm `pkg-config --libs raylib`
|
||||||
|
|
||||||
|
follow-mouse: main.c
|
||||||
|
$(CC) $(CFLAGS) main.c $(LDFLAGS) -o follow-mouse
|
||||||
|
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) follow-mouse
|
||||||
|
|
||||||
|
run: follow-mouse
|
||||||
|
./follow-mouse
|
|
@ -0,0 +1,35 @@
|
||||||
|
// x-run: make run
|
||||||
|
#include <raylib.h>
|
||||||
|
#include <raymath.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define TRAIL_LENGTH 360
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||||
|
InitWindow(800, 600, "vis/follow-mouse");
|
||||||
|
SetTargetFPS(120);
|
||||||
|
|
||||||
|
Vector2 trail[TRAIL_LENGTH];
|
||||||
|
Vector2 ex_trail[TRAIL_LENGTH];
|
||||||
|
|
||||||
|
Vector2 pos = { 0, 0 };
|
||||||
|
|
||||||
|
while (!WindowShouldClose()) {
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(BLACK);
|
||||||
|
memmove(&trail[0], &trail[1], sizeof(Vector2) * (TRAIL_LENGTH - 1));
|
||||||
|
trail[TRAIL_LENGTH - 1] = GetMousePosition();
|
||||||
|
DrawLineStrip(trail, TRAIL_LENGTH, RED);
|
||||||
|
|
||||||
|
pos = Vector2Lerp(pos, trail[TRAIL_LENGTH - 1], 0.125);
|
||||||
|
DrawCircleLines(pos.x, pos.y, 8, WHITE);
|
||||||
|
memmove(&ex_trail[0], &ex_trail[1], sizeof(Vector2) * (TRAIL_LENGTH - 1));
|
||||||
|
ex_trail[TRAIL_LENGTH - 1] = pos;
|
||||||
|
|
||||||
|
DrawLineStrip(ex_trail, TRAIL_LENGTH, GREEN);
|
||||||
|
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue