Skip to content

Instantly share code, notes, and snippets.

View amirrajan's full-sized avatar
💭
Working on DragonRuby Game Toolkit and RubyMotion

Amir Rajan amirrajan

💭
Working on DragonRuby Game Toolkit and RubyMotion
View GitHub Profile
@amirrajan
amirrajan / camera.rb
Last active October 24, 2026 18:39
DragonRuby Game Toolkit - Legion 4x (https://youtu.be/6Bpyh9iPJyM)
class Camera
class << self
def viewport_w
Grid.allscreen_w
end
def viewport_h
Grid.allscreen_h
end
@amirrajan
amirrajan / readme.org
Last active October 17, 2026 05:36
DragonRuby: I never wanted to create a game engine

1. The Success Trap

I never wanted to build a game engine. I’m an artist; for me, an engine was just a means to an end. But after four commercial releases, I realized I was losing the only edge I had as an indie: my time and my love of the craft. I got approval for the Nintendo Switch, and instead of celebrating, I felt dread. My initial mistake was using the “prescribed” tools for each target platform (the native frameworks the platform holders tell you to use). It’s vendor lock-in. To reach a new audience, I had to do a rewrite, every time. I wasn’t making art anymore; I was a full-time janitor for my own code.

2. The Strategy of the Widest Net

I knew that the success of my first title was synonymous to winning the lottery. I was honest enough with myself to admit it probably wouldn’t happen again. In an industry governed by hits, the only path to sustainability was to maximize exposure by casting the widest net possible from Day One: release to every available platform right out the gate.

I fel

For this kata you will be extending the Hash class to support a new method called 'flattened_keys'. The purpose of this method is to return a new hash that has any nested values flattened so that there is only the single root hash structure. The keys from the nested hash will be merged into the parent, separated by underscores.

Basic example:

unflat = {id: 1, info: {name: 'example'}}.flattened_keys unflat.flattened_keys # equals {id: 1, info_name: 'example'}

notice the info_name flattened key

The method should handle any level of nesting. For example:

unflat = {

@amirrajan
amirrajan / trace.md
Last active October 15, 2026 16:26
dotnet trace

just looking up some old notes.

dotnet tool install --global dotnet-trace
  1. get the process id for a current running process via powershell:
powershell -c "Get-CimInstance Win32_Process | Select-Object ProcessId, CommandLine | ConvertTo-Csv | Out-File ps -Encoding ASCII"

look at the file above and find the process id for processes that have ./dotnet.exe 2. You start the trace with:

@amirrajan
amirrajan / main.rb
Last active September 27, 2026 22:01
DragonRuby Game Toolkit - Multi-orientation, multi-platform, iPhone Duo (https://youtu.be/dXcsey7Pzmo)
# game concept from: https://youtu.be/Tz-AinJGDIM
# Color pallete for game
RED = { r: 222, g: 63, b: 66 }
GRAY = { r: 128, g: 128, b: 128 }
BLACK = { r: 0, g: 0, b: 0 }
LIGHT_GRAY = { r: 237, g: 237, b: 237 }
module Main
def start
@amirrajan
amirrajan / camera.rb
Created September 25, 2026 06:53
DragonRuby Game Toolkit - Live in-game map editor with AABB collision and camera. (https://youtu.be/N71tnzHuNq4)
class Camera
class << self
def viewport_w
Grid.allscreen_w
end
def viewport_h
Grid.allscreen_h
end
@amirrajan
amirrajan / go.sh
Last active October 23, 2026 18:25
java build benchmark thingy
#!/usr/bin/env bash
# git clone https://gist.github.com/amirrajan/0732e675346fca3ab4e7f19c01ad8806 benchmark-java-build && cd ./benchmark-java-build && sh ./go.sh
# Clone Kafka 4.0.2, fetch the benchmark script, and run it.
set -eu
git clone --depth 1 --branch 4.0.2 https://github.com/apache/kafka.git
cd kafka
@amirrajan
amirrajan / main.rb
Created September 22, 2026 04:37
DragonRuby Game Toolkit - Animation States Advanced
module Main
def start
@game = Game.new
end
def tick
@game.inputs = inputs
@game.tick
outputs.background_color = [30, 30, 30]
outputs.primitives << @game.primitives
@amirrajan
amirrajan / main.rb
Created September 13, 2026 21:01
DragonRuby Game Toolkit 7.0 - Many to Many Collisions (https://youtu.be/V7OXlAl1U3E)
# main entry point for the game
module Main
def start
# initialize the game and create 100 random squares
@squares = create_random_squares
end
def create_random_squares
# function creates 100 random squares
# that are within the bounds of the screen
@amirrajan
amirrajan / main.rb
Last active September 12, 2026 07:46
DragonRuby Game Toolkit - Water Ripples (https://youtu.be/NlAjjOEWPiM)
# https://www.youtube.com/watch?v=8rCRsOLiO7k
require "shaders/ripples.fragment.hlsl"
module Main
def start
@ripple_queue = []
end
def tick