module PirateGame::Boot
Constants
- BLUE_COLORS
- COLORS
- DARK_COLOR
- GREEN_COLORS
- LIGHT_COLOR
- PUB_COLOR
- SKY_COLOR
Public Class Methods
config()
click to toggle source
# File lib/pirate_game/boot.rb, line 43 def self.config @config ||= self.config_hash @config end
config_file()
click to toggle source
# File lib/pirate_game/boot.rb, line 31 def self.config_file File.expand_path '../../../config.json', __FILE__ end
config_hash()
click to toggle source
# File lib/pirate_game/boot.rb, line 35 def self.config_hash begin JSON.parse(open(self.config_file).read) rescue {"stage_duration" => 30, "action_duration" => 8} end end
waving_offset(frame, seed, delta_x, delta_y, speed = :normal)
click to toggle source
# File lib/pirate_game/boot.rb, line 48 def self.waving_offset(frame, seed, delta_x, delta_y, speed = :normal) t1 = frame + seed t2 = frame + seed * 2 vel = 10.0 case speed when :slow vel = 20.0 when :fast vel = 2.0 delta_x *= 2 delta_y *= 2 end offset_x = Math.sin(t1/vel) * delta_x offset_y = Math.cos(t2/vel) * delta_y return offset_x, offset_y end