Added some screenshot functionality on ctrl+p
Also tidied up some vs code stuff
This commit is contained in:
parent
24718bc096
commit
3886790925
4 changed files with 35 additions and 4 deletions
8
🕹️cube-tube.code-workspace
Normal file
8
🕹️cube-tube.code-workspace
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "🕹️cube-tube"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
2
🕹️cube-tube/.vscode/launch.json
vendored
2
🕹️cube-tube/.vscode/launch.json
vendored
|
@ -8,7 +8,7 @@
|
||||||
"name": "Run Game",
|
"name": "Run Game",
|
||||||
"type": "node-terminal",
|
"type": "node-terminal",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"command": "${workspaceRoot}/../.dragonruby/dragonruby ${workspaceRoot}",
|
"command": "\"${workspaceRoot}/../.dragonruby/dragonruby\" \"${workspaceRoot}\"",
|
||||||
"windows": {
|
"windows": {
|
||||||
"command": "${workspaceRoot}/../.dragonruby/dragonruby.exe ${workspaceRoot}",
|
"command": "${workspaceRoot}/../.dragonruby/dragonruby.exe ${workspaceRoot}",
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,8 +10,31 @@ class SceneInstance
|
||||||
attr_reader :tick_in_background
|
attr_reader :tick_in_background
|
||||||
attr_accessor :reset_on_pop
|
attr_accessor :reset_on_pop
|
||||||
|
|
||||||
|
def screenshot(args)
|
||||||
|
screenshot_path = "../marketing-assets/screenshots/#{args.gtk.platform}"
|
||||||
|
now = Time.new
|
||||||
|
now_s = "#{now.year}-#{"#{now.month}".rjust(2, "0")}-#{"#{now.day}".rjust(2, "0")} at #{"#{now.hour}".rjust(2, "0")}.#{"#{now.min}".rjust(2, "0")}.#{"#{now.sec}".rjust(2, "0")}"
|
||||||
|
base_filename = "#{screenshot_path}/Screenshot - #{args.gtk.platform} - #{now_s}"
|
||||||
|
filename = "#{base_filename}.png"
|
||||||
|
count = 0
|
||||||
|
while !args.gtk.stat_file(filename).nil?
|
||||||
|
count += 1;
|
||||||
|
filename = "#{base_filename} (#{count}).png"
|
||||||
|
end
|
||||||
|
|
||||||
|
args.outputs.screenshots << {
|
||||||
|
x: 0, y: 0, w: args.grid.w, h: args.grid.h, # Which portion of the screen should be captured
|
||||||
|
path: filename, # Output path of PNG file (inside game directory)
|
||||||
|
# r: 255, g: 255, b: 255, a: 0 # Optional chroma key
|
||||||
|
}
|
||||||
|
|
||||||
|
args.gtk.notify!("Screenshot taken: '#{filename}'")
|
||||||
|
end
|
||||||
|
|
||||||
# called every tick of the game loop
|
# called every tick of the game loop
|
||||||
def tick(args) end
|
def tick(args)
|
||||||
|
screenshot(args) if args.inputs.keyboard.ctrl_p
|
||||||
|
end
|
||||||
|
|
||||||
# custom logic to reset this scene
|
# custom logic to reset this scene
|
||||||
def reset(args) end
|
def reset(args) end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Input
|
||||||
class << self
|
class << self
|
||||||
PRIMARY_KEYS = [:j, :z, :space]
|
PRIMARY_KEYS = [:j, :z, :space]
|
||||||
SECONDARY_KEYS = [:k, :x, :backspace]
|
SECONDARY_KEYS = [:k, :x, :backspace]
|
||||||
PAUSE_KEYS = [:escape, :p]
|
PAUSE_KEYS = [:escape]
|
||||||
BINDINGS = {
|
BINDINGS = {
|
||||||
primary: {
|
primary: {
|
||||||
keyboard: %i[j z space],
|
keyboard: %i[j z space],
|
||||||
|
@ -16,7 +16,7 @@ module Input
|
||||||
controller_one: %i[b]
|
controller_one: %i[b]
|
||||||
},
|
},
|
||||||
pause: {
|
pause: {
|
||||||
keyboard: %i[escape p],
|
keyboard: %i[escape],
|
||||||
controller_one: %i[start]
|
controller_one: %i[start]
|
||||||
},
|
},
|
||||||
rotate_left: {
|
rotate_left: {
|
||||||
|
|
Loading…
Reference in a new issue