This file contains hidden or 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
class Game | |
attr_gtk | |
def initialize | |
@player = { x: 30, | |
y: -16, | |
w: 32, | |
h: 32, | |
dx: 0, | |
dy: 0, |
This file contains hidden or 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
class Game | |
attr_gtk | |
attr :enemy | |
def tick | |
defaults | |
calc | |
render | |
end |
This file contains hidden or 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
class Game | |
attr_gtk | |
def current_level_name | |
# used by level editor to figure out which data file to save/load | |
state.levels[state.current_level_index] || :todo | |
end | |
# helper method to move rect within the camera | |
def to_screen_space target |
This file contains hidden or 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
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 contains hidden or 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
# 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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
class Game | |
attr_gtk | |
def initialize | |
end | |
def defaults | |
state.objects ||= [] | |
end |
This file contains hidden or 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
class Player | |
def initialize | |
@action_lookup = { | |
idle: { | |
frame_count: 7, | |
dir: "sprites/player/idle", | |
repeat: true | |
}, | |
attack: { | |
frame_count: 6, |
NewerOlder