Skip to content

Instantly share code, notes, and snippets.

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
Last active Apr 25, 2022
DragonRuby Game Toolkit Boss Battle Sample App
View main.rb
class Game
attr_gtk
def tick
defaults
input
calc
render
end
@amirrajan
amirrajan / main.rb
Created Apr 18, 2022
The Ensign: Star Gazer Cutscene
View main.rb
module TE
class StarGazerCutscene < Cutscene
def width_height
[60, 27]
end
def mid_point
[29, 29]
end
@amirrajan
amirrajan / 01_main.rb
Last active May 7, 2022
DragonRuby Game Toolkit: Loading an OBJ file and rendering triangles.
View 01_main.rb
def tick args
args.grid.origin_center!
args.state.triangles ||= read_obj 'models/mario.obj'
movement_multiplier = 1000
args.outputs.labels << { x: 0,
y: 30.from_top,
text: "W,A,S,D to move. Mouse to look. Triangles is a Indie/Pro Feature and will be ignored in Standard.",
alignment_enum: 1 }
@amirrajan
amirrajan / init.el
Created Apr 2, 2022
Emacs add_advice for company-mode
View init.el
(use-package company
:ensure t
:config
(defun amir-company-set-selection-callback (orig-fun &rest args)
(setq amir-company-something-selected 't)
(let ((res (apply orig-fun args)))
res))
(advice-add 'company-set-selection :around #'amir-company-set-selection-callback)
@amirrajan
amirrajan / nokia.rb
Created Feb 11, 2022
DragonRuby Game Toolkit Nokia Emulation
View nokia.rb
# Emulation of a 64x64 canvas. Don't change this file unless you know what you're doing :-)
# Head over to main.rb and study the code there.
NOKIA_WIDTH = 84
NOKIA_HEIGHT = 48
NOKIA_ZOOM = 12
NOKIA_ZOOMED_WIDTH = NOKIA_WIDTH * NOKIA_ZOOM
NOKIA_ZOOMED_HEIGHT = NOKIA_HEIGHT * NOKIA_ZOOM
NOKIA_X_OFFSET = (1280 - NOKIA_ZOOMED_WIDTH).half
NOKIA_Y_OFFSET = ( 720 - NOKIA_ZOOMED_HEIGHT).half
@amirrajan
amirrajan / main.rb
Last active Feb 17, 2022
DragonRuby Game Toolkit - Shadows (https://amirrajan.itch.io/shadows)
View main.rb
class Game
attr_gtk
def tick
defaults
input
calc
render
end
@amirrajan
amirrajan / town_event.rb
Created Jan 12, 2022
town_event.rb DSL from A Dark Room
View town_event.rb
{
:start => {
:text => [
'a small suburb lays ahead, empty houses scorched and peeling.',
"broken streetlights stand, rusting. light hasn't graced this place in a long time."
],
:options => {
:enter => {
:next_scene => { 0.5 => :a1, 1 => :a2 }
},
@amirrajan
amirrajan / main.rb
Created Jan 5, 2022
DragonRuby Game Toolkit - Sand Simulation via Cellular Automata
View main.rb
class Elements
def initialize size
@size = size
@max_x_ordinal = 1280.idiv size
@element_lookup = {}
@elements = []
end
def add_element x_ordinal, y_ordinal
return nil if @element_lookup.dig x_ordinal, y_ordinal
@amirrajan
amirrajan / main.rb
Created Dec 28, 2021
Spirit of Akina built with DragonRuby Game Toolkit
View main.rb
# Copyright 2021 Scratchwork Development LLC. All rights reserved.
PI = 3.1415926
class Game
attr_gtk
def tick
defaults
render
@amirrajan
amirrajan / curltest.c
Created Nov 24, 2021 — forked from leprechau/curltest.c
example code using libcurl and json-c to post and parse a return from http://jsonplaceholder.typicode.com
View curltest.c
/**
* example C code using libcurl and json-c
* to post and return a payload using
* http://jsonplaceholder.typicode.com
*
* License:
*
* This code is licensed under MIT license
* https://opensource.org/licenses/MIT
*