Class: UI::MiningGame::Tiles

Inherits:
SpriteSheet show all
Defined in:
scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00006 Tiles.rb

Overview

Class that describes the Tiles sprite

Instance Attribute Summary collapse

Attributes inherited from SpriteSheet

#nb_x, #nb_y, #sx, #sy

Attributes inherited from LiteRGSS::ShaderedSprite

#blendmode, #shader

Attributes inherited from LiteRGSS::Sprite

#__index__, #angle, #bitmap, #height, #mirror, #opacity, #ox, #oy, #src_rect, #viewport, #visible, #width, #x, #y, #z, #zoom, #zoom_x, #zoom_y

Instance Method Summary collapse

Methods inherited from SpriteSheet

#bitmap=, #select

Methods inherited from Sprite

#load, #mouse_in?, #set_origin_div, #set_rect, #set_rect_div, #set_z, #simple_mouse_in?, #translate_mouse_coords, #update

Methods inherited from LiteRGSS::Sprite

new, #set_origin, #set_position

Methods inherited from LiteRGSS::Disposable

#dispose, #disposed?

Constructor Details

#initialize(viewport, state) ⇒ Tiles

Create the Tiles

Parameters:

  • viewport (Viewport)
  • state (Integer)

    the state the image is initialized on (between 0 and 6)



11
12
13
14
15
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00006 Tiles.rb', line 11

def initialize(viewport, state)
  super(viewport, possible_state_number, number_of_y_images)
  @state = state
  update_sx
end

Instance Attribute Details

#stateInteger

Returns state of the tile.

Returns:



6
7
8
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00006 Tiles.rb', line 6

def state
  @state
end

Instance Method Details

#lower_state(reason)

Lower the state and update the image in consequence

Parameters:

  • reason (Symbol)

    the reason of lowering



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00006 Tiles.rb', line 24

def lower_state(reason)
  if %i[pickaxe mace].include? reason
    @state -= 2
  elsif reason == :side_pickaxe
    @state -= 1
  elsif reason == :side_dynamite
    @state -= 4
  elsif reason == :dynamite
    @state -= 6
  end
  @state = 0 if @state < 0
  update_sx
end

#update_sx

Update the state of the sheet



18
19
20
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00006 Tiles.rb', line 18

def update_sx
  self.sx = @state
end