Class: UI::VoltorbFlip::BoardCounter

Inherits:
SpriteStack show all
Defined in:
scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb

Overview

Board counter sprite

Constant Summary

Constants inherited from SpriteStack

SpriteStack::NO_INITIAL_IMAGE

Instance Attribute Summary

Attributes inherited from SpriteStack

#animated, #data, #moving, #stack, #viewport, #x, #y

Instance Method Summary collapse

Methods inherited from SpriteStack

#[], #add_background, #add_line, #add_text, #anime, #anime_delta_set, #dispose, #each, #execute_anime, #move, #move_to, #opacity, #opacity=, #push, #push_sprite, #set_origin, #set_position, #simple_mouse_in?, #size, #stop_animation, #translate_mouse_coords, #update, #update_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=

Constructor Details

#initialize(viewport, index, column) ⇒ BoardCounter

Create a new board counter

Parameters:

  • viewport (Viewport)
  • index (Integer)

    index of the counter

  • column (Boolean)

    if it's a counter in the column or in the row



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 324

def initialize(viewport, index, column)
  super(viewport, default_cache: :interface)
  # @type [Array<BoardTile>]
  @tiles = []
  if column
    cx = GamePlay::Casino::VoltorbFlip::ColumnCoinDispX + index * GamePlay::Casino::VoltorbFlip::TileOffset
    cy = GamePlay::Casino::VoltorbFlip::ColumnCoinDispY
  else
    cx = GamePlay::Casino::VoltorbFlip::RowCoinDispX
    cy = GamePlay::Casino::VoltorbFlip::RowCoinDispY + index * GamePlay::Casino::VoltorbFlip::TileOffset
  end
  @coin_counter1 = push(cx, cy, 'voltorbflip/numbers')
  @coin_counter2 = push(cx + 7, cy, 'voltorbflip/numbers')
  @voltorb_counter = push(cx + 7, cy + 13, 'voltorbflip/numbers')
  @coin_counter1.set_rect_div(0, 0, 10, 1)
  @coin_counter2.set_rect_div(0, 0, 10, 1)
  @voltorb_counter.set_rect_div(0, 0, 10, 1)
end

Instance Method Details

#add_tile(tile)

Add a tile

Parameters:



351
352
353
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 351

def add_tile(tile)
  @tiles.push tile
end

#update_display

Update the counter display according to the tile values



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 356

def update_display
  # Initialize
  counter = [0, 0]
  # Count each tile content [voltorb, point]
  @tiles.each do |tile|
    if tile.content == :voltorb
      counter[0] += 1
    else
      counter[1] += tile.content
    end
  end

  # Display the numbers
  @coin_counter1.set_rect_div(counter[1] / 10, 0, 10, 1)
  @coin_counter2.set_rect_div(counter[1] - (counter[1] / 10) * 10, 0, 10, 1)
  @voltorb_counter.set_rect_div(counter[0], 0, 10, 1)
  @counter = counter
end

#voltorb_countInteger

Return the count of voltorb

Returns:



345
346
347
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 345

def voltorb_count
  return @counter[0]
end