[pedido vx] "setas" pro game
+2
G@briel!
pitoquinho
6 participantes
Página 1 de 1
[pedido vx] "setas" pro game
ei,auguem tem um script tipo esse
da para percebe
q tem um "mouse" ali,
ai queria colocar um script desse tipo,
esperando uma resposta!!
da para percebe
q tem um "mouse" ali,
ai queria colocar um script desse tipo,
esperando uma resposta!!
pitoquinho- Mensagens : 461
Data de inscrição : 14/07/2010
Idade : 27
Localização : Ajudei?Não me dem Pedras,e sim,upem meu pet!
Re: [pedido vx] "setas" pro game
Err... Essa seta é da própria mensagem, mano...
G@briel!- Mensagens : 104
Data de inscrição : 13/07/2010
Idade : 27
Localização : Posto de chegada na base lunar
Re: [pedido vx] "setas" pro game
G@briel! escreveu:Err... Essa seta é da própria mensagem, mano...
@G@abriel
Axoo q naum
gsgg10- Mensagens : 259
Data de inscrição : 14/07/2010
Localização : Fortaleza,Ceará
Re: [pedido vx] "setas" pro game
Isto é da WindosSkin, se quiser POSSO tentar fazer 1.
[Executor]- Mensagens : 172
Data de inscrição : 16/07/2010
Re: [pedido vx] "setas" pro game
Gentem, ele está se referindo à aquele cursor de raposa qe tem ali em cima da WINDOW ¬¬
@Topic
Eu achei na Santuário, procura lá, porque o link eu não me lembro
@Topic
Eu achei na Santuário, procura lá, porque o link eu não me lembro
Dungeon22- Mensagens : 399
Data de inscrição : 14/07/2010
Localização : Na minha casa
Re: [pedido vx] "setas" pro game
Precisa desses três scripts:
Mouse input Module:
Path Finding (não sei pra quê que serve, mas tinha na demo que tinha na MRM)
e
Sistema Simples de Mouse
Depois, faça seu cursor com 32 pixels x 32 pixels e coloque na pasta System chamado "fox_cursor"
Acho que para mudar o nome do arquivo é no script ...
Na pasta System da demo tinha esse ícone aqui chamado mecha_icon, não sei praquê serve ...
Os cursores suportam transparência no fundo das imagens (é claro ¬¬')
Mouse input Module:
- Código:
#==============================================================================
# ** Mouse Input Module (Revised)
#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.2
# 08-18-2007
#------------------------------------------------------------------------------
# Based on...
# Mouse Input Module
# by Near Fantastica
#------------------------------------------------------------------------------
# Set_Pos feature by
# Freakboy
#------------------------------------------------------------------------------
#
# THE CALLS:
#
# Mouse.click?
# This returns a true/false value when you test whether a button is clicked.
# The values you pass are 1 (for the left mouse button), 2 (for the right) or
# 3 (for the middle button).
#
# Mouse.press?
# This returns a true/false value when you test whether a button is pressed
# and kept depressed. The values you pass are 1 (for the left mouse button),
# 2 (for the right mouse button), or 3 (for the middle).
#
# Mouse.pixels
# This returns the mouse's screen coordinates in pixels. Based on a screen
# with a 640x480 dimension, this returns an array of the mouse's position in
# index values. Calling Mouse.pixels returns both x & y positions in a sin-
# gle string, but calling Mouse.pixels[0] returns the x position (0-639) and
# calling Mouse.pixels[1] returns the y position (0-439). If the mouse is
# outside of the game's window region, this call returns nil.
#
# Mouse.tiles
# This returns the mouse's screen coordinates in map tiles. Based on the
# system's 20x15 tile size, this returns it in index values (a 0-19 width &
# a 0-14 height). This functions the same manner as Mouse.pixels.
#
# Mouse.set_pos
# This allows you to forcefully position the mouse at an x/y position within
# the game screen by pixel coordinates. Given the game's normal screen width
# of 640x480, adding: Mouse.set_pos(320,240) should position the mouse dead
# center of the gaming window.
#
# Mouse.update
# Add this routine into your update routines to update the mouse position.
# It must be called otherwise you won't get valid mouse coordinates.
#
#==============================================================================
module Mouse
@mouse_menu = 0
#--------------------------------------------------------------------------
# * Mouse Click
# button : button
#--------------------------------------------------------------------------
def Mouse.click?(button)
return true if @keys.include?(button)
return false
end
#--------------------------------------------------------------------------
# * Mouse Pressed
# button : button
#--------------------------------------------------------------------------
def Mouse.press?(button)
return true if @press.include?(button)
return false
end
#--------------------------------------------------------------------------
# * Mouse Pressed
# button : button
#--------------------------------------------------------------------------
def Mouse.area?(x, y, width=32, height=32)
return false if @pos == nil
return true if @pos[0] >= x and @pos[0] <= (x+width) and @pos[1] >= y and @pos[1] <= (y+height)
return false
end
#--------------------------------------------------------------------------
# * Mouse Pixel Position
#--------------------------------------------------------------------------
def Mouse.pixels
return @pos == nil ? [0, 0] : @pos
end
#--------------------------------------------------------------------------
# * Mouse Tile Position
#--------------------------------------------------------------------------
def Mouse.tiles
return nil if @pos == nil
x = @pos[0] / 32
y = @pos[1] / 32
return [x, y]
end
#--------------------------------------------------------------------------
# * Set Mouse Position
#--------------------------------------------------------------------------
def Mouse.set_pos(x_pos=0, y_pos=0)
width, height = Mouse.client_size
if (x_pos.between?(0, width) && y_pos.between?(0, height))
x = Mouse.client_pos[0] + x_pos; y = Mouse.client_pos[1] + y_pos
Win32API.new('user32', 'SetCursorPos', 'NN', 'N').call(x, y)
end
end
#--------------------------------------------------------------------------
# * Mouse Update
#--------------------------------------------------------------------------
def Mouse.update
@pos = Mouse.pos
@keys, @press = [], []
@keys.push(1) if Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(1) & 0X01 == 1
@keys.push(2) if Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(2) & 0X01 == 1
@keys.push(3) if Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(4) & 0X01 == 1
@press.push(1) if Win32API.new("user32","GetKeyState",['i'],'i').call(1) & 0X01 == 1
@press.push(2) if Win32API.new("user32","GetKeyState",['i'],'i').call(2) & 0X01 == 1
@press.push(3) if Win32API.new("user32","GetKeyState",['i'],'i').call(4) & 0X01 == 1
end
#--------------------------------------------------------------------------
# * Automatic functions below
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
# * Obtain Mouse position in screen
#--------------------------------------------------------------------------
def Mouse.global_pos
pos = [0, 0].pack('ll')
if Win32API.new('user32', 'GetCursorPos', 'p', 'i').call(pos) != 0
return pos.unpack('ll')
else
return nil
end
end
#--------------------------------------------------------------------------
# * Return Screen mouse position within game window
#--------------------------------------------------------------------------
def Mouse.pos
x, y = Mouse.screen_to_client(*Mouse.global_pos)
width, height = Mouse.client_size
begin
if (x >= 0 and y >= 0 and x < width and y < height)
return x, y
else
return nil
end
rescue
return nil
end
end
#--------------------------------------------------------------------------
# * Pass Screen to Game System
#--------------------------------------------------------------------------
def Mouse.screen_to_client(x, y)
return nil unless x and y
pos = [x, y].pack('ll')
if Win32API.new('user32', 'ScreenToClient', %w(l p), 'i').call(Mouse.hwnd, pos) != 0
return pos.unpack('ll')
else
return nil
end
end
#--------------------------------------------------------------------------
# * Get Screen Window Handle
#--------------------------------------------------------------------------
def Mouse.hwnd
game_name = "\0" * 256
Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l').call('Game','Title','',game_name,255,".\\Game.ini")
game_name.delete!("\0")
return Win32API.new('user32', 'FindWindowA', %w(p p), 'l').call('RGSS Player',game_name)
end
#--------------------------------------------------------------------------
# * Get Game Window Size
#--------------------------------------------------------------------------
def Mouse.client_size
rect = [0, 0, 0, 0].pack('l4')
Win32API.new('user32', 'GetClientRect', %w(l p), 'i').call(Mouse.hwnd, rect)
right, bottom = rect.unpack('l4')[2..3]
return right, bottom
end
#--------------------------------------------------------------------------
# * Get Window Position (RGSS Player)
#--------------------------------------------------------------------------
def Mouse.client_pos
rect = [0, 0, 0, 0].pack('l4')
Win32API.new('user32', 'GetWindowRect', %w(l p), 'i').call(Mouse.hwnd, rect)
left, upper = rect.unpack('l4')[0..1]
return left+4, upper+30
end
end
Path Finding (não sei pra quê que serve, mas tinha na demo que tinha na MRM)
- Código:
#==============================================================================
# ■ Path Finding
#==============================================================================
# Near Fantastica
# Version 1
# 29.11.05
#==============================================================================
# Lets the Player or Event draw a path from an desonation to the source. This
# method is very fast and because the pathfinding is imbedded into the Game
# Character the pathfinding can be interrupted or redrawn at any time.
#==============================================================================
# Player :: $game_player.find_path(x,y)
# Event Script Call :: self.event.find_path(x,y)
# Event Movement Script Call :: self.find_path(x,y)
#==============================================================================
# [VX] Simple Mouse System Note: I edited the method
# character.passable?(x, y, direction) to character.passable?(x, y)
# according to change of this method in VX.
#------------------------------------------------------------------------------
class Game_Character
#--------------------------------------------------------------------------
alias nf_pf_game_character_initialize initialize
alias nf_pf_game_character_update update
#--------------------------------------------------------------------------
attr_accessor :map
attr_accessor :runpath
#--------------------------------------------------------------------------
def initialize
nf_pf_game_character_initialize
@map = nil
@runpath = false
end
#--------------------------------------------------------------------------
def update
run_path if @runpath == true
nf_pf_game_character_update
end
#--------------------------------------------------------------------------
def run_path
return if moving?
step = @map[@x,@y]
if step == 1
@map = nil
@runpath = false
return
end
dir = rand(2)
case dir
when 0
move_right if @map[@x+1,@y] == step - 1 and step != 0
move_down if @map[@x,@y+1] == step - 1 and step != 0
move_left if @map[@x-1,@y] == step -1 and step != 0
move_up if @map[@x,@y-1] == step - 1 and step != 0
when 1
move_up if @map[@x,@y-1] == step - 1 and step != 0
move_left if @map[@x-1,@y] == step -1 and step != 0
move_down if @map[@x,@y+1] == step - 1 and step != 0
move_right if @map[@x+1,@y] == step - 1 and step != 0
end
end
#--------------------------------------------------------------------------
def find_path(x,y)
sx, sy = @x, @y
result = setup_map(sx,sy,x,y)
@runpath = result[0]
@map = result[1]
@map[sx,sy] = result[2] if result[2] != nil
end
#--------------------------------------------------------------------------
def clear_path
@map = nil
@runpath = false
end
#--------------------------------------------------------------------------
def setup_map(sx,sy,ex,ey)
map = Table.new($game_map.width, $game_map.height)
map[ex,ey] = 1
old_positions = []
new_positions = []
old_positions.push([ex, ey])
depth = 2
depth.upto(100){|step|
loop do
break if old_positions[0] == nil
x,y = old_positions.shift
return [true, map, step] if x == sx and y+1 == sy
if $game_player.passable?(x, y) and map[x,y + 1] == 0
map[x,y + 1] = step
new_positions.push([x,y + 1])
end
return [true, map, step] if x-1 == sx and y == sy
if $game_player.passable?(x, y) and map[x - 1,y] == 0
map[x - 1,y] = step
new_positions.push([x - 1,y])
end
return [true, map, step] if x+1 == sx and y == sy
if $game_player.passable?(x, y) and map[x + 1,y] == 0
map[x + 1,y] = step
new_positions.push([x + 1,y])
end
return [true, map, step] if x == sx and y-1 == sy
if $game_player.passable?(x, y) and map[x,y - 1] == 0
map[x,y - 1] = step
new_positions.push([x,y - 1])
end
end
old_positions = new_positions
new_positions = []
}
return [false, nil, nil]
end
end
class Game_Map
#--------------------------------------------------------------------------
alias pf_game_map_setup setup
#--------------------------------------------------------------------------
def setup(map_id)
pf_game_map_setup(map_id)
$game_player.clear_path
end
end
class Game_Player
#--------------------------------------------------------------------------
alias pf_game_player_update update
#--------------------------------------------------------------------------
def update
$game_player.clear_path if Input.dir4 != 0
pf_game_player_update
end
end
class Interpreter
#--------------------------------------------------------------------------
def event
return $game_map.events[@event_id]
end
end
e
Sistema Simples de Mouse
- Código:
#==============================================================================
# [VX] SSM - Sistema Simples de Mouse
#------------------------------------------------------------------------------
# ◦ by Woratana [woratana@hotmail.com]
# ◦ Lançado em: 14/04/2008 (D-M-Y)
# ◦ Versão: 1.5
#
# ◦ Tradução por Night'Walker
# reinorpg.com
#
# ◦ Créditos: DerVVulfman, Near Fantastica, e Freak Boy [Mouse Input Module]
# lambchop, shun, Cybersam, Astro_mech, e Mr.Mo [Super Simple Mouse System]
# - Algebra moderna, Zeriab, Patrick Lester [Path Finding]
# - Near Fantastica, Fuso [Path Finding]
#
# - Eu não seria capaz de fazer este script sem estas pessoas e os scripts
# - abaixo:
#-----------------------------------------------------------------------------
#====[REQUER]=====
# - DerVVulfman Mouse Input Module
# (http://rmxp.org/forums/index.php?topic=26993)
# É um script para XP, mas também funciona no VX.
#
# - Near Fantastica Path Finding [versão 1.0]
# (http://www.rmxp.org/forums/index.php?topic=26661.0)
# Com uma pequena alteração para funcionar no VX.
#
#====[FEATURE]=====
# - Suporta utilizar o mouse em várias Scenes/Janelas
# - Clique no mapa para mover o jogador com PathFinding
# - Ponteiro do Mouse
#
#====[Para a próxima versão]=====
# - Alteração do cursor sobre eventos
# - Melhor verificador de disparado de evento pelo clique
#
#------------------------------------------------------------------------------
#==============================================================================
# ** Mouse Input Module
#==============================================================================
class << Mouse
show_cursor = Win32API.new('user32', 'ShowCursor', 'l', 'l')
show_cursor.call(0)
$mousec = Sprite.new
$mousec.z = 10001
$mousec.x = $mousec.y = 1000
$mouse_icon = 'fox_cursor'
$mousec.bitmap = Cache.system($mouse_icon)
alias wor_mouse_upd_mouse update unless $@
def Mouse.update
wor_mouse_upd_mouse
if $mouse_old_icon.nil? or $mouse_old_icon != $mouse_icon
$mouse_old_icon = $mouse_icon
$mousec.bitmap = Cache.system($mouse_old_icon)
end
if @pos.nil?
$mousec.x = 1000 if $mousec.x != 1000
$mousec.y = 1000 if $mousec.y != 1000
else
$mousec.x = @pos[0] if $mousec.x != @pos[0]
$mousec.y = @pos[1] if $mousec.y != @pos[1]
end
end
def Mouse.map_pos
return nil if @pos == nil
x = ($game_map.display_x / 256) + (@pos[0] / 32)
y = ($game_map.display_y / 256) + (@pos[1] / 32)
return [x, y]
end
end
#==============================================================================
# ** Input
#==============================================================================
class << Input
alias wor_input_upd_mouse update unless $@
alias wor_input_trig_mouse trigger? unless $@
alias wor_input_rep_mouse repeat? unless $@
def Input.update
wor_input_upd_mouse
Mouse.update
end
def Input.trigger?(input)
return wor_input_trig_mouse(input) if Mouse.pos.nil?
case input
when Input::B
return (wor_input_trig_mouse(input) or Mouse.click?(2))
when Input::C
if $scene.is_a?(Scene_Map) and !$game_message.visible
return wor_input_trig_mouse(input)
else
return (wor_input_trig_mouse(input) or Mouse.click?(1))
end
else
return wor_input_trig_mouse(input)
end
end
def Input.repeat?(input)
if input == Input::B
return (wor_input_rep_mouse(input) or Mouse.click?(2))
else
return wor_input_rep_mouse(input)
end
end
end
#==============================================================================
# ** Graphics
#==============================================================================
class << Graphics
alias wor_graph_fadeout_mouse fadeout unless $@
def Graphics.fadeout(frames = 1)
$mousec.visible = false if !$mousec.nil?
wor_graph_fadeout_mouse(frames)
end
end
#==============================================================================
# ** Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
alias wor_winsel_ini_mouse initialize
alias wor_winsel_upd_mouse update
def initialize(*args)
wor_winsel_ini_mouse(*args)
@scroll_wait = 0
@cursor_wait = 0
end
def update
wor_winsel_upd_mouse
update_mouse if self.active and self.visible
end
def update_mouse
@cursor_wait -= 1 if @cursor_wait > 0
(0..@item_max - 1).each do |i|
irect = item_rect(i)
irx = self.x + 16 + irect.x - self.ox
iry = self.y + 16 + irect.y - self.oy
move_cursor(i) if Mouse.area?(irx, iry, irect.width, irect.height)
end
end
def move_cursor(index)
return if @index == index
@scroll_wait -= 1 if @scroll_wait > 0
row1 = @index / @column_max
row2 = index / @column_max
bottom = self.top_row + (self.page_row_max - 1)
if row1 == self.top_row and row2 < self.top_row
return if @scroll_wait > 0
@index = [@index - @column_max, 0].max
@scroll_wait = 4
elsif row1 == bottom and row2 > bottom
return if @scroll_wait > 0
@index = [@index + @column_max, @item_max - 1].min
@scroll_wait = 4
else
@index = index
end
return if @cursor_wait > 0
Sound.play_cursor
@cursor_wait += 2
end
end
#==============================================================================
# ** Window_MenuStatus
#==============================================================================
class Window_MenuStatus < Window_Selectable
def item_rect(index)
return Rect.new(0, index * 96, contents.width, 96)
end
end
#==============================================================================
# ** Window_NameInput
#==============================================================================
class Window_NameInput < Window_Base
alias wor_winnam_upd_mouse update
def update
wor_winnam_upd_mouse
if self.active and self.visible
(0..TABLE[@mode].size - 1).each do |i|
irect = item_rect(i)
irx = self.x + 16 + irect.x - self.ox
iry = self.y + 16 + irect.y - self.oy
@index = i if Mouse.area?(irx, iry, irect.width, irect.height)
end
end
end
end
#==============================================================================
# ** Window_PartyCommand
#==============================================================================
class Window_PartyCommand < Window_Command
def update_mouse
(0..@item_max - 1).each do |i|
irect = item_rect(i)
irx = self.viewport.ox + 16 + irect.x - self.ox
iry = 288 + 16 + irect.y - self.oy
self.index = i if Mouse.area?(irx, iry, irect.width, irect.height)
end
end
end
#==============================================================================
# ** Window_ActorCommand
#==============================================================================
class Window_ActorCommand < Window_Command
def update_mouse
(0..@item_max - 1).each do |i|
irect = item_rect(i)
irx = self.viewport.ox + 288 + 16 + irect.x
iry = 288 + 16 + irect.y
self.index = i if Mouse.area?(irx, iry, irect.width, irect.height)
end
end
end
#==============================================================================
# ** Window_Message
#==============================================================================
class Window_Message < Window_Selectable
def update_mouse
(0..@item_max - 1).each do |i|
irect = item_rect(i)
irx = self.x + 16 + irect.x - self.ox
iry = self.y + 16 + irect.y - self.oy + ($game_message.choice_start * WLH)
self.index = i if Mouse.area?(irx, iry, irect.width, irect.height)
end
end
end
#==============================================================================
# ** Scene_Base
#==============================================================================
class Scene_Base
alias wor_scebase_posstr_mouse post_start
alias wor_scebase_preter_mouse pre_terminate
def post_start
$mousec.visible = true if !$mousec.nil?
wor_scebase_posstr_mouse
end
def pre_terminate
$mousec.visible = false if !$mousec.nil?
wor_scebase_preter_mouse
end
end
#==============================================================================
# ** Scene_File
#==============================================================================
class Scene_File < Scene_Base
alias wor_scefil_upd_mouse update
def update
(0..@item_max - 1).each do |i|
ix = @savefile_windows[i].x
iy = @savefile_windows[i].y
iw = @savefile_windows[i].width
ih = @savefile_windows[i].height
if Mouse.area?(ix, iy, iw, ih)
@savefile_windows[@index].selected = false
@savefile_windows[i].selected = true
@index = i
end
end
wor_scefil_upd_mouse
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
alias wor_scemap_ini_mouse initialize
alias wor_scemap_upd_mouse update
def initialize
@last_click = [nil, nil]
wor_scemap_ini_mouse
end
def update
wor_scemap_upd_mouse
mouse_xy = Mouse.map_pos
if Mouse.click?(1) and !mouse_xy.nil? and !$game_message.visible and
!$game_map.interpreter.running?
$game_player.turn_toward_pos(mouse_xy[0], mouse_xy[1])
if $game_player.close?(mouse_xy[0],mouse_xy[1]) and
$game_player.check_action_event
$game_player.clear_path
return
end
if $game_map.passable?(mouse_xy[0], mouse_xy[1])
$game_player.find_path(mouse_xy[0], mouse_xy[1])
end
@last_click = mouse_xy
end
if Mouse.click?(3) and !mouse_xy.nil? and !$game_message.visible and
!$game_map.interpreter.running?
$game_player.clear_path
$game_player.turn_toward_pos(mouse_xy[0], mouse_xy[1])
end
end
end
#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
def turn_toward_pos(x,y)
sx = distance_x_from_pos(x)
sy = distance_y_from_pos(y)
if sx.abs > sy.abs
sx > 0 ? turn_left : turn_right
elsif sx.abs < sy.abs
sy > 0 ? turn_up : turn_down
end
end
def distance_x_from_pos(x)
sx = @x - x
if $game_map.loop_horizontal?
if sx.abs > $game_map.width / 2
sx -= $game_map.width
end
end
return sx
end
def distance_y_from_pos(y)
sy = @y - y
if $game_map.loop_vertical?
if sy.abs > $game_map.height / 2
sy -= $game_map.height
end
end
return sy
end
def close?(x,y)
sx = (@x - x).abs
sy = (@y - y).abs
if sx + sy == 1
return true
end
return false
end
end
Depois, faça seu cursor com 32 pixels x 32 pixels e coloque na pasta System chamado "fox_cursor"
Acho que para mudar o nome do arquivo é no script ...
Na pasta System da demo tinha esse ícone aqui chamado mecha_icon, não sei praquê serve ...
Os cursores suportam transparência no fundo das imagens (é claro ¬¬')
arrout123- Mensagens : 148
Data de inscrição : 14/07/2010
Idade : 26
Localização : GTA V SOON
Re: [pedido vx] "setas" pro game
vlw arond!
5+ pedras lunares
5+ pedras lunares
pitoquinho- Mensagens : 461
Data de inscrição : 14/07/2010
Idade : 27
Localização : Ajudei?Não me dem Pedras,e sim,upem meu pet!
Re: [pedido vx] "setas" pro game
Achei a demo no meu histórico, confere se é essa mesmo:
http://www.mediafire.com/?lywkictomwh
OBS: É arrout, não around '-'
1 Pedra lunar já é boa, imagina 5 o.O
;D
http://www.mediafire.com/?lywkictomwh
OBS: É arrout, não around '-'
1 Pedra lunar já é boa, imagina 5 o.O
;D
arrout123- Mensagens : 148
Data de inscrição : 14/07/2010
Idade : 26
Localização : GTA V SOON
Re: [pedido vx] "setas" pro game
a,desculpe,
bom,mas vlw a demo!
bom,mas vlw a demo!
pitoquinho- Mensagens : 461
Data de inscrição : 14/07/2010
Idade : 27
Localização : Ajudei?Não me dem Pedras,e sim,upem meu pet!
Re: [pedido vx] "setas" pro game
- Spoiler:
- arrout123 escreveu:Precisa desses três scripts:
Mouse input Module:- Código:
#==============================================================================
# ** Mouse Input Module (Revised)
#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.2
# 08-18-2007
#------------------------------------------------------------------------------
# Based on...
# Mouse Input Module
# by Near Fantastica
#------------------------------------------------------------------------------
# Set_Pos feature by
# Freakboy
#------------------------------------------------------------------------------
#
# THE CALLS:
#
# Mouse.click?
# This returns a true/false value when you test whether a button is clicked.
# The values you pass are 1 (for the left mouse button), 2 (for the right) or
# 3 (for the middle button).
#
# Mouse.press?
# This returns a true/false value when you test whether a button is pressed
# and kept depressed. The values you pass are 1 (for the left mouse button),
# 2 (for the right mouse button), or 3 (for the middle).
#
# Mouse.pixels
# This returns the mouse's screen coordinates in pixels. Based on a screen
# with a 640x480 dimension, this returns an array of the mouse's position in
# index values. Calling Mouse.pixels returns both x & y positions in a sin-
# gle string, but calling Mouse.pixels[0] returns the x position (0-639) and
# calling Mouse.pixels[1] returns the y position (0-439). If the mouse is
# outside of the game's window region, this call returns nil.
#
# Mouse.tiles
# This returns the mouse's screen coordinates in map tiles. Based on the
# system's 20x15 tile size, this returns it in index values (a 0-19 width &
# a 0-14 height). This functions the same manner as Mouse.pixels.
#
# Mouse.set_pos
# This allows you to forcefully position the mouse at an x/y position within
# the game screen by pixel coordinates. Given the game's normal screen width
# of 640x480, adding: Mouse.set_pos(320,240) should position the mouse dead
# center of the gaming window.
#
# Mouse.update
# Add this routine into your update routines to update the mouse position.
# It must be called otherwise you won't get valid mouse coordinates.
#
#==============================================================================
module Mouse
@mouse_menu = 0
#--------------------------------------------------------------------------
# * Mouse Click
# button : button
#--------------------------------------------------------------------------
def Mouse.click?(button)
return true if @keys.include?(button)
return false
end
#--------------------------------------------------------------------------
# * Mouse Pressed
# button : button
#--------------------------------------------------------------------------
def Mouse.press?(button)
return true if @press.include?(button)
return false
end
#--------------------------------------------------------------------------
# * Mouse Pressed
# button : button
#--------------------------------------------------------------------------
def Mouse.area?(x, y, width=32, height=32)
return false if @pos == nil
return true if @pos[0] >= x and @pos[0] <= (x+width) and @pos[1] >= y and @pos[1] <= (y+height)
return false
end
#--------------------------------------------------------------------------
# * Mouse Pixel Position
#--------------------------------------------------------------------------
def Mouse.pixels
return @pos == nil ? [0, 0] : @pos
end
#--------------------------------------------------------------------------
# * Mouse Tile Position
#--------------------------------------------------------------------------
def Mouse.tiles
return nil if @pos == nil
x = @pos[0] / 32
y = @pos[1] / 32
return [x, y]
end
#--------------------------------------------------------------------------
# * Set Mouse Position
#--------------------------------------------------------------------------
def Mouse.set_pos(x_pos=0, y_pos=0)
width, height = Mouse.client_size
if (x_pos.between?(0, width) && y_pos.between?(0, height))
x = Mouse.client_pos[0] + x_pos; y = Mouse.client_pos[1] + y_pos
Win32API.new('user32', 'SetCursorPos', 'NN', 'N').call(x, y)
end
end
#--------------------------------------------------------------------------
# * Mouse Update
#--------------------------------------------------------------------------
def Mouse.update
@pos = Mouse.pos
@keys, @press = [], []
@keys.push(1) if Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(1) & 0X01 == 1
@keys.push(2) if Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(2) & 0X01 == 1
@keys.push(3) if Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(4) & 0X01 == 1
@press.push(1) if Win32API.new("user32","GetKeyState",['i'],'i').call(1) & 0X01 == 1
@press.push(2) if Win32API.new("user32","GetKeyState",['i'],'i').call(2) & 0X01 == 1
@press.push(3) if Win32API.new("user32","GetKeyState",['i'],'i').call(4) & 0X01 == 1
end
#--------------------------------------------------------------------------
# * Automatic functions below
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
# * Obtain Mouse position in screen
#--------------------------------------------------------------------------
def Mouse.global_pos
pos = [0, 0].pack('ll')
if Win32API.new('user32', 'GetCursorPos', 'p', 'i').call(pos) != 0
return pos.unpack('ll')
else
return nil
end
end
#--------------------------------------------------------------------------
# * Return Screen mouse position within game window
#--------------------------------------------------------------------------
def Mouse.pos
x, y = Mouse.screen_to_client(*Mouse.global_pos)
width, height = Mouse.client_size
begin
if (x >= 0 and y >= 0 and x < width and y < height)
return x, y
else
return nil
end
rescue
return nil
end
end
#--------------------------------------------------------------------------
# * Pass Screen to Game System
#--------------------------------------------------------------------------
def Mouse.screen_to_client(x, y)
return nil unless x and y
pos = [x, y].pack('ll')
if Win32API.new('user32', 'ScreenToClient', %w(l p), 'i').call(Mouse.hwnd, pos) != 0
return pos.unpack('ll')
else
return nil
end
end
#--------------------------------------------------------------------------
# * Get Screen Window Handle
#--------------------------------------------------------------------------
def Mouse.hwnd
game_name = "\0" * 256
Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l').call('Game','Title','',game_name,255,".\\Game.ini")
game_name.delete!("\0")
return Win32API.new('user32', 'FindWindowA', %w(p p), 'l').call('RGSS Player',game_name)
end
#--------------------------------------------------------------------------
# * Get Game Window Size
#--------------------------------------------------------------------------
def Mouse.client_size
rect = [0, 0, 0, 0].pack('l4')
Win32API.new('user32', 'GetClientRect', %w(l p), 'i').call(Mouse.hwnd, rect)
right, bottom = rect.unpack('l4')[2..3]
return right, bottom
end
#--------------------------------------------------------------------------
# * Get Window Position (RGSS Player)
#--------------------------------------------------------------------------
def Mouse.client_pos
rect = [0, 0, 0, 0].pack('l4')
Win32API.new('user32', 'GetWindowRect', %w(l p), 'i').call(Mouse.hwnd, rect)
left, upper = rect.unpack('l4')[0..1]
return left+4, upper+30
end
end
Path Finding (não sei pra quê que serve, mas tinha na demo que tinha na MRM)- Código:
#==============================================================================
# ■ Path Finding
#==============================================================================
# Near Fantastica
# Version 1
# 29.11.05
#==============================================================================
# Lets the Player or Event draw a path from an desonation to the source. This
# method is very fast and because the pathfinding is imbedded into the Game
# Character the pathfinding can be interrupted or redrawn at any time.
#==============================================================================
# Player :: $game_player.find_path(x,y)
# Event Script Call :: self.event.find_path(x,y)
# Event Movement Script Call :: self.find_path(x,y)
#==============================================================================
# [VX] Simple Mouse System Note: I edited the method
# character.passable?(x, y, direction) to character.passable?(x, y)
# according to change of this method in VX.
#------------------------------------------------------------------------------
class Game_Character
#--------------------------------------------------------------------------
alias nf_pf_game_character_initialize initialize
alias nf_pf_game_character_update update
#--------------------------------------------------------------------------
attr_accessor :map
attr_accessor :runpath
#--------------------------------------------------------------------------
def initialize
nf_pf_game_character_initialize
@map = nil
@runpath = false
end
#--------------------------------------------------------------------------
def update
run_path if @runpath == true
nf_pf_game_character_update
end
#--------------------------------------------------------------------------
def run_path
return if moving?
step = @map[@x,@y]
if step == 1
@map = nil
@runpath = false
return
end
dir = rand(2)
case dir
when 0
move_right if @map[@x+1,@y] == step - 1 and step != 0
move_down if @map[@x,@y+1] == step - 1 and step != 0
move_left if @map[@x-1,@y] == step -1 and step != 0
move_up if @map[@x,@y-1] == step - 1 and step != 0
when 1
move_up if @map[@x,@y-1] == step - 1 and step != 0
move_left if @map[@x-1,@y] == step -1 and step != 0
move_down if @map[@x,@y+1] == step - 1 and step != 0
move_right if @map[@x+1,@y] == step - 1 and step != 0
end
end
#--------------------------------------------------------------------------
def find_path(x,y)
sx, sy = @x, @y
result = setup_map(sx,sy,x,y)
@runpath = result[0]
@map = result[1]
@map[sx,sy] = result[2] if result[2] != nil
end
#--------------------------------------------------------------------------
def clear_path
@map = nil
@runpath = false
end
#--------------------------------------------------------------------------
def setup_map(sx,sy,ex,ey)
map = Table.new($game_map.width, $game_map.height)
map[ex,ey] = 1
old_positions = []
new_positions = []
old_positions.push([ex, ey])
depth = 2
depth.upto(100){|step|
loop do
break if old_positions[0] == nil
x,y = old_positions.shift
return [true, map, step] if x == sx and y+1 == sy
if $game_player.passable?(x, y) and map[x,y + 1] == 0
map[x,y + 1] = step
new_positions.push([x,y + 1])
end
return [true, map, step] if x-1 == sx and y == sy
if $game_player.passable?(x, y) and map[x - 1,y] == 0
map[x - 1,y] = step
new_positions.push([x - 1,y])
end
return [true, map, step] if x+1 == sx and y == sy
if $game_player.passable?(x, y) and map[x + 1,y] == 0
map[x + 1,y] = step
new_positions.push([x + 1,y])
end
return [true, map, step] if x == sx and y-1 == sy
if $game_player.passable?(x, y) and map[x,y - 1] == 0
map[x,y - 1] = step
new_positions.push([x,y - 1])
end
end
old_positions = new_positions
new_positions = []
}
return [false, nil, nil]
end
end
class Game_Map
#--------------------------------------------------------------------------
alias pf_game_map_setup setup
#--------------------------------------------------------------------------
def setup(map_id)
pf_game_map_setup(map_id)
$game_player.clear_path
end
end
class Game_Player
#--------------------------------------------------------------------------
alias pf_game_player_update update
#--------------------------------------------------------------------------
def update
$game_player.clear_path if Input.dir4 != 0
pf_game_player_update
end
end
class Interpreter
#--------------------------------------------------------------------------
def event
return $game_map.events[@event_id]
end
end
e
Sistema Simples de Mouse- Código:
#==============================================================================
# [VX] SSM - Sistema Simples de Mouse
#------------------------------------------------------------------------------
# ◦ by Woratana [woratana@hotmail.com]
# ◦ Lançado em: 14/04/2008 (D-M-Y)
# ◦ Versão: 1.5
#
# ◦ Tradução por Night'Walker
# reinorpg.com
#
# ◦ Créditos: DerVVulfman, Near Fantastica, e Freak Boy [Mouse Input Module]
# lambchop, shun, Cybersam, Astro_mech, e Mr.Mo [Super Simple Mouse System]
# - Algebra moderna, Zeriab, Patrick Lester [Path Finding]
# - Near Fantastica, Fuso [Path Finding]
#
# - Eu não seria capaz de fazer este script sem estas pessoas e os scripts
# - abaixo:
#-----------------------------------------------------------------------------
#====[REQUER]=====
# - DerVVulfman Mouse Input Module
# (http://rmxp.org/forums/index.php?topic=26993)
# É um script para XP, mas também funciona no VX.
#
# - Near Fantastica Path Finding [versão 1.0]
# (http://www.rmxp.org/forums/index.php?topic=26661.0)
# Com uma pequena alteração para funcionar no VX.
#
#====[FEATURE]=====
# - Suporta utilizar o mouse em várias Scenes/Janelas
# - Clique no mapa para mover o jogador com PathFinding
# - Ponteiro do Mouse
#
#====[Para a próxima versão]=====
# - Alteração do cursor sobre eventos
# - Melhor verificador de disparado de evento pelo clique
#
#------------------------------------------------------------------------------
#==============================================================================
# ** Mouse Input Module
#==============================================================================
class << Mouse
show_cursor = Win32API.new('user32', 'ShowCursor', 'l', 'l')
show_cursor.call(0)
$mousec = Sprite.new
$mousec.z = 10001
$mousec.x = $mousec.y = 1000
$mouse_icon = 'fox_cursor'
$mousec.bitmap = Cache.system($mouse_icon)
alias wor_mouse_upd_mouse update unless $@
def Mouse.update
wor_mouse_upd_mouse
if $mouse_old_icon.nil? or $mouse_old_icon != $mouse_icon
$mouse_old_icon = $mouse_icon
$mousec.bitmap = Cache.system($mouse_old_icon)
end
if @pos.nil?
$mousec.x = 1000 if $mousec.x != 1000
$mousec.y = 1000 if $mousec.y != 1000
else
$mousec.x = @pos[0] if $mousec.x != @pos[0]
$mousec.y = @pos[1] if $mousec.y != @pos[1]
end
end
def Mouse.map_pos
return nil if @pos == nil
x = ($game_map.display_x / 256) + (@pos[0] / 32)
y = ($game_map.display_y / 256) + (@pos[1] / 32)
return [x, y]
end
end
#==============================================================================
# ** Input
#==============================================================================
class << Input
alias wor_input_upd_mouse update unless $@
alias wor_input_trig_mouse trigger? unless $@
alias wor_input_rep_mouse repeat? unless $@
def Input.update
wor_input_upd_mouse
Mouse.update
end
def Input.trigger?(input)
return wor_input_trig_mouse(input) if Mouse.pos.nil?
case input
when Input::B
return (wor_input_trig_mouse(input) or Mouse.click?(2))
when Input::C
if $scene.is_a?(Scene_Map) and !$game_message.visible
return wor_input_trig_mouse(input)
else
return (wor_input_trig_mouse(input) or Mouse.click?(1))
end
else
return wor_input_trig_mouse(input)
end
end
def Input.repeat?(input)
if input == Input::B
return (wor_input_rep_mouse(input) or Mouse.click?(2))
else
return wor_input_rep_mouse(input)
end
end
end
#==============================================================================
# ** Graphics
#==============================================================================
class << Graphics
alias wor_graph_fadeout_mouse fadeout unless $@
def Graphics.fadeout(frames = 1)
$mousec.visible = false if !$mousec.nil?
wor_graph_fadeout_mouse(frames)
end
end
#==============================================================================
# ** Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
alias wor_winsel_ini_mouse initialize
alias wor_winsel_upd_mouse update
def initialize(*args)
wor_winsel_ini_mouse(*args)
@scroll_wait = 0
@cursor_wait = 0
end
def update
wor_winsel_upd_mouse
update_mouse if self.active and self.visible
end
def update_mouse
@cursor_wait -= 1 if @cursor_wait > 0
(0..@item_max - 1).each do |i|
irect = item_rect(i)
irx = self.x + 16 + irect.x - self.ox
iry = self.y + 16 + irect.y - self.oy
move_cursor(i) if Mouse.area?(irx, iry, irect.width, irect.height)
end
end
def move_cursor(index)
return if @index == index
@scroll_wait -= 1 if @scroll_wait > 0
row1 = @index / @column_max
row2 = index / @column_max
bottom = self.top_row + (self.page_row_max - 1)
if row1 == self.top_row and row2 < self.top_row
return if @scroll_wait > 0
@index = [@index - @column_max, 0].max
@scroll_wait = 4
elsif row1 == bottom and row2 > bottom
return if @scroll_wait > 0
@index = [@index + @column_max, @item_max - 1].min
@scroll_wait = 4
else
@index = index
end
return if @cursor_wait > 0
Sound.play_cursor
@cursor_wait += 2
end
end
#==============================================================================
# ** Window_MenuStatus
#==============================================================================
class Window_MenuStatus < Window_Selectable
def item_rect(index)
return Rect.new(0, index * 96, contents.width, 96)
end
end
#==============================================================================
# ** Window_NameInput
#==============================================================================
class Window_NameInput < Window_Base
alias wor_winnam_upd_mouse update
def update
wor_winnam_upd_mouse
if self.active and self.visible
(0..TABLE[@mode].size - 1).each do |i|
irect = item_rect(i)
irx = self.x + 16 + irect.x - self.ox
iry = self.y + 16 + irect.y - self.oy
@index = i if Mouse.area?(irx, iry, irect.width, irect.height)
end
end
end
end
#==============================================================================
# ** Window_PartyCommand
#==============================================================================
class Window_PartyCommand < Window_Command
def update_mouse
(0..@item_max - 1).each do |i|
irect = item_rect(i)
irx = self.viewport.ox + 16 + irect.x - self.ox
iry = 288 + 16 + irect.y - self.oy
self.index = i if Mouse.area?(irx, iry, irect.width, irect.height)
end
end
end
#==============================================================================
# ** Window_ActorCommand
#==============================================================================
class Window_ActorCommand < Window_Command
def update_mouse
(0..@item_max - 1).each do |i|
irect = item_rect(i)
irx = self.viewport.ox + 288 + 16 + irect.x
iry = 288 + 16 + irect.y
self.index = i if Mouse.area?(irx, iry, irect.width, irect.height)
end
end
end
#==============================================================================
# ** Window_Message
#==============================================================================
class Window_Message < Window_Selectable
def update_mouse
(0..@item_max - 1).each do |i|
irect = item_rect(i)
irx = self.x + 16 + irect.x - self.ox
iry = self.y + 16 + irect.y - self.oy + ($game_message.choice_start * WLH)
self.index = i if Mouse.area?(irx, iry, irect.width, irect.height)
end
end
end
#==============================================================================
# ** Scene_Base
#==============================================================================
class Scene_Base
alias wor_scebase_posstr_mouse post_start
alias wor_scebase_preter_mouse pre_terminate
def post_start
$mousec.visible = true if !$mousec.nil?
wor_scebase_posstr_mouse
end
def pre_terminate
$mousec.visible = false if !$mousec.nil?
wor_scebase_preter_mouse
end
end
#==============================================================================
# ** Scene_File
#==============================================================================
class Scene_File < Scene_Base
alias wor_scefil_upd_mouse update
def update
(0..@item_max - 1).each do |i|
ix = @savefile_windows[i].x
iy = @savefile_windows[i].y
iw = @savefile_windows[i].width
ih = @savefile_windows[i].height
if Mouse.area?(ix, iy, iw, ih)
@savefile_windows[@index].selected = false
@savefile_windows[i].selected = true
@index = i
end
end
wor_scefil_upd_mouse
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
alias wor_scemap_ini_mouse initialize
alias wor_scemap_upd_mouse update
def initialize
@last_click = [nil, nil]
wor_scemap_ini_mouse
end
def update
wor_scemap_upd_mouse
mouse_xy = Mouse.map_pos
if Mouse.click?(1) and !mouse_xy.nil? and !$game_message.visible and
!$game_map.interpreter.running?
$game_player.turn_toward_pos(mouse_xy[0], mouse_xy[1])
if $game_player.close?(mouse_xy[0],mouse_xy[1]) and
$game_player.check_action_event
$game_player.clear_path
return
end
if $game_map.passable?(mouse_xy[0], mouse_xy[1])
$game_player.find_path(mouse_xy[0], mouse_xy[1])
end
@last_click = mouse_xy
end
if Mouse.click?(3) and !mouse_xy.nil? and !$game_message.visible and
!$game_map.interpreter.running?
$game_player.clear_path
$game_player.turn_toward_pos(mouse_xy[0], mouse_xy[1])
end
end
end
#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
def turn_toward_pos(x,y)
sx = distance_x_from_pos(x)
sy = distance_y_from_pos(y)
if sx.abs > sy.abs
sx > 0 ? turn_left : turn_right
elsif sx.abs < sy.abs
sy > 0 ? turn_up : turn_down
end
end
def distance_x_from_pos(x)
sx = @x - x
if $game_map.loop_horizontal?
if sx.abs > $game_map.width / 2
sx -= $game_map.width
end
end
return sx
end
def distance_y_from_pos(y)
sy = @y - y
if $game_map.loop_vertical?
if sy.abs > $game_map.height / 2
sy -= $game_map.height
end
end
return sy
end
def close?(x,y)
sx = (@x - x).abs
sy = (@y - y).abs
if sx + sy == 1
return true
end
return false
end
end
Depois, faça seu cursor com 32 pixels x 32 pixels e coloque na pasta System chamado "fox_cursor"
Acho que para mudar o nome do arquivo é no script ...
Na pasta System da demo tinha esse ícone aqui chamado mecha_icon, não sei praquê serve ...
Os cursores suportam transparência no fundo das imagens (é claro ¬¬')
Sim, foram esses que eu achei! +1 Pedra Lunar, tinha perdido esses scripts
Dungeon22- Mensagens : 399
Data de inscrição : 14/07/2010
Localização : Na minha casa
Re: [pedido vx] "setas" pro game
Nossa, fail meu xD
Nem notei a raposa ali xD
Nem notei a raposa ali xD
G@briel!- Mensagens : 104
Data de inscrição : 13/07/2010
Idade : 27
Localização : Posto de chegada na base lunar
Tópicos semelhantes
» [Pedido/VX] Pedido Avançado de Pular
» [Pedido Ultra simples ] Não poder andar pelas setas
» [Pedido] Game Over
» [DISPONDO]Setas indicativas.
» [PEDIDO]Script que o boneco cria sua popria arma[PEDIDO]
» [Pedido Ultra simples ] Não poder andar pelas setas
» [Pedido] Game Over
» [DISPONDO]Setas indicativas.
» [PEDIDO]Script que o boneco cria sua popria arma[PEDIDO]
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos