Last active
November 22, 2022 01:51
-
-
Save brettchalupa/10a6835f377c7378415afe1cda0a2bc5 to your computer and use it in GitHub Desktop.
DragonRuby GTK PadBud Source r1
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
PADDING = 20 | |
def tick args | |
args.outputs.background_color = [255, 255, 255] | |
args.outputs.labels << [PADDING, args.grid.h - PADDING, 'PadBud', 3] | |
args.outputs.labels << [PADDING, args.grid.h - PADDING * 3, 'A simple tool for viewing DragonRuby gamepad input.'] | |
args.outputs.labels << [PADDING, 140, 'Platform Details', 2] | |
args.outputs.labels << [PADDING, 110, "OS: #{args.gtk.platform}"] | |
args.outputs.sprites << { x: PADDING + 80, y: args.grid.h - PADDING - 28, h: 32, w: 32, path: "metadata/icon.png" } | |
["one", "two", "three", "four"].each_with_index do |slot, i| | |
i += 1 | |
controller = args.inputs.send("controller_#{slot}") | |
str = "Controller #{i} connected? #{controller.connected}" | |
if controller.connected | |
truthy_keys = controller.key_held.truthy_keys | |
str += " " | |
if truthy_keys.any? | |
str += "Pressed buttons: #{truthy_keys}" | |
else | |
str += "No pressed buttons" | |
end | |
end | |
args.outputs.labels << [PADDING, args.grid.h - PADDING - PADDING * 3 - (i * 32), str] | |
end | |
args.outputs.debug << [args.grid.w - PADDING * 1.5, args.grid.h - PADDING / 2, "#{args.gtk.current_framerate}", 150, 150, 150].label | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@computer045 thanks again, just updated with that change. Much cleaner!