Skip to content

Instantly share code, notes, and snippets.

View nezvers's full-sized avatar

Agnis Aldiņš "NeZvērs" nezvers

View GitHub Profile
@nezvers
nezvers / carve.c
Created December 1, 2025 09:05
Binary extraction in C
#include <stdio.h>
void carve_file(const char *input_file, const char *output_file, size_t start_byte, size_t end_byte){
FILE *file_in = NULL;
FILE *file_out = NULL;
file_in = fopen(input_file, "rb");
if (!file_in) {
printf("Failed to open input file - %s\n", input_file);
goto defer;
@nezvers
nezvers / nob_raylib.c
Last active November 9, 2025 22:26
nob.h template for raylib with fetch (Cmake style) using only C & Curl/Wget
#define NOB_IMPLEMENTATION
// #define NOB_STRIP_PREFIX
#define NOB_WARN_DEPRECATED
#include "nob.h" // https://github.com/tsoding/nob.h
#include <stdio.h>
#include <string.h>
#define PROJECT_NAME "NoBuild_Raylib"
#define BUILD_FOLDER "build/"
@nezvers
nezvers / timer.c
Last active October 18, 2025 11:05
High precision timer/clock (Windows, Linux)
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <time.h>
#endif
static double timer_start = 0.0;
@nezvers
nezvers / SDL3 + Dear ImGui CMake.txt
Last active August 20, 2025 06:46
SDL3 + Dear ImGui CMake
cmake_minimum_required(VERSION 3.12)
include(FetchContent)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 17)
# SDL3 ______________________________________________
FetchContent_Declare(
sdl3
cmake_minimum_required(VERSION 3.28)
include(FetchContent)
set(ProjectName RaylibTemplate)
project(${ProjectName} LANGUAGES C CXX)
# Raylib _______________________________________
FetchContent_Declare(
raylib
DOWNLOAD_EXTRACT_TIMESTAMP OFF
@nezvers
nezvers / SDL3 Cmake template.txt
Last active April 9, 2025 11:47
SDL3 Cmake template
cmake_minimum_required(VERSION 3.12)
include(FetchContent)
set(PROJECT_NAME Sdl3Template)
project(${PROJECT_NAME})
# ?
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.12)
include(FetchContent)
set(PROJECT_NAME SfmlTemplate)
project(${PROJECT_NAME} VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.28)
include(FetchContent)
# NAME
set(PROJECT_NAME RaylibTemplate)
project(${PROJECT_NAME} LANGUAGES C)
set(CMAKE_C_STANDARD 99)
# set(CMAKE_CXX_STANDARD 17)
@nezvers
nezvers / spring.gd
Created May 21, 2024 22:27
Spring delta time equation [Godot]
## Translated from EgoMoose tutorial of deriving formula for Unity
## https://youtu.be/FZekwtIO0I4
## https://gist.github.com/EgoMoose/777ed827e89b69d479ea407e79261b97
class_name SpringMath
extends Node
## zeta = damping ratio
## omega = angular frequency
static func vec1(value:float, target:float, velocity:float, delta:float, zeta:float = 0.3, omega:float = 20.0)->Array[float]:
@nezvers
nezvers / better_jumping_character_example.gd
Last active July 22, 2021 09:46 — forked from sjvnnings/better_jumping_character_example.gd
An easy to work with jump in Godot
# https://youtu.be/IOe1aGY6hXA
extends KinematicBody2D
export var move_speed = 200.0
var velocity := Vector2.ZERO
export var jump_height : float
export var jump_time_to_peak : float
export var jump_time_to_descent : float