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 / shared_controller.rb
Created June 7, 2025 00:05
two controllers, one game
class SharedKeyDown
attr :args
def inputs
@args.inputs
end
def start
inputs.controllers.any? { |c| c.key_down.start }
end
@amirrajan
amirrajan / main.rb
Created June 5, 2025 03:20
Cutscene in DragonRuby
# creation of a game class
class Game
attr_gtk # adds arg properties to the class
def initialize
# have the hero start at the center and the npc be at the far right
@hero = { x: 640,
y: 360,
w: 80,
h: 80,
@amirrajan
amirrajan / main.rb
Last active June 3, 2025 22:57
camera with rotation matrix and circle based collision
class Game
attr_gtk
def initialize
@player = { x: 30,
y: -16,
w: 32,
h: 32,
dx: 0,
dy: 0,
@amirrajan
amirrajan / tmux.conf
Created May 20, 2025 20:22
tmux for windows (specifically clipboard)
# ~/.tmux.conf
# * brew install tmux reattach-to-user-namespace
# * C-e - Your leader <l> key.
# * <l>: - Type command not handled by shortcut keys. Eg: <l>: kill-pane ENT
# * <l>r - Reload this file/config.
# * <l>j - Select split using number jump list.
# * <l>{ - Swap splits left.
# * <l>} - Swap splits right.
# * <l>| - Create vertical split.
# * <l>- - Create orizontal split.
@amirrajan
amirrajan / .minttyrc
Created April 30, 2025 03:01
git bash minttyrc for windows
CtrlShiftShortcuts=yes
Font=Dank Mono
FontHeight=14
Black=31,33,39
Blue=77,156,238
BrightBlack= 31,33,39
BrightBlue= 77,156,238
BrightCyan= 68,168,182
BrightGreen= 134,187,98
BrightMagenta= 185,89,216
@amirrajan
amirrajan / main.rb
Created April 24, 2025 00:08
DragonRuby Game Toolkit - Spinning labels as particles
class Game
attr_gtk
def initialize
# keeps track of particle states
@particles ||= []
# keeps track of whether a render target for the specific number
# has been created already
@created_prefabs ||= {}
@amirrajan
amirrajan / readme.org
Last active May 23, 2025 06:51
DragonRuby primer for Lua game devs (Love2D)

Lua is a great language. Whenever someone asks me how they can get started with game dev, I immediately point them to Lua and PICO8. The simplicity of Lua comes with a potential downside. As your skills as a coder grows, you’ll begin to hit the language’s limitations. Lua is something you’ll eventually outgrow.

When you feel like you’re hitting the limits of the Lua, consider Ruby as your next goal. The syntax will come naturally to you given that you’ve used Lua.

Functions

@amirrajan
amirrajan / HotKeys.lua
Created April 16, 2025 14:18
hammer spoon ctrl+t to swap bettween windows
require("hs.ipc")
hs.hotkey.bind({'ctrl'}, "t", function()
app_name = hs.application.frontmostApplication():name()
if app_name == 'Alacritty' then
hs.osascript.applescript('tell application "Chrome" to activate')
else
hs.osascript.applescript('tell application "Alacritty" to activate')
end
end)
@amirrajan
amirrajan / WindowsManagement.lua
Created April 16, 2025 13:53
Hammer Spoon windows management
require("hs.ipc")
--- ==========================================
--- Window Management
--- ==========================================
-- ctrl+option+left resizes window to left half of screen
hs.hotkey.bind({'ctrl', 'option'}, "Left", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
@amirrajan
amirrajan / .zshrc
Created April 15, 2025 22:31
ZSH vim mode
set -o vi
# =====================
# vi mode
# =====================
bindkey -v
export KEYTIMEOUT=1
# =====================
# Change cursor shape for different vi modes.