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 / index.html
Created March 29, 2026 00:40
DragonRuby Fiddle Tutorial Format
<html>
<head>
<title>DragonRuby - Warp Drive Tutorial</title>
</head>
<body>
<h1>DragonRuby Game Toolkit - Warp Drive Tutorial</h1>
<div itemscope="itemscope" itemtype="tutorial-step" data-step-number="1">
<div itemscope="itemscope" itemtype="tutorial-text">
<h1>Traveling at Light Speed</h1>
@amirrajan
amirrajan / main.rb
Last active March 15, 2026 18:32
DragonRuby Game Toolkit - Circular Viewport/Minimap
def boot args
args.state = {}
end
def tick args
args.outputs.background_color = [30, 30, 30]
args.state.player ||= {
x: 640 - 32,
y: 360 - 32,
w: 64,
@amirrajan
amirrajan / main.rb
Created March 7, 2026 02:30
DragonRuby Game Toolkit - `Easing.smooth_stop` and `Numeric#lerp`
def boot args
args.state = {}
end
def tick args
# create 100 things and set the seed to a numeric value
# the seed will be used to create a delay for each thing when the up and down keys are pressed
args.state.things ||= 220.map do |i|
x_ordinal = i % 20
y_ordinal = i.idiv(20)
@amirrajan
amirrajan / main.rb
Last active February 14, 2026 05:14
DragonRuby Game Toolkit - Advanced Blendmodes
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
# Remove the pound sign and leading space for the properties below before publishing your game.
# devid=myname
# devtitle=My Name
# gameid=mygame
# gametitle=My Game
# version=0.1
# icon=metadata/icon.png
# === Flags available at all licensing tiers ===
@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!