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 RootScene < Scene | |
| attr :game | |
| def initialize | |
| @game = Game.new | |
| $game = @game | |
| @world_scene = WorldScene.new | |
| @embark_scene = EmbarkScene.new | |
| @world_event_scene = WorldEventScene.new | |
| @battle_scene = BattleScene.new |
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 tick | |
| defaults | |
| render | |
| input | |
| calc | |
| 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 ShopScene | |
| attr_gtk | |
| def activate | |
| state.module_selected = nil | |
| state.available_modules = state.modules.shuffle.take(3) | |
| state.available_module_1 = state.available_modules[0] | |
| state.available_module_2 = state.available_modules[1] | |
| state.available_module_3 = state.available_modules[2] | |
| 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
| # Based on TinyWM by Nick Welch | |
| require 'X11' | |
| dpy = X11::Display.new | |
| root = dpy.screens.first.root | |
| # OK, so pure-x11 *really* badly needs built in keysym lookup, | |
| # but I don't want to add that without doing it properly, so this |
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
| # frozen_string_literal: true | |
| # Inspiration: https://brandnewbox.com/notes/2021/03/form-builders-in-ruby/ | |
| # | |
| # Example: | |
| # | |
| # f.input :field, options | |
| # | |
| # possible options: | |
| # - as: symbol (:boolean, :data, :float, :radio, :select, :string, :text, :file, :time) |
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
| # game concept from: https://youtu.be/Tz-AinJGDIM | |
| # This class encapsulates the logic of a button that pulses when clicked. | |
| # It is used in the StartScene and GameOverScene classes. | |
| class PulseButton | |
| # a block is passed into the constructor and is called when the button is clicked, | |
| # and after the pulse animation is complete | |
| def initialize rect, text, &on_click | |
| @rect = rect | |
| @text = text |
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
| # ActiveJob natively captures constructor arguments in an `@arguments` instance variable | |
| # which is also exposed as an `arguments` property on each job instance. | |
| # | |
| # Calls to `perform_now` and `perform_later` both forward arguments to the constructor. | |
| # | |
| # For example, all of these invocation styles work. | |
| # | |
| # result = DoStuffJob.new("foobar").perform # sync | |
| # result = DoStuffJob.new.perform("foobar") # sync | |
| # result = DoStuffJob.perform_now("foobar") # sync |
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 Referrable | |
| extend ActiveSupport: :Concern | |
| included do | |
| has_one referral, foreign_key: "referred_user_id", dependent: : destroy has_one referring_user, through: :referral alias_method :referred_by, :referring_user | |
| has_many :referrals, foreign_key: "referring_user_id", dependent: :nullify has_many :referred_users, through: referrals | |
| validates :referral_code, uniqueness: true, allow_nil: true | |
| end | |
| 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
| require'irb/color' | |
| code = File.read(ARGV[0] || 'fukuokark.rb') | |
| def hoge(s) | |
| s.gsub("eval(s*'')","$a=s*''") | |
| end | |
| eval code.gsub('then{;eval', 'then{eval hoge') | |
| w = 132 | |
| ended = false | |
| colored = IRB::Color.colorize_code(code.lines[0].dup+'%').gsub(/\n.+/,"\n") |
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
| include MatrixFunctions | |
| # Math constants | |
| K_INV_6 = 1.0 / 6.0 | |
| K_2_OVER_3 = 2.0 / 3.0 | |
| K_2_PI = Math::PI * 2.0 | |
| K_SQRT_3 = Math.sqrt 3.0 | |
| K_NEG_1_OVER_3 = -1.0 / 3.0 | |
| K_DEG2RAD = Math::PI / 180.0 | |
| K_RAD2DEG = 360.0 / (2.0 * Math::PI) |