Class: Core::Cursor

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

Instance Method Summary collapse

Constructor Details

#initializeCursor

Returns a new instance of Cursor.



5
6
7
8
9
10
# File 'lib/cursor.rb', line 5

def initialize
  @cursor = Core.sprite("cursors/normal")
  clear
  @x = 512
  @y = 384
end

Instance Method Details

#attach(sprite) ⇒ Object



29
30
31
# File 'lib/cursor.rb', line 29

def attach(sprite)
  @sprite = sprite
end

#clearObject



33
34
35
# File 'lib/cursor.rb', line 33

def clear
  @sprite = nil
end

#drawObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cursor.rb', line 16

def draw
  if !@x
    @x = 0
  end
  if !@y
    @y = 0
  end
  @cursor.draw(@x, @y, Core::CURSOR_Z)
  if @sprite
    @sprite.draw(@x+4, @y+8, Core::CURSOR_Z-1)
  end
end

#empty?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/cursor.rb', line 37

def empty?
  return @sprite == nil
end

#update(x, y) ⇒ Object



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

def update(x, y)
  @x, @y = x, y
end