Sha256: feb4391ce49d7064646eb797f92ab83eec5dad9113d7875b65b3178c5715cacc

Contents?: true

Size: 852 Bytes

Versions: 21

Compression:

Stored size: 852 Bytes

Contents

# encoding: utf-8

module Fidgit
  class Cursor < Chingu::GameObject
    ARROW = 'arrow.png'
    HAND = 'hand.png'

    def initialize(options = {})
      options = {
        image: Gosu::Image[ARROW],
        rotation_center: :top_left,
        zorder: Float::INFINITY
      }.merge!(options)

      super(options)

      nil
    end

    # Is the mouse pointer position inside the game window pane?
    def inside_window?
      x >= 0 and y >= 0 and x < $window.width and y < $window.height
    end

    def update
      self.x, self.y = $window.mouse_x, $window.mouse_y

      super

      nil
    end

    def draw
      # Prevent system and game mouse from being shown at the same time.
      super if inside_window? and $window.current_game_state.is_a? GuiState and not $window.needs_cursor?
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
fidgit-0.2.4 lib/fidgit/cursor.rb
fidgit-0.2.3 lib/fidgit/cursor.rb
fidgit-0.2.2 lib/fidgit/cursor.rb
fidgit-0.2.1 lib/fidgit/cursor.rb
fidgit-0.2.0 lib/fidgit/cursor.rb
fidgit-0.1.10 lib/fidgit/cursor.rb
fidgit-0.1.9 lib/fidgit/cursor.rb
fidgit-0.1.8 lib/fidgit/cursor.rb
fidgit-0.1.7 lib/fidgit/cursor.rb
fidgit-0.1.6 lib/fidgit/cursor.rb
fidgit-0.1.5 lib/fidgit/cursor.rb
fidgit-0.1.4 lib/fidgit/cursor.rb
fidgit-0.1.3 lib/fidgit/cursor.rb
fidgit-0.1.2 lib/fidgit/cursor.rb
fidgit-0.1.1 lib/fidgit/cursor.rb
fidgit-0.1.0 lib/fidgit/cursor.rb
fidgit-0.0.6alpha lib/fidgit/cursor.rb
fidgit-0.0.5alpha lib/fidgit/cursor.rb
fidgit-0.0.4alpha lib/fidgit/cursor.rb
fidgit-0.0.3alpha lib/fidgit/cursor.rb