Class: SnakeGame::GameObject

Inherits:
Object
  • Object
show all
Defined in:
lib/game_object.rb

Overview

Base class for all game objects

Direct Known Subclasses

Bait, SnakePart

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(position, image) ⇒ GameObject

Returns a new instance of GameObject.



8
9
10
11
# File 'lib/game_object.rb', line 8

def initialize(position, image)
  @position = position
  @image = image
end

Instance Attribute Details

#imageObject

Returns the value of attribute image.



6
7
8
# File 'lib/game_object.rb', line 6

def image
  @image
end

#positionObject

Returns the value of attribute position.



6
7
8
# File 'lib/game_object.rb', line 6

def position
  @position
end

Instance Method Details

#drawObject



13
14
15
# File 'lib/game_object.rb', line 13

def draw
  @image.draw @position.x, @position.y, 0
end