Fading Pillowcases Demo
Made in DragonRuby to get to know the engine.
def tick args
args.state.solids.faders ||= []
if args.inputs.mouse.down # Tracking mouse drag initial position…
args.state.inputs.mouse.held.point ||= args.inputs.mouse.down.point
end
if args.inputs.mouse.up # …and whether it's currently held.
args.state.inputs.mouse.held.point = nil
if args.state.solids.pillowcase # Making the current pillowcase a new fader.
args.state.solids.faders << args.state.solids.pillowcase
args.state.solids.pillowcase = nil
end
end
args.state.solids.faders.select! {|i| i[:a] > 1} # Culling the invisible faders.
args.state.solids.faders.each do |i| # Defining faders' lifecycle.
if i[:fresh] then i[:a] += 5 else i[:a] -= 1 end
if i[:a] > 254 then i[:fresh] = false end
end
args.outputs.solids << args.state.solids.faders
if args.state.inputs.mouse.held.point # Setting the current pillowcase.
args.state.solids.pillowcase = {
x: args.state.inputs.mouse.held.point.x,
y: args.state.inputs.mouse.held.point.y,
w: args.inputs.mouse.point.x - args.state.inputs.mouse.held.point.x,
h: args.inputs.mouse.point.y - args.state.inputs.mouse.held.point.y,
r: 255,
g: 0,
b: 0,
a: 55,
fresh: true
}
end
args.outputs.solids << args.state.solids.pillowcase
args.outputs.labels << [20, 20, 'Faders ' + args.state.solids.faders.size.to_s]
# To make sure they do in fact get culled and not just invisible.
end
Leave a comment
Log in with itch.io to leave a comment.