Skip to content

Instantly share code, notes, and snippets.

View jweinst1's full-sized avatar
🎯
Focusing

Josh Weinstein jweinst1

🎯
Focusing
View GitHub Profile
@jweinst1
jweinst1 / inttoarrayfast.cpp
Last active July 29, 2026 06:29
murmur3 hash to larger array map
#include <iostream>
#include <vector>
#include <unordered_map>
#include <random>
#include <chrono>
#include <cstdint>
#include <limits>
#include <cstring>
#include <cstdlib>
#include <cstdio>
@jweinst1
jweinst1 / glass_shatter.cpp
Created July 25, 2026 00:30
glass shattering game in C++
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <random>
// Linearly interpolate between two points
inline SDL_FPoint lerp(const SDL_FPoint& a, const SDL_FPoint& b, float t) {
return SDL_FPoint{
@jweinst1
jweinst1 / sphere_vertex.cpp
Last active July 21, 2026 08:06
sphere made via vertex in C++
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cmath>
#include <vector>
// Calculates the X and Y screen coordinates for a circle centered anywhere
void get_arbitrary_circle_point_trig(
float centerX, float centerY,
@jweinst1
jweinst1 / rotate_with_indices.cpp
Created July 19, 2026 08:59
rotate 3 way pyramid with indices in C++
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cmath>
struct Vec3 {
float x, y, z;
};
typedef struct {
Vec3 position;
@jweinst1
jweinst1 / circle_with_trig.cpp
Created July 18, 2026 07:41
draw a circle with sin and cos in C++ SDL3
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cmath>
// Calculates the X and Y screen coordinates for a circle centered anywhere
void get_arbitrary_circle_point_trig(
float centerX, float centerY,
float radius, float angle_radians,
float* out_x, float* out_y
) {
@jweinst1
jweinst1 / 3dcube.cpp
Last active July 16, 2026 08:33
triangle and geometry drawing in C++ with SDL3
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
typedef struct {
SDL_FPoint position;
SDL_FColor color;
} LocalVertex;
// 3d cube shape
static constexpr LocalVertex BLUEPRINT[] = {
@jweinst1
jweinst1 / chess.cpp
Last active July 14, 2026 23:46
Chess in SDL3 with C++
#include <SDL3/SDL.h>
#include <iostream>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
@jweinst1
jweinst1 / sdl_audio.cpp
Created July 11, 2026 19:15
audio sounds for games in SDL
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cmath>
#include <iostream>
#include <cstdlib> // For rand()
// Global settings
const float SAMPLE_RATE = 48000.0f;
const float PI = 3.14159265f;
@jweinst1
jweinst1 / text_box_sdl3.cpp
Last active July 11, 2026 17:52
implementation of a tiny text box in sdl3
#include <SDL3/SDL.h>
#include <iostream>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
@jweinst1
jweinst1 / sdl3_template.cpp
Created July 8, 2026 03:08
empty SDL3 time accum loop
#include <SDL3/SDL.h>
#include <iostream>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>