Class: Cursetank::TankObject

Inherits:
Object
  • Object
show all
Defined in:
lib/cursetank/tank_objects/tank_object.rb

Direct Known Subclasses

BasicFish, Bubble, Octopus, Plant

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ TankObject

Returns a new instance of TankObject.



8
9
10
11
12
13
14
15
16
# File 'lib/cursetank/tank_objects/tank_object.rb', line 8

def initialize(args={})
  @frame     = 0
  @win       = args.fetch(:window)
  @pos_x     = args.fetch(:pos_x, 0)
  @pos_y     = args.fetch(:pos_y, 0)
  @dir_right = args.fetch(:dir_right, 1)
  @dir_down  = args.fetch(:dir_down, 1)
  @maxframes = frames.length
end

Instance Method Details

#drawObject



30
31
32
# File 'lib/cursetank/tank_objects/tank_object.rb', line 30

def draw
  raise Exception("draw method not implemented!")
end

#framesObject



26
27
28
# File 'lib/cursetank/tank_objects/tank_object.rb', line 26

def frames
  []
end

#set_directionObject



18
19
20
21
22
23
# File 'lib/cursetank/tank_objects/tank_object.rb', line 18

def set_direction
  @dir_right = -1 if @swin.begx >= @win.maxx - 10
  @dir_right = 1 if @swin.begx <= 5
  @dir_down  = -1 if @swin.begy >= @win.maxy - 10
  @dir_down  = 1 if @swin.begy <= 5
end