Skip to content

Instantly share code, notes, and snippets.

View rakin406's full-sized avatar
๐Ÿ˜

Rakin Rahman rakin406

๐Ÿ˜
View GitHub Profile
@rakin406
rakin406 / clock.cpp
Created December 4, 2023 14:58
C++ clock and delta time
#include "clock.h"
#include <chrono>
Clock::Clock() : lastTick { std::chrono::steady_clock::now() }, deltaTime { 0 }
{
}
void Clock::tick()
{
@rakin406
rakin406 / randomGenerator.cpp
Last active November 29, 2023 18:55
C++ random number generation function
int getRandomValue(int min, int max)
{
static std::random_device rd {};
static std::mt19937 mt { rd() };
std::uniform_int_distribution<std::mt19937::result_type> dist(min, max);
return dist(mt);
}
@rakin406
rakin406 / colors.h
Created November 28, 2023 16:37
Custom color palette header for C++ and SDL
#ifndef COLORS_H
#define COLORS_H
#include "SDL.h"
// Custom color palette
inline constexpr SDL_Color LIGHTGRAY { 200, 200, 200, 255 }; // Light Gray
inline constexpr SDL_Color GRAY { 130, 130, 130, 255 }; // Gray
inline constexpr SDL_Color DARKGRAY { 80, 80, 80, 255 }; // Dark Gray