Wave Maker
A downloadable game for Windows
Make your own mathmatical waves. Choose to use Sin, Cos or Tan waves.
Below is the raw source code:
#include "raylib.h"
#include <cmath>
#include <iostream>
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
#include <functional>
float n = 1.0f; // Kept as float for smooth step additions
float slider = 0.0f;
float slider2 = 20.0f;
float slider3 = 50.0f;
float OFFSET = 350;
int cycle = 1;
float multiplier = 1.0f;
float functio(float angle) {
if (cycle == 1) {
float result = sinf(angle);
return result;
} else if (cycle == 2) {
float result = cosf(angle);
return result;
} else if (cycle == 3) {
float result = tanf(angle);
return result;
}
return 0.0f;
}
int main() {
// Matches your target high-resolution layout
InitWindow(1900, 1000, "Simple Wave");
SetTargetFPS(200);
// Set colors for the NORMAL state (unhovered)
GuiSetStyle(BUTTON, BORDER_COLOR_NORMAL, ColorToInt(DARKGRAY));
GuiSetStyle(BUTTON, BASE_COLOR_NORMAL, ColorToInt(SKYBLUE));
GuiSetStyle(BUTTON, TEXT_COLOR_NORMAL, ColorToInt(BLACK));
// Set colors for the FOCUSED state (hovered)
GuiSetStyle(BUTTON, BORDER_COLOR_FOCUSED, ColorToInt(BLUE));
GuiSetStyle(BUTTON, BASE_COLOR_FOCUSED, ColorToInt(BLUE));
GuiSetStyle(BUTTON, TEXT_COLOR_FOCUSED, ColorToInt(WHITE));
// Set colors for the PRESSED state (clicked)
GuiSetStyle(BUTTON, BORDER_COLOR_PRESSED, ColorToInt(DARKBLUE));
GuiSetStyle(BUTTON, BASE_COLOR_PRESSED, ColorToInt(DARKBLUE));
GuiSetStyle(BUTTON, TEXT_COLOR_PRESSED, ColorToInt(LIGHTGRAY));
while (!WindowShouldClose()) {
BeginDrawing();
ClearBackground(BLACK);
// 1. INCREASE TOTAL POINTS: Use 400 spheres to cover the screen width
for (int i = 0; i < 300; i++) {
// 2. PACK THEM CLOSER: Space them by 5 pixels instead of 40 (400 * 5 = 2000px wide)
float x = (i * 6.0f);
// 3. SCALE THE VALUE INSIDE SINE: Multiplying 'i' by a decimal prevents the math from fragmenting
float y = (450.0f + functio((i * slider2/200/*0.08f*/) - n) * ((slider3 * 0.8) * 5));
// 4. RADIUS ADJUSTMENT: 5.0f keeps them tight and crisp
DrawCircle(x, y, 5.0f, RAYWHITE);
}
GuiSlider(
(Rectangle){ (950 - OFFSET), 900, 200, 40 },
"SPEED MULTIPLIER",
TextFormat("%0.0f", slider),
&slider, // <-- The ampersand passes the pointer!
0.0f,
100.0f
);
GuiSlider(
(Rectangle){ (450 - OFFSET), 900, 200, 40 },
"WAVELENGTH",
TextFormat("%0.0f", slider2),
&slider2, // <-- The ampersand passes the pointer!
0.0f,
100.0f
);
GuiSlider(
(Rectangle){ (1450 - OFFSET), 900, 200, 40 },
"AMPLITUDE",
TextFormat("%0.0f", slider3),
&slider3, // <-- The ampersand passes the pointer!
0.0f,
100.0f
);
GuiSlider(
(Rectangle){ (1200 - OFFSET), 950, 200, 40 },
"EXTRA SPEED MULTIPLIER",
TextFormat("%0.0f", multiplier),
&multiplier, // <-- The ampersand passes the pointer!
1.0f,
10.0f
);
// This button will be drawn automatically using the global styles set above
if (GuiButton((Rectangle){ (1950 - OFFSET), 900, 200, 40 }, "SWITCH WAVE TYPE")) {
cycle += 1;
if (cycle >= 4) {
cycle = 1;
}
}
EndDrawing();
// we slow down the increment step so the wave doesn't race across the screen.
n += ((float(slider) * multiplier)/1000);
std::cout << n << "\r" << std::flush;
}
CloseWindow();
return 0;
}
| Published | 2 days ago |
| Status | Released |
| Platforms | Windows |
| Author | RGB2056 |
| AI Disclosure | AI Assisted, Code |

Leave a comment
Log in with itch.io to leave a comment.