Skip to content

Instantly share code, notes, and snippets.

@kdrnic
kdrnic / fix.md
Last active June 29, 2021 23:46
Finding and fixing a bug in a Lua JSON parser

Engine entities

This is a comparison of data structures for game entities (aka objects, actors...) across different games and game engines.

Game engine choices

  1. Source code has to be at least partly available, either in original form or through reverse-engineering or a remake
  2. The complexity of a 3D game makes those generally more interesting
  3. Similarly, a game in the action genre has more interesting architectural challenges than other genres - complex AI, several different object behaviours, all data structures must be highly performant, etc.
  4. The code is preferentially in the C/C++ languages
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<script src="ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var allegro_code = `
ceil = Math.ceil;
floor = Math.floor;
sin = Math.sin;
@kdrnic
kdrnic / gouraud.c
Created April 19, 2020 18:21
Laziest gouraud shader
/*
Random internet code to solve system of 3 lin eqs:
float a,b,c,d,l,m,n,k,p,D,q,r,s,x,y,z;
printf("PROGRAM TO SOLVE THREE VARIABLE LINEAR SIMULTANEOUS EQUATIONS");
printf("The equations are of the form:"
"ax+by+cz+d=0"
"lx+my+nz+k=0"
"px+qy+rz+s=0");
printf("Enter the coefficients in the order a,b,c,d,l,m,n,k,p,q,r,s");
"""
TurboBSP Power 97 2.0 lightmap baker and map exporter script
Lightmap bake script
Objectives
----------
-Source is regular Blender file, containing a level
-Level geometry must be in an object called "level"
-"lightmap" object if present will be deleted
#include <allegro.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
#include "mesh.h"
#include "obj.h"
#include "compat.h"
@kdrnic
kdrnic / build.js
Created July 23, 2019 22:33
A minimalist static site "generator"
//Code highlighting
hljs = require('highlight.js');
fs = require('fs');
//HTML processing
cheerio = require('cheerio');
//Name of code highlighter style sheet
var hlcss = "hlstyles/default.css";
var filenames = fs.readdirSync("./");
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <Windows.h>
const char prog[1024] = "\"C:\\Program Files (x86)\\Notepad++\\notepad++.exe\"";
DWORD GetNumCharsInConsoleBuffer()
{
CONSOLE_SCREEN_BUFFER_INFO buffer_info;
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <assert.h>
#include <string.h>
#include <limits.h>
#include <inttypes.h>
uint32_t fnv1(const char *str)
@kdrnic
kdrnic / hash.c
Created April 30, 2019 00:37
hashtable implementation in C uses open addressing, linear probing also includes a FNV1/DJB2 hashing comparison
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <assert.h>
#include <string.h>
#include <limits.h>
#include <inttypes.h>
uint32_t fnv1(const char *str)