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
# repetition specifies:
# token |   description        |
# ------+----------------------+
# $(),  | each comma delemited |
# $():, | each kwarg delemited |
# $()*  | each                 |
#
# intrinsic macros
# $to_s!
commit 9de4eae6fcc85bf6aa34521ace7bef762696a0cb
Author: Amir Rajan <[email protected]>
Date: Sat May 24 00:54:18 2025 -0500
[mRuby] Applied patch from upstream to allow for endless methods w/o parens and heredoc overflow fix.
commit 07c847027875a955ba64d3c84f8f456e96155b31 (HEAD)
Author: Yukihiro "Matz" Matsumoto <[email protected]>
Date: Tue May 18 16:26:36 2021 +0900
@amirrajan
amirrajan / main.rb
Created October 31, 2025 05:55
DragonRuby - Fiber Animation
class MoveOrchestration
attr :camera_center, :camera_scale
def initialize(probe:, celestial_body:)
@probe = probe
@celestial_body = celestial_body
@fiber = build_fiber
@camera_center = { x: @probe.x, y: @probe.y }
@camera_scale = 1.5
end
@amirrajan
amirrajan / init.el
Created October 30, 2025 17:23
Emacs - Doom Mode Line and Nerd Icons
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1))
(use-package nerd-icons
:ensure t
:custom
(nerd-icons-font-family "Symbols Nerd Font Mono"))
(use-package nerd-icons-completion
@amirrajan
amirrajan / main.rb
Last active October 24, 2025 13:11
DragonRuby Game Toolkit - Definitely not Wordle
class Game
attr_gtk
GREEN = { r: 98, g: 140, b: 84 }
YELLOW = { r: 177, g: 159, b: 54 }
GRAY = { r: 64, g: 64, b: 64 }
def initialize
# get the list of words that can be inputed
@valid_words = GTK.read_file("data/valid.txt")
@amirrajan
amirrajan / main.rb
Last active October 21, 2025 12:59
DragonRuby Game Toolkit - Parry 33
class Game
attr_gtk
def initialize
@clock = 0
@clock_debounce = 0
@player = { x: 640 - 64,
y: 72 - 64,
w: 128,
h: 128,
@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