Skip to content

Instantly share code, notes, and snippets.

View BenMcLean's full-sized avatar

Benjamin McLean BenMcLean

View GitHub Profile
private void initialize() {
Coord.expandPoolTo(WIDTH+3, HEIGHT+3);
// Initialize the heightmap generator
ModuleFractal heightFractal = new ModuleFractal (ModuleFractal.FractalType.FBM,
ModuleBasisFunction.BasisType.GRADIENT,
ModuleBasisFunction.InterpolationType.QUINTIC);
heightFractal.setNumOctaves(terrainOctaves);
heightFractal.setFrequency(terrainFrequency);
heightFractal.setSeed(CommonRNG.getRng().between(0, Integer.MAX_VALUE));
ModuleFractal ridgedHeightFractal = new ModuleFractal (ModuleFractal.FractalType.RIDGEMULTI,
@BenMcLean
BenMcLean / ref.lua
Created November 9, 2017 20:27
"Assign by reference"-like behavior in Lua
ref=(function(obj,key)
return (function(...)
local p={...}
if select('#',...)==0 then
return obj[key]
else
obj[key]=p[1]
end
end)
end)
@BenMcLean
BenMcLean / cleanDist.ps1
Created November 29, 2017 23:19
Use BFG to strip out old web builds from my repositories that use Github Pages
param ($name)
Set-PSDebug -Trace 2
git clone --mirror https://github.com/BenMcLean/$name.git
java -jar bfg.jar --delete-folders dist "$name.git"
cd ./$name.git
git push
cd..
Remove-Item -Path "$name.git" -Recurse -Force
@BenMcLean
BenMcLean / TestApp.java
Last active October 6, 2018 04:40
Simple libGDX app
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.FitViewport;
@BenMcLean
BenMcLean / darkplaces.service
Last active October 25, 2018 03:03
darkplaces-server as a systemd service on Ubuntu
[Unit]
Description=This service spawns a Darkplaces Quake dedicated server.
# Place this file in /lib/systemd/system
# To enable this service to launch at boot time, enter in a terminal: systemctl enable darkplaces.service
# To disable this service from launching at boot time, enter in a terminal: systemctl disable darkplaces.service
# To check the state of all existing unit files, enter in a terminal: systemctl list-unit-files
# I followed these instructions to install Darkplaces, except for the parts about starting the dedicated server on boot because those parts don't work anymore: https://ubuntuforums.org/showthread.php?t=2095900
# I based this service on https://github.com/cdev-tux/q3lite/blob/ba3f578b0dc93f2af645724fad283e7484b8d77e/misc/q3lite/pi/q3lite_ded.service
[Service]
@BenMcLean
BenMcLean / VirtualBoyGo.ps1
Last active July 12, 2019 01:19
VirtualBoyGo powershell
<#
.SYNOPSIS
Downloads VirtualBoyGo source code
.DESCRIPTION
Gathers all dependencies and places them in the correct folders!
.NOTES
Author : Benjamin McLean mclean.ben@gmail.com
.LINK
https://github.com/CidVonHighwind/VirtualBoyGo
#>
@BenMcLean
BenMcLean / .gitconfig
Created February 14, 2019 22:53
apply-gitignore alias for Git
[alias]
                apply-gitignore = !git ls-files -ci --exclude-standard -z | xargs -0r git rm --cached
@BenMcLean
BenMcLean / get-state.bat
Last active July 27, 2019 18:17
Oculus Quest ADB stuff
@ECHO OFF
c:
cd %APPDATA%
cd ..\Local\Android\Sdk\platform-tools
adb get-state
// Pixelated font shader by lox9973
// It is a cutout shader, using alpha blending for 1 pixel antialiasing on the edges.
// Intended use is "3D Text" on an opaque object like a sign.
Shader "UI/PixelFont" {
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
// Below Transparent queue. Renders after the skybox, but writes to depth.
@BenMcLean
BenMcLean / lolwut.cpp
Last active September 28, 2020 21:19
Simple data structure that encapsulates an array in C++
#include <iostream>
using namespace std;
template <class T>
class lolwut // a lolwut is a simple encapsulated array
{
public:
lolwut() : data(NULL), size(0)
{