ramp-collision.mp4
class Game
attr :args
def defaults
args.state.terrain ||= [
{ x: 0, y: 0, w: 128, h: 128, left_perc: 0, right_perc: 0.5 },
{ x: 128, y: 64, w: 128, h: 128, left_perc: 0, right_perc: 1.0 },
class Probe | |
def queue_story!(predicate: nil, entries:, completion_action: nil, completion_checkpoint:, completion: nil) | |
raise "Either completion_action or completion must be provided." if !completion_action && !completion | |
return if @action == :story | |
return if @current_story_items.length > 0 | |
return if checkpoint_reached?(completion_checkpoint) | |
should_queue = if predicate.is_a? Proc | |
predicate.call | |
elsif predicate.is_a? FalseClass |
# this file sets up the main game loop (no need to modify it) | |
# play game here: https://samples.dragonruby.org/samples/99_genre_lowrez/nokia_3310_snake/index.html | |
require "app/nokia_emulation.rb" | |
class Game | |
attr :args, :nokia_mouse_position | |
def tick | |
# create a new game on frame zero | |
new_game if Kernel.tick_count == 0 |
class Game | |
attr_gtk | |
# get solution for hanoi tower | |
# https://youtu.be/rf6uf3jNjbo | |
def solve count, from, to, other | |
solve_recur(count, from, to, other).flatten | |
end | |
# recursive function for getting solution |
class Game | |
attr :args | |
def initialize args | |
@args = args | |
end | |
def new_game(rng_seed) | |
puts "New Game: #{rng_seed}" | |
self.state ||= {} |
# representation of a game that has a healing mechanic | |
class Game | |
# game has access to args and hp | |
attr :args, :hp | |
# initialize game with 100 hp | |
def initialize | |
@hp = 100 | |
end |
def tick args | |
if Kernel.tick_count == 0 | |
r = read_obj_raw 'models/rinoa.obj' | |
end | |
args.grid.origin_center! | |
args.state.obj ||= read_obj_raw 'models/rinoa.obj' | |
args.state.triangles ||= read_obj 'models/rinoa.obj' | |
args.state.target_triangles_start ||= 0 | |
args.state.target_triangles_end ||= 952 |
class Game
attr :args
def defaults
args.state.terrain ||= [
{ x: 0, y: 0, w: 128, h: 128, left_perc: 0, right_perc: 0.5 },
{ x: 128, y: 64, w: 128, h: 128, left_perc: 0, right_perc: 1.0 },
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) |
class Game | |
attr :args | |
def defaults | |
args.state.terrain ||= [ | |
{ x: 0, y: 0, w: 128, h: 128, left_perc: 0, right_perc: 0.5 }, | |
{ x: 128, y: 64, w: 128, h: 128, left_perc: 0, right_perc: 1.0 }, | |
{ x: 256, y: 64, w: 128, h: 128, left_perc: 0.5, right_perc: 0 }, | |
{ x: 384, y: 64, w: 128, h: 128, left_perc: 0, right_perc: 0 }, | |
] |
class Game | |
attr_gtk | |
def tick | |
defaults | |
input | |
calc | |
render | |
end |