Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mouse
#1
Mouse
by Corbaque
Aug 30 2007

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


Hello all :P

Would you like to make a joke to players ?
The mouse is in life !!! O_O !!!

Add this script before main, named it "Mouse" :

Code:
#===================================
# Mouse
#---------------------------------------------------------------
# Created by Corbaque
#===================================
class Mouse < Sprite
  # Game screen
  Win = Win32API.new('user32', 'FindWindowA', %w(p p), 'i').call('RGSS Player', nil)
  # Adapt cursor to client
  Scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
  # Get cursor pos
  Pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  # Set cursor pos
  Set = Win32API.new('user32','SetCursorPos','ii','i')
  #-------------------------------------------------------------
  # Update
  #-------------------------------------------------------------
  def Mouse.update
    # Get cursor position
    pos = [0, 0].pack('ll'); Pos.call(pos)
    # Update in game cursor
    $cursor.x, $cursor.y = pos.unpack('ll') if Scr2cli.call(Win, pos) != 0
  end
  #-------------------------------------------------------------
  # Set cursor pos
  #-------------------------------------------------------------
  def set(x, y)
    # Adapt position to the game screen
    pos = [0, 0].pack('ll'); Scr2cli.call(Win, pos)
    # Set Position
    a, b = pos.unpack('ll'); Set.call(x-a, y-b)
  end
end
$cursor = Mouse.new


How to use ?
To update the cursor position :
Code:
Mouse.update


To set a new position (not only on the game !! ^^)
Code:
Mouse.set(x, y)

(Mouse.set(0, 0) put cursor at the top left of game screen)

The cursor is the $cursor sprite.
You can add a bitmap if you want :P

And it's all =)
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Mouse Over Translated Fox536 0 2,198 08-01-2009, 01:00 PM
Last Post: Fox536
  Hawk's Mouse Control System Hawk-McKain 0 2,366 11-05-2006, 01:00 PM
Last Post: Hawk-McKain



Users browsing this thread: