Skip to content

Instantly share code, notes, and snippets.

@oeloeloel
oeloeloel / main.rb
Last active January 28, 2023 00:10
1nvader
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'
}
@oeloeloel
oeloeloel / main.rb
Created March 26, 2023 16:27
buffer pixel array data to persist across ticks
# 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
@oeloeloel
oeloeloel / main.rb
Last active June 22, 2023 14:44
Visualisation: DragonRuby built-in spline function
$gtk.reset
SPLINE = [
[0.0, 0.99, 0.99, 1.0]
]
def tick args
# duration of movement
args.state.duration = 4.seconds