26 Year Old Quake Lighting on Hue Mar 27 2022

Here’s a short video demonstrating a small project I recently worked on. The objective was to take the 26 year old light flickering code from the original Quake (also used in Half-Life, Half-Life 2, Portal 2 and Half-Life Alyx). Last year it made the news after some folk synced up videos of the lighting in each game and found the flickering matched exactly.

26 Year Old Quake Lighting on Hue

Converting the code started by pulling the original lighting patterns from the Quake Source Code and converting it into C# for my little WinForms app.

private readonly Dictionary<string, string> _lightDict = new Dictionary<string, string>
    { "normal", "m" },
    { "FLICKER (first variety)", "mmnmmommommnonmmonqnmmo" },
    { "SLOW STRONG PULSE", "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba" },
    { "CANDLE (first variety)", "mmmmmaaaaammmmmaaaaaabcdefgabcdefg" },
    { "FAST STROBE", "mamamamamama" },
    { "GENTLE PULSE 1", "jklmnopqrstuvwxyzyxwvutsrqponmlkj" },
    { "FLICKER (second variety)", "nmonqnmomnmomomno" },
    { "CANDLE (second variety)", "mmmaaaabcdefgmmmmaaaammmaamm" },
    { "CANDLE (third variety)", "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa" },
    { "SLOW STROBE (fourth variety)", "aaaaaaaazzzzzzzz" },
    { "FLUORESCENT FLICKER", "mmamammmmammamamaaamammma" },
    { "SLOW PULSE NOT FADE TO BLACK", "abcdefghijklmnopqrrqponmlkjihgfedcba" },
    { "testing", "a" }

From there I simply added a ComboBox with the options, a Setup button (to make a connection with my Hue Bridge) and a Start/Stop button to control the flickering.

The characters represent the flickering pattern, e.g. ‘mmmaaaabcdefgmmmmaaaammmaamm’ is ‘Candle (second variety)’ which ultimately gets converted into a number between 0 and 255 which is sent to my study Hue light as a brightness value allowing it to work with any colour.

It turns out that it’s hard to make a decent quality video when you want to show something on the screen and room lighting!

Playing Duke Nukem 3D in 2022 Mar 15 2022

Duke Nukem 3D was released in 1996 and sits amongst the top first person shooters of its time alongside games like Quake, Doom, etc. It is also known for the game engine under the hood called ‘Build’ which has been used as recently as 2019 for Ion Fury.

Playing it in 2022 turns out to be straight-forward. All you need is a…

  • Legal copy of the game (GOG, Steam, Disks, etc.) so you have access to the files DUKE3D.GRP and DUKE.RTS files
  • Download EDuke32, a source port of the original and extract it
  • Optionally the Duke Nukem 3D: High Resolution Pack also extracted (but bin their shareware versions of DUKE3D.GRP and DUKE.RTS)

And Voilà, that’s it!

Duke32 away.

Aged pretty well gameplay wise.

Microsoft SQL Loading Large Dataset Mar 13 2022

Lately I’ve been loading large datasets into Microsoft SQL (MSSQL) and found the quickest way to do so is using BULK INSERT, even from .NET (instead of SqlBulkCopy for example). Chatting to people, it seems not many knew you could load data straight into MSSQL from a file using this, so I thought I’d write it up.

In my example I’ve downloaded a 5 million row CSV from this neat source and used the following command to load it into my local MSSQL server.

Using this table…

CREATE TABLE [dbo].[load_5mSalesRecords](
	[Region] [varchar](64) NOT NULL,
	[Country] [varchar](64) NOT NULL,
	[ItemType] [varchar](32) NOT NULL,
	[SalesChannel] [varchar](16) NOT NULL,
	[OrderPriority] [varchar](1) NOT NULL,
	[OrderDate] [varchar](16) NOT NULL,
	[OrderID] [int] NOT NULL,
	[ShipDate] [varchar](16) NOT NULL,
	[UnitsSold] [varchar](8) NOT NULL,
	[UnitPrice] [numeric](6, 2) NOT NULL,
	[UnitCost] [numeric](6, 2) NOT NULL,
	[TotalRevenue] [numeric](10, 2) NOT NULL,
	[TotalCost] [numeric](10, 2) NOT NULL,
	[TotalProfit] [numeric](10, 2) NOT NULL

followed by the BULK INSERT…

dbo.load_5mSalesRecords -- target table
'C:\Users\Jason\Desktop\5m Sales Records.csv' -- source file
, CODEPAGE='65001' -- Unicode (UTF-8)
, FIELDTERMINATOR = ',' -- csv so ,
, FIRSTROW=2 -- ignore header row

You’re able to load 5 million records in 20 seconds into the table.

Now, the gotcha (isn’t there always!) is that the file is relative to the SQL server and not the machine you’re running the command on. Which seems obvious when you say it but it does mean that if you’re writing an app that makes the file then both systems need to be able to access a shared folder. This is also true on Azure, but you’re able to use Azure Blob storage to get around it.

Count Castle Tilset Mar 11 2022

I’m releasing the tiles I created for Count Castle for anyone to use under the CC0 licence. It would be nice if credited but I’m easy.

Count Castle Tileset

Count Castle Tileset

Two New Games Feb 21 2022

I’ve recently finished two more games which I’ve forgotten to post about!

Night Forest

An attempt to create a small horror game

Count Castle

Tile based counting game for kids

Previous Page: 1 of 10 Next