08-30-2007, 01:00 PM
Mouse
by Corbaque
Aug 30 2007
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" :
How to use ?
To update the cursor position :
To set a new position (not only on the game !! ^^)
(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 =)
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.
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 =)