Skip to content

Instantly share code, notes, and snippets.

View dbechrd's full-sized avatar

Dan Bechard dbechrd

View GitHub Profile

RicoTech Engine (2016 - 2019)

Learning modern OpenGL. The first two quads I rendered on screen.

image

Five more quads (1 ground, 4 walls) added to scene. Added textures.

image

///////////////////////////////////////////////////////
// asset_watcher.h
///////////////////////////////////////////////////////
#pragma once
#include "SDL/SDL_thread.h"
#include "SDL/SDL_mutex.h"
typedef enum ta_watcher_result {
TA_WATCHER_SUCCESS = 0,
TA_WATCHER_ERR_INVALID_HANDLE = -1,
#!/bin/sh
###############################################################################
# Copyright 2021 - Dan Bechard
# Deletes a random line of code from a random source file to cause chaos. >:)
###############################################################################
# Directory where source files are kept
sourcedir="src"
# Directory depth to search
# OS generated files
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
#/[Bb]in
/[Oo]bj
@dbechrd
dbechrd / chunk_coords.md
Last active February 1, 2022 03:12
Calculate chunk/tile offset with negative coord support

https://gamedev.stackexchange.com/a/199172/24266

I just spent a while writing some code for my 2D game to do this that should work correctly with negative coordinates. I informally checked it against Minecraft's F3 debug menu's chunk offsets, as well as wrote a few simple unit tests that I've provided below.

If anyone knows of a way to simplify or optimize this algorithm, do please comment and let me know!

// Copyright 2022 by Dan Bechard
// Your choice of any the following licenses:
// - Public domain
/*
Author: Dan Bechard
Date: November 2, 2010
Project: Stack class
Professor: Bo Kim
Course: CS217-A
*/
#include <iostream>
#include "MyStack.h"
#!/usr/bin/env bash
###################################################################
#Author: Dan Bechard
# Date: May 9, 2013
# Desc: Displays status of all repositories in directory to allow
# the user to easily identify uncommited changes and pending
# commits on the remote.
###################################################################
# Root directory of where you store all of repos
@dbechrd
dbechrd / game_of_life.py
Created February 23, 2022 22:35
Game of Life
# Copyright 2022 Ben Groves & Dan Bechard @ Avvir.io
# MIT License
import os
import time
import random
from copy import deepcopy
def create_board(size):
board = [[0] * size for i in range(size)]
// Read file as binary, but append \0 to the end of the buffer
// filename: name of file to read
// buf : if file read successfully, this will be set to a pointer to the file contents on the heap
// len : if file read successfully, this will be set to the file length
// Returns 0 on success, negative error code on failure (see stderr for more info)
// WARN: you must free(buf) when you're done with it!!
int ta_file_read_all(const char *filename, char **buf, size_t *len)
{
assert(filename);
assert(buf);
@dbechrd
dbechrd / ini_parser.cpp
Created June 23, 2022 03:30
Simple INI parser
#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <vector>
struct buffer {
char *data;
int length;