Skip to content

Instantly share code, notes, and snippets.

@cbilski
cbilski / level_objective_widget.rb
Created July 28, 2021 14:15
A work in progress level objective dialog for Helicorps
class LevelObjectiveWidget
#
# Initialize Widget
#
def initialize
@finished = false
end
#
# Process input from args
@cbilski
cbilski / render_text.rb
Created July 28, 2021 03:03
A lazy way to wrap strings in dragonruby.
# This breaks when the characters no longer fit on the line. A smarter version would iterate using word/line boundaries
# Sample Usage:
# rect = args.layout.rect(row: 3, col: 12, w: 6, h: 7, dx: 0, dy: 0) # OBJECTIVE
# text = "OBJECTIVE:\n\nMECHs are threatening\nour CITIZENS:\n+ Bring the CITIZENS home.\n+ Destroy the MECHs."
# render_text(args, args.outputs.primitives, rect, text, 1, "/fonts/PixeloidSans.ttf")
#
def render_text(args, pipeline, rect, text, font_size, font)
work = ""
len = text.length
font_h = args.gtk.calcstringbox(text, font_size, font).y
@cbilski
cbilski / Sfx.rb
Created February 15, 2021 20:06
A sample sound effects class for DragonRuby
class Sfx
def initialize(args)
@args = args
@music_mast = 0.5
@sfx_mast = 0.5
end
def stop(sound_id)
if @args.audio.key?(sound_id)
@args.audio.delete(sound_id)