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 / main.rb
Created October 12, 2025 19:03
DragonRuby Game Toolkit - Sprite Unpacker
# hacky AF
# abandon all hope ye who enter here
class Pixel
def self.abgr_to_h abgr
a = (abgr >> 24) & 0xff
b = (abgr >> 16) & 0xff
g = (abgr >> 8) & 0xff
r = (abgr >> 0) & 0xff
{ r: r, g: g, b: b, a: a }
end
@amirrajan
amirrajan / main.rb
Last active October 5, 2025 21:28
DragonRuby Game Toolkit - Verlet Integration (https://youtu.be/pW_pwP-CZas)
# https://www.youtube.com/watch?v=-GWTDhOQU6M
class Square
attr :x, :y, :w, :h,
:prev_x, :prev_y,
:acceleration_x, :acceleration_y,
:drag_x, :drag_y,
:radius,
:dx, :dy, :path, :start_acceleration_x, :start_acceleration_y
def initialize(x:, y:, w:, h:, radius:, start_acceleration_x:, start_acceleration_y:, drag_x:, drag_y:)
@amirrajan
amirrajan / 00_preview.md
Last active October 2, 2025 13:41
DragonRuby Game Toolkit - Toggle Switch
toggle-switch-720p.mp4
@amirrajan
amirrajan / main.rb
Last active October 1, 2025 18:45
DragonRuby Game Toolkit: Toggle Button Example
class ToggleButton
attr :on_off
def initialize(x:, y:, w:, h:, on_off:, button_text:, on_click:)
@x = x
@y = y
@w = w
@h = h
@on_off = on_off
@button_text = button_text
@amirrajan
amirrajan / main.rb
Created September 4, 2025 22:08
DragonRuby Game Toolkit - Star Perf Revisited
# Sprites represented as Hashes using the queue ~args.outputs.sprites~
# code up, but are the "slowest" to render.
# The reason for this is the access of the key in the Hash and also
# because the data args.outputs.sprites is cleared every tick.
def random_x
rand * $grid.w * -1
end
def random_y
@amirrajan
amirrajan / main.rb
Created August 30, 2025 23:50
DragonRuby Game Toolkit - Square Fall (Mult-orientation and Edge to Edge rendering) https://youtu.be/r1IrTdEUE0o
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 }
def boot args
args.state = {}
end
def tick args

Nissan Motors, and Their Crappy U.S. Made Transmissions

This is a work of fiction. Names, characters, places and incidents either are products of the author’s imagination or are used fictitiously. Any resemblance to actual events or locales or persons or companies (or anything else not explicity stated in this ridiculous disclaimer), living or dead, is entirely coincidental.

In the 1960’s, Nissan Motors expanded its market to the United States. In doing so, a portion of parts were to be built on American soil. Around this same time period, automotive innovation was in full force. Specifically with regard to automatic transmissions. An extremely bright team of American and Japanese engineers got together and spec’d out the first line of automatic transmissions to be used in Nissan automobiles.

The specifications for the new automatic transmissions were sent to the production lines in the United States and Japan. The transmissions were complex, 863 unique parts needed to be assembled for this incredible piec

@amirrajan
amirrajan / main.rb
Created August 7, 2025 07:02
DragonRuby Game Toolkit: Easing Fubar
def tick args
duration = 120
args.state.after_image_queue ||= []
args.state.start_at = if Kernel.tick_count == 0
0
elsif Kernel.tick_count.zmod?(duration.idiv(2))
args.state.start_at + duration.idiv(2)
else
args.state.start_at
end
@amirrajan
amirrajan / 00_preview.md
Last active August 7, 2025 01:42
DragonRuby - Cube World
cube-world-720p.mp4
@amirrajan
amirrajan / 00_preview.md
Created August 6, 2025 21:54
DragonRuby Game Toolkit - Rinoa Final Fantasy 8
riona-720p.mp4