Class: Core::Game::Fog

Inherits:
Object show all
Defined in:
lib/game/map/fog.rb

Instance Method Summary collapse

Constructor Details

#initialize(file, sx, sy, a = 255, r = 255, g = 255, b = 255) ⇒ Fog

Returns a new instance of Fog.



6
7
8
9
10
11
# File 'lib/game/map/fog.rb', line 6

def initialize(file, sx, sy, a=255, r=255, g=255, b=255)
  @img = Core.sprite("fog/#{file}", true)
  @x = @y = 0.0
  @sx, @sy = sx, sy
  @color = Gosu::Color.new(a, r, g, b)
end

Instance Method Details

#drawObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/game/map/fog.rb', line 26

def draw
  @img.draw(@x, @y, Core::FOG_Z, 1, 1, @color)
  if @sx != 0
    @img.draw(@x-@img.width, @y, Core::FOG_Z, 1, 1, @color)
  end
  if @sy != 0
    @img.draw(@x, @y-@img.height, Core::FOG_Z, 1, 1, @color)
  end
  if @sx != 0 and @sy != 0
    @img.draw(@x-@img.width, @y-@img.height, Core::FOG_Z, 1, 1, @color)
  end
end

#updateObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/game/map/fog.rb', line 12

def update
  @x += @sx
  @y += @sy
  if @x > 1024
    @x = 0.0
  elsif @x < 0
    @x = 1024.0
  end
  if @y > 768.0
    @y = 0
  elsif @y < 0
    @y = 768.0
  end
end