Class: GamesAndRpgParadise::Graphics

Inherits:
Object
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/graphics.rb,
lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/graphics/game_over.rb,
lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/graphics/score/placeholder.rb

Defined Under Namespace

Classes: GameOver, Score

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logic:) ⇒ Graphics

Returns a new instance of Graphics.



12
13
14
15
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/graphics.rb', line 12

def initialize(logic:)
  @objects = {}
  @logic = logic
end

Instance Attribute Details

#logicObject

Returns the value of attribute logic.



9
10
11
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/graphics.rb', line 9

def logic
  @logic
end

#objectsObject (readonly)

Returns the value of attribute objects.



10
11
12
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/graphics.rb', line 10

def objects
  @objects
end

Instance Method Details

#add(key, graphic) ⇒ Object



17
18
19
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/graphics.rb', line 17

def add(key, graphic)
  @objects[key] = graphic
end

#update!Object



21
22
23
24
25
26
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/graphics.rb', line 21

def update!
  objects.each_pair { |id, object|
    next unless logic[id] && object.respond_to?(:update!)
    object.update!(logic[id])
  }
end