This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A small POC experiment with buttons (it doesn't attempt to solve all the problems) | |
# the button method implements behaviour for a three-state button | |
# it accounts for button "layers" that can be formed from multiple primitives | |
# it doesn't impose other constraints on the dev, so the dev is free to make | |
# the buttons any way they like. This code shows: | |
# • A button made from a basic rect and label (with a bonus arbitrary rect for the active state) | |
# • A resizable button with rounded ends and a 2 pixel outline (1 label, 6 sprites) | |
def tick args | |
args.outputs.background_color = {r: 88, g: 124, b: 204} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$gtk.reset | |
SPLINE = [ | |
[0.0, 0.99, 0.99, 1.0] | |
] | |
def tick args | |
# duration of movement | |
args.state.duration = 4.seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# buffer pixel array data to persist across ticks | |
def tick args | |
dimension = 100 # keep it small and let the GPU scale it when rendering the sprite. | |
if args.tick_count.zero? | |
# Set up our "parray" pixel array and fill it with black pixels. | |
args.pixel_array(:parray).width = dimension | |
args.pixel_array(:parray).height = dimension | |
args.pixel_array(:parray).pixels.fill(0xFFFFFFFF, 0, dimension * dimension) # black, full alpha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tick(args) | |
args.state.game_state ||= 'playing' | |
args.state.player ||= { | |
x: 100, y: 40, w: 80, h: 80, angle: 90, | |
path: 'sprites/circle/blue.png' | |
} | |
args.state.player_bullet ||= { | |
x: 130, y: 800, w: 20, h: 20, | |
path: 'sprites/triangle/equilateral/blue.png' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AnObject | |
attr_reader :a, :b, :c, :d, :e, :f | |
def initialize | |
@a = 1 | |
@b = 1 | |
@c = 1 | |
@d = 1 | |
@e = 1 | |
@f = 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# supersampling for fancy sprite rotation | |
# solves uneven rotation of odd-sized sprites | |
# using an upscaled render target | |
def tick(args) | |
args.state.size ||= 7 # width/height of sprite (odd) | |
args.state.upsample ||= 8 # 2 minimum, 8 is better | |
args.state.path ||= 'sprites/rotate5.png' # path to sprite | |
args.state.upsample_size ||= args.state.size * args.state.upsample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cromakey no chromakey | |
# removes a specified background colour from a spritesheet | |
# by making it transparent and exports it as a new file. | |
# change these values then run in DragonRuby | |
# path to spritesheet | |
INPUT_FILE = '/sprites/chroma-test-input.png' | |
# path to export file | |
OUTPUT_FILE = '/sprites/chroma-test-output.png' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$gtk.reset | |
def tick args | |
defaults args | |
handle_input args | |
calc args | |
render args | |
end | |
def handle_input args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
DragonRuby C Extension Pixel Array | |
Written by @Akzidenz-Grotesk (with help from @AlexDenisov & @Kenneth | CANICVS) | |
Demonstrates some quick and pretty dirty image filters | |
Loads image files into Pixel Array | |
Performs image manipulation every tick | |
Returns a modified 100x100 pixel image to DragonRuby | |
*/ | |
#ifndef NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bresenham circle for DragonRuby (basic) | |
RED = [255, 0, 0] | |
def put_pixel(args, x, y, c) | |
args.outputs.solids << [x, y, 1, 1, *c] | |
end | |
def drawCircle(args, xc, yc, x, y) | |
put_pixel(args, xc + x, yc + y, RED) |
NewerOlder