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
| module Dungeon | |
| # Multipliers for transforming coordinates into other octants | |
| MULT = [ | |
| [1, 0, 0, -1, -1, 0, 0, 1], | |
| [0, 1, -1, 0, 0, -1, 1, 0], | |
| [0, 1, 1, 0, 0, -1, -1, 0], | |
| [1, 0, 0, 1, -1, 0, 0, -1], | |
| ] | |
| # Determines which co-ordinates on a 2D grid are visible |
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
| # Sample from: | |
| # https://docs.dragonruby.org/#/samples/rendering-basics?id=labels-text-wrapping-mainrb | |
| def tick(args) | |
| lines = ["line1", "line2", "line3", "line4"] | |
| labels = lines.map.with_index do |text, index| | |
| { | |
| x: 1280 / 2, | |
| y: 720 / 2, | |
| text: text, | |
| anchor_y: index |
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 | |
| # rng is sent to Random so that everyone gets the same levels | |
| @rng = Random.new 100 | |
| @solved_board = (1..16).to_a | |
| # rendering size of the cell |
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 Game < HttpRouter | |
| def initialize(players: []) | |
| @players = players | |
| @http_debounce = 0 | |
| route do |routes| | |
| @players.each do |player| | |
| routes.get "/#{player.id}/progress" do |req| | |
| if @current_scene_name == :host_scene | |
| req.respond 200, "{ \"progress\": #{player.progress} }" |
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 |
NewerOlder