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 February 8, 2026 23:31
DragonRuby Game Toolkit: render order demonstration
def tick args
# comment out each of these label options one at a time to see how it renders
args.outputs.labels << { x: 640,
y: Math.sin(Kernel.tick_count.to_radians).abs * 720,
r: 255, g: 0, b: 0,
text: "I will always be on top (regardless of position in the tick method)",
anchor_x: 0.5,
anchor_y: 0.5 }
# comment out each of these label options one at a time to see how it renders
@amirrajan
amirrajan / main.rb
Created February 8, 2026 23:17
DragonRuby Game Toolkit - Easing.spline
def tick args
zig_zag_spline = [
[0, 0.33, 0.66, 1],
[1, 0.66, 0.33, 0],
[0, 0.33, 0.66, 1],
[1, 0.66, 0.33, 0]
]
linear_down_spline = [
[1, 0.66, 0.33, 0]
@amirrajan
amirrajan / main.rb
Created January 27, 2026 06:43
DragonRuby Game Toolkit - custom blend modes -> ring progress bar
BLENDOPERATION_ADD = 0x1
BLENDOPERATION_SUBTRACT = 0x2
BLENDOPERATION_REV_SUBTRACT = 0x3
BLENDOPERATION_MINIMUM = 0x4
BLENDOPERATION_MAXIMUM = 0x5
BLENDFACTOR_ZERO = 0x1
BLENDFACTOR_ONE = 0x2
BLENDFACTOR_SRC_COLOR = 0x3
BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4
BLENDFACTOR_SRC_ALPHA = 0x5
@amirrajan
amirrajan / Program.cs
Last active January 7, 2026 21:52
.ToInt extension method
using System;
using System.Linq;
using System.Collections.Generic;
using static Sugar;
class Program
{
static void Main(string[] args)
{
if ("1111".ToInt() is int parsed)
# repetition specifies:
# token |   description        |
# ------+----------------------+
# $(),  | each comma delemited |
# $():, | each kwarg delemited |
# $()*  | each                 |
#
# intrinsic macros
# $to_s!
commit 9de4eae6fcc85bf6aa34521ace7bef762696a0cb
Author: Amir Rajan <ar@amirrajan.net>
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 <matz@ruby.or.jp>
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,