Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dbechrd's full-sized avatar

Dan Bechard dbechrd

View GitHub Profile
#!/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
/*
Author: Dan Bechard
Date: November 2, 2010
Project: Stack class
Professor: Bo Kim
Course: CS217-A
*/
#include <iostream>
#include "MyStack.h"
@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
# 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
#!/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

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

#include <stdio.h>
#include "../../dlb/dlb_vector.h"
// NOTE: Have to store as offset rather than pointer in case vector reallocs. Could use block allocator but wutevs man.
typedef struct String {
size_t offset;
size_t length;
} String;
typedef enum TokenType {
///////////////////////////////////////////////////////
// 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,
// Copyright 2020 - Dan Bechard
// https://github.com/dbechrd
// License: Public Domain
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
// Lists all classes that inherit from Component in Unity's debug log
// Note: This uses C#'s run-time type introspection (i.e. "reflection"),
@dbechrd
dbechrd / event_system_pseudo.cpp
Last active May 25, 2020 16:40
Pseudocode for a very basic event system in a game engine
At a high level, events work as follows:
- Each type of event must have a unique name or ID (e.g. "user_joined_game")
- Each type of event may have additional metadata (e.g. the "user_joined_game" event will likely have a "user_id" in the metadata)
- Zero or more event handlers (in the form of callback function, also sometimes called "listeners" and owned by "subscribers") can be registered for each type of event. This can be done in many different ways, one way would be to have a central event manager that keeps track by having a list of subscribers for each type of event. In a more advanced implementation, you could also have filters (e.g. only send me "user_position_changed" events for "user_id = 5"). I would recommend starting with a simple boolean "handled" flag as a filter to start (see below).
- Zero or more places where an event is fired (also called "triggered", done by a "publisher").
- When an even is fired/triggered by a publisher, it goes into an event queue. Generally you'd have one portion of a