Created
October 6, 2024 08:31
-
-
Save amirrajan/434dfcafe3ad95fceb07564e35cc5d8d to your computer and use it in GitHub Desktop.
DragonRuby Game Toolkit PowerPoint
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_intro args | |
[ | |
Layout.rect(row: 0, col: 12) | |
.merge(text: "DragonRuby Game Toolkit: Lessons Learned", | |
alignment_enum: 1, | |
vertical_alignment_enum: 1, | |
size_enum: 10, **white), | |
Layout.rect(row: 1, col: 12) | |
.merge(text: "Amir Rajan", **centered_white_label), | |
Layout.rect(row: 1.6, col: 12) | |
.merge(text: "t: @amirrajan", **centered_white_label), | |
Layout.rect(row: 2.2, col: 12) | |
.merge(text: "m: @[email protected]", **centered_white_label), | |
{ x: 640 - 100, y: 360 - 100, w: 200, h: 200, path: 'console-logo.png' }, | |
Layout.rect(row: 10, col: 12) | |
.merge(text: "Claim your free license at: dragonruby.itch.io.", | |
**centered_white_label) | |
] | |
end | |
def tick_top_rated args | |
tick_matrix_slide(args, | |
title: "Info and Rationale", | |
current_index: 0, | |
images: ["sprites/top-rated.png", | |
"sprites/games-on-itch.png", | |
"sprites/many-to-many-collisions.png", | |
"sprites/rendering-performance.png", | |
"sprites/binary-sizes.png"], | |
bottom_title: "One of the top rated game engines on Itch.io.", | |
bottom_subtitle: "(Ranks in Top 5 In Popular and Best Selling)") | |
end | |
def tick_games_on_itch args | |
tick_matrix_slide(args, | |
title: "Info and Rationale", | |
current_index: 1, | |
images: ["sprites/top-rated.png", | |
"sprites/games-on-itch.png", | |
"sprites/many-to-many-collisions.png", | |
"sprites/rendering-performance.png", | |
"sprites/binary-sizes.png"], | |
bottom_title: "400+ Games on Itch.io", | |
bottom_subtitle: "dragonruby.org/games-on-itch") | |
end | |
def tick_many_to_many args | |
tick_matrix_slide(args, | |
title: "Info and Rationale", | |
current_index: 2, | |
images: ["sprites/top-rated.png", | |
"sprites/games-on-itch.png", | |
"sprites/many-to-many-collisions.png", | |
"sprites/rendering-performance.png", | |
"sprites/binary-sizes.png"], | |
bottom_title: "5K Many To Many Collisions - DragonRuby: 60fps, Unity: 3fps") | |
end | |
def tick_render_limits args | |
tick_matrix_slide(args, | |
title: "Info and Rationale", | |
current_index: 3, | |
images: ["sprites/top-rated.png", | |
"sprites/games-on-itch.png", | |
"sprites/many-to-many-collisions.png", | |
"sprites/rendering-performance.png", | |
"sprites/binary-sizes.png"], | |
bottom_title: "Rendering 20K Moving Sprites - DragonRuby: 60fps, Unity: 9fps") | |
end | |
def tick_binary_sizes args | |
tick_matrix_slide(args, | |
title: "Info and Rationale", | |
current_index: 4, | |
images: ["sprites/top-rated.png", | |
"sprites/games-on-itch.png", | |
"sprites/many-to-many-collisions.png", | |
"sprites/rendering-performance.png", | |
"sprites/binary-sizes.png"], | |
bottom_title: "Binary Size - DragonRuby: 6.8mb, Unity: 59mb") | |
end | |
def tick_innovation args | |
[ | |
tick_matrix_slide(args, | |
title: "Info and Rationale", | |
current_index: 5, | |
images: ["sprites/top-rated.png", | |
"sprites/games-on-itch.png", | |
"sprites/many-to-many-collisions.png", | |
"sprites/rendering-performance.png", | |
"sprites/binary-sizes.png"]), | |
Layout.rect(row: 5, col: 12) | |
.merge(text: "Ruby Begets Innovation.", | |
**centered_white_label, | |
size_px: 60), | |
] | |
end | |
def tick_context args | |
args.state.local ||= { start_at: Kernel.tick_count } | |
frame_index = Numeric.frame_index(start_at: args.state.local.start_at, frame_count: 39, hold_for: 4) | |
frame_index ||= 38 | |
[ | |
Layout.rect(row: 0, col: 12) | |
.merge(text: "Context for Lessons Learned", | |
**align_center, | |
size_enum: 10, **white), | |
{ x: 640, y: 360, w: 320, h: 320, path: "sprites/magic/magic-#{frame_index + 1}.png", **align_center } | |
] | |
end | |
def tick_continuity_of_design args | |
[ | |
Layout.rect(row: 5, col: 12) | |
.merge(text: "The One Lesson To Rule Them All", | |
**align_center, | |
size_enum: 20, **white, | |
anchor_y: -0.5), | |
Layout.rect(row: 5, col: 12) | |
.merge(text: "Continuity of Design", | |
**align_center, | |
size_enum: 20, **white, | |
anchor_y: 0.5), | |
] | |
end | |
def tick_continuity_of_design_1 args | |
tick_matrix_slide args, | |
title: "The One Lesson To Rule Them All", | |
subtitle: "Continuity of Design", | |
current_index: 0, | |
images: ["sprites/build-deploy-0.png", | |
"sprites/build-deploy-1.png", | |
"sprites/build-deploy-2.png", | |
"sprites/build-deploy-3.png"] | |
end | |
def tick_continuity_of_design_2 args | |
tick_matrix_slide args, | |
title: "The One Lesson To Rule Them All", | |
subtitle: "Continuity of Design", | |
current_index: 1, | |
images: ["sprites/build-deploy-0.png", | |
"sprites/build-deploy-1.png", | |
"sprites/build-deploy-2.png", | |
"sprites/build-deploy-3.png"] | |
end | |
def tick_continuity_of_design_3 args | |
tick_matrix_slide args, | |
title: "The One Lesson To Rule Them All", | |
subtitle: "Continuity of Design", | |
current_index: 2, | |
images: ["sprites/build-deploy-0.png", | |
"sprites/build-deploy-1.png", | |
"sprites/build-deploy-2.png", | |
"sprites/build-deploy-3.png"] | |
end | |
def tick_continuity_of_design_4 args | |
tick_matrix_slide args, | |
title: "The One Lesson To Rule Them All", | |
subtitle: "Continuity of Design", | |
current_index: 3, | |
images: ["sprites/build-deploy-0.png", | |
"sprites/build-deploy-1.png", | |
"sprites/build-deploy-2.png", | |
"sprites/build-deploy-3.png"] | |
end | |
def tick_continuity_of_design_5 args | |
[ | |
tick_matrix_slide(args, | |
title: "The One Lesson To Rule Them All", | |
subtitle: "Continuity of Design", | |
current_index: 4, | |
images: ["sprites/build-deploy-0.png", | |
"sprites/build-deploy-1.png", | |
"sprites/build-deploy-2.png", | |
"sprites/build-deploy-3.png"]), | |
Layout.rect(row: 5, col: 12) | |
.merge(text: "Spectrum of solutions.", | |
**centered_white_label, | |
size_px: 60), | |
] | |
end | |
def tick_pdc_1 args | |
tick_matrix_slide(args, | |
title: "Progress Disclosure of Complexity", | |
current_index: -1, | |
images: ["sprites/primitives-0.png", | |
"sprites/primitives-1.png", | |
"sprites/primitives-2.png", | |
"sprites/primitives-3.png", | |
"sprites/nominal-cpp.png", | |
"sprites/nominal-1.png", | |
"sprites/nominal-0.png"]) | |
end | |
def tick_pdc_2 args | |
tick_matrix_slide(args, | |
title: "Progress Disclosure of Complexity", | |
current_index: 0, | |
images: ["sprites/primitives-0.png", | |
"sprites/primitives-1.png", | |
"sprites/primitives-2.png", | |
"sprites/primitives-3.png", | |
"sprites/nominal-cpp.png", | |
"sprites/nominal-1.png", | |
"sprites/nominal-0.png"]) | |
end | |
def tick_pdc_3 args | |
tick_matrix_slide(args, | |
title: "Progress Disclosure of Complexity", | |
current_index: 1, | |
images: ["sprites/primitives-0.png", | |
"sprites/primitives-1.png", | |
"sprites/primitives-2.png", | |
"sprites/primitives-3.png", | |
"sprites/nominal-cpp.png", | |
"sprites/nominal-1.png", | |
"sprites/nominal-0.png"]) | |
end | |
def tick_pdc_4 args | |
tick_matrix_slide(args, | |
title: "Progress Disclosure of Complexity", | |
current_index: 2, | |
images: ["sprites/primitives-0.png", | |
"sprites/primitives-1.png", | |
"sprites/primitives-2.png", | |
"sprites/primitives-3.png", | |
"sprites/nominal-cpp.png", | |
"sprites/nominal-1.png", | |
"sprites/nominal-0.png"]) | |
end | |
def tick_pdc_5 args | |
tick_matrix_slide(args, | |
title: "Progress Disclosure of Complexity", | |
current_index: 3, | |
images: ["sprites/primitives-0.png", | |
"sprites/primitives-1.png", | |
"sprites/primitives-2.png", | |
"sprites/primitives-3.png", | |
"sprites/nominal-cpp.png", | |
"sprites/nominal-1.png", | |
"sprites/nominal-0.png"]) | |
end | |
def tick_pdc_6 args | |
tick_matrix_slide(args, | |
title: "Progress Disclosure of Complexity", | |
current_index: 4, | |
images: ["sprites/primitives-0.png", | |
"sprites/primitives-1.png", | |
"sprites/primitives-2.png", | |
"sprites/primitives-3.png", | |
"sprites/nominal-cpp.png", | |
"sprites/nominal-1.png", | |
"sprites/nominal-0.png"]) | |
end | |
def tick_pdc_7 args | |
tick_matrix_slide(args, | |
title: "Progress Disclosure of Complexity", | |
current_index: 5, | |
images: ["sprites/primitives-0.png", | |
"sprites/primitives-1.png", | |
"sprites/primitives-2.png", | |
"sprites/primitives-3.png", | |
"sprites/nominal-cpp.png", | |
"sprites/nominal-1.png", | |
"sprites/nominal-0.png"]) | |
end | |
def tick_pdc_8 args | |
tick_matrix_slide(args, | |
title: "Progress Disclosure of Complexity", | |
current_index: 6, | |
images: ["sprites/primitives-0.png", | |
"sprites/primitives-1.png", | |
"sprites/primitives-2.png", | |
"sprites/primitives-3.png", | |
"sprites/nominal-cpp.png", | |
"sprites/nominal-1.png", | |
"sprites/nominal-0.png"]) | |
end | |
def tick_revolt args | |
args.state.local ||= { start_at: Kernel.tick_count } | |
hellno_frame_index = Numeric.frame_index(start_at: args.state.local.start_at, frame_count: 144, hold_for: 4) | |
hellno_frame_index ||= 143 | |
nope_frame_index = Numeric.frame_index(start_at: args.state.local.start_at, frame_count: 71, hold_for: 8) | |
nope_frame_index ||= 70 | |
[ | |
Layout.rect(row: 1, col: 12) | |
.merge(text: "But I use Ruby because it isn't Nominal Ruby!", | |
**centered_white_label, | |
size_px: 60), | |
{ x: 640 - 160, | |
y: 360, | |
w: 320, | |
h: 240, | |
path: "sprites/hellno/hellno-#{hellno_frame_index + 1}.png", | |
**align_center }, | |
{ x: 640 + 160, | |
y: 360, | |
w: 320, | |
h: 181, | |
path: "sprites/nope/nope-#{nope_frame_index + 1}.png", | |
**align_center } | |
] | |
end | |
def white | |
{ r: 255, g: 255, b: 255 } | |
end | |
def centered_white_label | |
{ alignment_enum: 1, vertical_alignment_enum: 1, size_enum: 4, **white } | |
end | |
def align_center | |
{ anchor_x: 0.5, anchor_y: 0.5 } | |
end | |
def tick_presentation args | |
args.outputs.background_color = [29, 31, 33] | |
if !args.state.scene.is_a? Numeric | |
args.state.scene = 0 | |
end | |
m = args.state.slides[args.state.scene] | |
if m | |
args.outputs.primitives << send(m, args) | |
end | |
end | |
def lerp_rect start_at, end_at, start_rect, end_rect | |
perc = Easing.smooth_stop(start_at: start_at, | |
end_at: end_at, | |
tick_count: Kernel.global_tick_count, | |
power: 2) | |
{ | |
x: start_rect.x.lerp(end_rect.x, perc), | |
y: start_rect.y.lerp(end_rect.y, perc), | |
w: start_rect.w.lerp(end_rect.w, perc), | |
h: start_rect.h.lerp(end_rect.h, perc), | |
} | |
end | |
def new_matrix_4_slide_state | |
{ | |
main_rect: Layout.rect(row: [2, 9], col: [5, 18]), | |
main_rect_alpha: 0, | |
shown_at: Kernel.global_tick_count, | |
rect_1: Layout.rect(row: 3, col: 0, w: 5, h: 3), | |
rect_2: Layout.rect(row: 6, col: 0, w: 5, h: 3), | |
rect_3: Layout.rect(row: 3, col: 19, w: 5, h: 3), | |
rect_4: Layout.rect(row: 6, col: 19, w: 5, h: 3), | |
} | |
end | |
def new_matrix_5_slide_state | |
{ | |
main_rect: Layout.rect(row: [2, 9], col: [5, 18]), | |
main_rect_alpha: 0, | |
shown_at: Kernel.global_tick_count, | |
rect_1: Layout.rect(row: 1.5, col: 0, w: 5, h: 3), | |
rect_2: Layout.rect(row: 4.5, col: 0, w: 5, h: 3), | |
rect_3: Layout.rect(row: 7.5, col: 0, w: 5, h: 3), | |
rect_4: Layout.rect(row: 3, col: 19, w: 5, h: 3), | |
rect_5: Layout.rect(row: 6, col: 19, w: 5, h: 3), | |
} | |
end | |
def new_matrix_6_slide_state | |
{ | |
main_rect: Layout.rect(row: [2, 9], col: [5, 18]), | |
main_rect_alpha: 0, | |
shown_at: Kernel.global_tick_count, | |
rect_1: Layout.rect(row: 1.5, col: 0, w: 5, h: 3), | |
rect_2: Layout.rect(row: 4.5, col: 0, w: 5, h: 3), | |
rect_3: Layout.rect(row: 7.5, col: 0, w: 5, h: 3), | |
rect_4: Layout.rect(row: 1.5, col: 19, w: 5, h: 3), | |
rect_5: Layout.rect(row: 4.5, col: 19, w: 5, h: 3), | |
rect_6: Layout.rect(row: 7.5, col: 19, w: 5, h: 3), | |
} | |
end | |
def tick_matrix_slide(args, title: nil, subtitle: nil, bottom_title: nil, bottom_subtitle: nil, current_index:, images:) | |
args.state.local ||= if images.length == 4 | |
new_matrix_4_slide_state | |
elsif images.length == 5 | |
new_matrix_5_slide_state | |
elsif images.length == 6 | |
new_matrix_6_slide_state | |
elsif images.length == 7 | |
new_matrix_6_slide_state | |
else | |
raise "Invalid number of images" | |
end | |
local = args.state.local | |
local.main_rect_alpha = local.main_rect_alpha.lerp(255, 0.05) | |
fade_out_alpha = if current_index >= images.length | |
255 | |
# 255 - local.main_rect_alpha * 2 | |
else | |
255 | |
end | |
title_rect = Layout.rect(row: 0, col: 12) | |
title_anchor_y = title && subtitle ? 0.0 : 0.5 | |
subtitle_anchor_y = title && subtitle ? 1.0 : 0.5 | |
moving_rect = if current_index >= 1 | |
lerp_rect(local.shown_at, | |
local.shown_at + 15, | |
local.main_rect, | |
local[:"rect_#{current_index}"]).merge(path: images[current_index], a: local.main_rect_alpha) | |
end | |
title_prefab = if title | |
title_rect.merge(text: title, | |
**align_center, | |
size_enum: 10, **white, | |
anchor_y: title_anchor_y) | |
end | |
subtitle_prefab = if subtitle | |
title_rect.merge(text: subtitle, | |
**align_center, | |
size_enum: 10, **white, | |
anchor_y: subtitle_anchor_y) | |
end | |
slide_prefabs = if current_index >= 0 | |
images.map.with_index do |image, i| | |
if i == current_index | |
local.main_rect.merge(path: image, a: local.main_rect_alpha) | |
elsif i == current_index - 1 | |
moving_rect.merge(path: image, a: fade_out_alpha) | |
elsif i <= current_index | |
local[:"rect_#{i + 1}"].merge(path: image, a: fade_out_alpha) | |
else | |
nil | |
end | |
end | |
else | |
[] | |
end | |
bottom_rect = Layout.rect(row: 10, col: 12) | |
bottom_title_anchor_y = bottom_title && bottom_subtitle ? 0.0 : 0.5 | |
bottom_subtitle_anchor_y = bottom_title && bottom_subtitle ? 1.0 : 0.5 | |
bottom_title_prefab = if bottom_title | |
bottom_rect.merge(text: bottom_title, | |
**centered_white_label, | |
anchor_y: bottom_title_anchor_y) | |
end | |
bottom_subtitle_prefab = if bottom_subtitle | |
bottom_rect.merge(text: bottom_subtitle, | |
**centered_white_label, | |
anchor_y: bottom_subtitle_anchor_y) | |
end | |
[ | |
title_prefab, | |
subtitle_prefab, | |
slide_prefabs, | |
bottom_title_prefab, | |
bottom_subtitle_prefab | |
] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment