Skip to content

Instantly share code, notes, and snippets.

View emdeeeks's full-sized avatar

Gareth Griffiths emdeeeks

View GitHub Profile
@KonnorRogers
KonnorRogers / dungeon.rb
Created September 14, 2025 01:14
shadowcasting
module Dungeon
# Multipliers for transforming coordinates into other octants
MULT = [
[1, 0, 0, -1, -1, 0, 0, 1],
[0, 1, -1, 0, 0, -1, 1, 0],
[0, 1, 1, 0, 0, -1, -1, 0],
[1, 0, 0, 1, -1, 0, 0, -1],
]
# Determines which co-ordinates on a 2D grid are visible
@amirrajan
amirrajan / 00_preview.md
Created August 6, 2025 21:54
DragonRuby Game Toolkit - Rinoa Final Fantasy 8
riona-720p.mp4
@KonnorRogers
KonnorRogers / dr.rb
Last active December 17, 2025 16:39
Label wrapping
# Sample from:
# https://docs.dragonruby.org/#/samples/rendering-basics?id=labels-text-wrapping-mainrb
def tick(args)
lines = ["line1", "line2", "line3", "line4"]
labels = lines.map.with_index do |text, index|
{
x: 1280 / 2,
y: 720 / 2,
text: text,
anchor_y: index
@amirrajan
amirrajan / main.rb
Created June 18, 2025 06:41
DragonRuby Game Toolkit - Fifteen Puzzle Game version 2.0
class Game
attr_gtk
def initialize
# rng is sent to Random so that everyone gets the same levels
@rng = Random.new 100
@solved_board = (1..16).to_a
# rendering size of the cell
@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
Last active June 9, 2025 22:56
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 / main.rb
Last active June 9, 2025 23:01
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 9, 2025 00:22
DragonRuby Game Toolkit - Endurance The Probe
class Game
attr_gtk
def current_level_name
# used by level editor to figure out which data file to save/load
state.levels[state.current_level_index] || :todo
end
# helper method to move rect within the camera
def to_screen_space target
@julianrubisch
julianrubisch / main.rb
Last active December 23, 2025 13:48
DragonRuby "Async" Multiplayer Sync via HTTP
class Game < HttpRouter
def initialize(players: [])
@players = players
@http_debounce = 0
route do |routes|
@players.each do |player|
routes.get "/#{player.id}/progress" do |req|
if @current_scene_name == :host_scene
req.respond 200, "{ \"progress\": #{player.progress} }"
@amirrajan
amirrajan / main.rb
Created January 15, 2025 14:01
Legion Story Progression Concept
class Probe
def queue_story!(predicate: nil, entries:, completion_action: nil, completion_checkpoint:, completion: nil)
raise "Either completion_action or completion must be provided." if !completion_action && !completion
return if @action == :story
return if @current_story_items.length > 0
return if checkpoint_reached?(completion_checkpoint)
should_queue = if predicate.is_a? Proc
predicate.call
elsif predicate.is_a? FalseClass