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 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 April 24, 2025 05:43
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 ease of picking up Lua comes from the language’s limitations. It’s something you’ll eventually outgrow as you gain experience with game dev.

When you feel like you’re hitting the limits of the language, consider Ruby as your next goal. The syntax will come naturally to you given that you’ve used Lua, but Ruby’s skill ceiling is very high (I myself have used it for over a decade and it’s served me well).

@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.
# ~/.oh-my-zsh/custom/themes/amirrajan.zsh-theme
# https://github.com/blinks zsh theme
function _prompt_char() {
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
echo "%{%F{blue}%}±%{%f%k%b%}"
else
echo ' '
fi
}
@amirrajan
amirrajan / .tmux.conf
Created April 15, 2025 19:13
Tmux config 5/15/2025
# ~/.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 / 00_preview.md
Last active April 6, 2025 07:14
DragonRuby Game Toolkit - Beakers with liquids

beaker

@amirrajan
amirrajan / main.rb
Last active March 30, 2025 06:48
DragonRuby Game Toolkit: Slay the Card Game Example
class Game
attr_gtk
attr :enemy
def tick
defaults
calc
render
end
@amirrajan
amirrajan / main.rb
Created March 25, 2025 23:33
DragonRuby Game Toolkit - Dual Stick Shooter with keyboard and analog support.
class Game
attr_gtk
def defaults
state.player ||= { x: 640,
y: 360,
w: 80,
h: 80,
dx: 0,
dy: 0,