Class: Core::States::State

Inherits:
Object show all
Defined in:
lib/states/states.rb

Overview

Skeleton for game states

Provides a cursor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window) ⇒ State

Returns a new instance of State.



13
14
15
16
17
# File 'lib/states/states.rb', line 13

def initialize(window)
  @window = Core.window = window
  @x = @y = 0
  @cursor = Core::Cursor.new
end

Instance Attribute Details

#windowObject (readonly)

Returns the value of attribute window.



12
13
14
# File 'lib/states/states.rb', line 12

def window
  @window
end

#xObject (readonly)

Returns the value of attribute x.



12
13
14
# File 'lib/states/states.rb', line 12

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



12
13
14
# File 'lib/states/states.rb', line 12

def y
  @y
end

Instance Method Details

#drawObject



25
26
27
# File 'lib/states/states.rb', line 25

def draw
  draw_cursor
end

#draw_cursorObject



28
29
30
# File 'lib/states/states.rb', line 28

def draw_cursor
  @cursor.draw
end

#finishObject



31
32
# File 'lib/states/states.rb', line 31

def finish
end

#updateObject



18
19
20
# File 'lib/states/states.rb', line 18

def update
  update_cursor
end

#update_cursorObject



21
22
23
24
# File 'lib/states/states.rb', line 21

def update_cursor
  @x, @y = @window.mouse_x, @window.mouse_y
  @cursor.update(@x, @y)
end