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.sh
Created August 27, 2026 04:55
ed demonstration
echo hello world > hello-ed.txt
ed ./hello-ed.txt <<-S
%s/hello/hi
a
good bye
.
wq
S
@amirrajan
amirrajan / hello-world.hlsl
Last active August 15, 2026 04:45
gray scale shader
Texture2D tex_scene : register(t0, space2);
SamplerState sam_scene : register(s0, space2);
struct Input {
float4 tex_color : COLOR0;
float2 tex_coord : TEXCOORD0;
};
struct Output {
float4 frag_color : SV_Target;
Texture2D scene : register(t0, space2);
SamplerState sampler0 : register(s0, space2);
// Scalar uniforms passed from Ruby via `uniforms: [{ name:, value:, type: }, ...]`.
// Members must match the array order. Fragment uniform buffers live in space3
// (b registers) for SDL_shadercross HLSL.
cbuffer Uniforms : register(b0, space3) {
int tick_count;
float time;
};
@amirrajan
amirrajan / effects.frag.hlsl
Last active August 1, 2026 20:33
DragonRuby Game Toolkit - Uniforms Definition
Texture2D scene : register(t0, space2);
SamplerState sampler0 : register(s0, space2);
// Scalar uniforms passed from Ruby via `uniforms: [{ name:, value:, type: }, ...]`.
// Members must match the array order. Fragment uniform buffers live in space3
// (b registers) for SDL_shadercross HLSL.
cbuffer Uniforms : register(b0, space3) {
int tick_count;
float time;
};
@amirrajan
amirrajan / main.rb
Created July 30, 2026 10:33
DragonRuby Game Toolkit - Low Res Game with On Screen Joystick
class OnScreenGamepad
attr :inputs, :directional_vector, :directional_angle, :dpad_vector
def initialize inputs, side: :left
@side = side
@inputs = inputs
end
def tick
if finger
@amirrajan
amirrajan / main.rb
Last active July 30, 2026 14:45
Celeste Classic in DragonRuby Game Toolkit (WIP)
class Game
attr :camera
def initialize world_data
@world_data = world_data
@player = Player.new @world_data.player.ordinal_x,
@world_data.player.ordinal_y
@tiles = @world_data.tiles
@walls = @world_data.walls
@spikes = @world_data.spikes
@amirrajan
amirrajan / finalize-auto.rb
Created June 28, 2026 11:55
Chopping up a sprite sheet with ruby
#!/usr/bin/env ruby
require "optparse"
require "tty-prompt"
require_relative "lib"
ARGV.delete("--")
options = {}
OptionParser.new do |opts|
@amirrajan
amirrajan / main.rb
Created June 17, 2026 14:27
DragonRuby Game Toolkit - freeze frame
# Copyright 2025 Scratchwork Development LLC. All right reserved.
require 'app/command.rb'
require 'app/command_button.rb'
require 'app/location_button.rb'
require 'app/player_slash.rb'
require 'app/player_stab.rb'
require 'app/player_air_slash.rb'
require 'app/player_lightning.rb'
require 'app/player_move.rb'
@amirrajan
amirrajan / cmake-1.sh
Last active June 13, 2026 03:56
Build LLVM MacOS
xcodebuild -version
brew install cmake
brew install ninja
rm -rf ./llvm-project
git clone --depth 1 --branch release/19.x git@github.com:llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake ../llvm \
-DCMAKE_BUILD_TYPE=Release \
@amirrajan
amirrajan / main.sh
Created June 5, 2026 23:36
DragonRuby Game Toolkit - download all the things for Android and deploy apk
cd YOUR_DR_DIRECTORY
# ============================================
# Download command line tools
# ============================================
rm -rf ./.android
mkdir ./.android
wget --directory-prefix=./.android https://dl.google.com/android/repository/commandlinetools-mac-7583922_latest.zip
cd ./.android
unzip -o ./commandlinetools-mac-7583922_latest.zip