Module: PirateGame::Boot
- Defined in:
- lib/pirate_game/boot.rb
Constant Summary collapse
- DARK_COLOR =
dimgray
'#696969'
- LIGHT_COLOR =
gainsboro
'#dcdcdc'
- SKY_COLOR =
aqua
'#00ffff'
- PUB_COLOR =
brown
'#52352b'
- COLORS =
{dark: DARK_COLOR, light: LIGHT_COLOR, sky: SKY_COLOR, pub: PUB_COLOR}
- BLUE_COLORS =
[ Shoes::COLORS[:cornflowerblue], Shoes::COLORS[:darkcyan], Shoes::COLORS[:deepskyblue], Shoes::COLORS[:mediumturquoise], Shoes::COLORS[:steelblue], Shoes::COLORS[:teal], Shoes::COLORS[:turquoise] ]
- GREEN_COLORS =
[Shoes::COLORS[:lightseagreen], Shoes::COLORS[:mediumaquamarine], Shoes::COLORS[:mediumseagreen], Shoes::COLORS[:seagreen], Shoes::COLORS[:teal] ]
Class Method Summary collapse
- .config ⇒ Object
- .config_file ⇒ Object
- .config_hash ⇒ Object
- .waving_offset(frame, seed, delta_x, delta_y, speed = :normal) ⇒ Object
Class Method Details
.config ⇒ Object
43 44 45 46 |
# File 'lib/pirate_game/boot.rb', line 43 def self.config @config ||= self.config_hash @config end |
.config_file ⇒ Object
31 32 33 |
# File 'lib/pirate_game/boot.rb', line 31 def self.config_file File. '../../../config.json', __FILE__ end |
.config_hash ⇒ Object
35 36 37 38 39 40 41 |
# 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) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# 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 |