Class: UI::Casino::BandDisplay

Inherits:
Sprite show all
Defined in:
scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00002 BandDisplay.rb

Overview

Object showing image that should be aligned

Constant Summary collapse

FILES =

List of files that shows the images of the band

%w[casino/v1 casino/v2 casino/v3 casino/v4
casino/v5 casino/v6 casino/v7]
@@loaded_images =

List of loaded image for shorter processing

Returns:

[]

Instance Attribute Summary collapse

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Sprite

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

Methods inherited from LiteRGSS::Sprite

new, #set_origin, #set_position

Methods inherited from LiteRGSS::Disposable

#dispose, #disposed?

Constructor Details

#initialize(viewport, x, y, band, speed) ⇒ BandDisplay

Create a new BandDisplay

Parameters:



27
28
29
30
31
32
33
34
35
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00002 BandDisplay.rb', line 27

def initialize(viewport, x, y, band, speed)
  super(viewport)
  @band = band
  make_band
  set_position(x, y)
  self.opacity = 224
  @animation_speed = speed
  @locked = true
end

Instance Attribute Details

#animation_speedInteger

Animation speed of the band

Returns:



16
17
18
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00002 BandDisplay.rb', line 16

def animation_speed
  @animation_speed
end

#bandArray<Integer> (readonly)

Band information

Returns:



13
14
15
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00002 BandDisplay.rb', line 13

def band
  @band
end

#lockedBoolean

Tell if the band is locked or not

Returns:

  • (Boolean)


19
20
21
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00002 BandDisplay.rb', line 19

def locked
  @locked
end

Class Method Details

.dispose_images

Dispose all the loaded images



101
102
103
104
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00002 BandDisplay.rb', line 101

def dispose_images
  @@loaded_images.each(&:dispose)
  @@loaded_images.clear
end

Instance Method Details

#done?Boolean

Tell if the animation is done

Returns:

  • (Boolean)


52
53
54
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00002 BandDisplay.rb', line 52

def done?
  return (src_rect.y % cell_height) == 0 && @locked
end

#update

Update the animation



38
39
40
41
42
43
44
45
46
47
48
49
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00002 BandDisplay.rb', line 38

def update
  return if done?
  if @locked
    @animation_speed.times do
      src_rect.y -= 1
      break if done?
    end
  else
    src_rect.y -= @animation_speed
  end
  src_rect.y = src_rect.y % (7 * cell_height)
end

#value(row = 1) ⇒ Integer

Get the current value of the image shown by the band

Parameters:

  • row (Integer) (defaults to: 1)

    row you want the value

Returns:



59
60
61
62
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00002 BandDisplay.rb', line 59

def value(row = 1)
  value_index = src_rect.y / cell_height + row
  return @band[value_index % @band.size]
end