Suporte no desenvolvimento de jogos


    [SYS] Mouse Event Moving Script

    Felix Blayder
    Felix Blayder
    Membro de Honra
    Membro de Honra

    Mensagens : 1406
    Créditos : 219

    Ficha do personagem
    Nível: 1
    Experiência:
    [SYS] Mouse Event Moving Script Left_bar_bleue0/0[SYS] Mouse Event Moving Script Empty_bar_bleue  (0/0)
    Vida:
    [SYS] Mouse Event Moving Script Left_bar_bleue30/30[SYS] Mouse Event Moving Script Empty_bar_bleue  (30/30)

    [SYS] Mouse Event Moving Script Empty [SYS] Mouse Event Moving Script

    Mensagem por Felix Blayder em Ter Ago 16, 2011 7:43 am

    Mouse Sistem
    Creditos:

    Sepiroth Spawn > Criador
    Berka > Criador
    Felix Blayder > por trazer o script até ao aldeia.

    Comentários:
    Bem com esse script da pra selecionar a area, mover o personagem e os objetos com o mouse (para movimentar cliquei com o botão direito do mouse), achei bem legal, e diferencia dos outros scripts.

    Atenção: O script ñ funciona com netplays, mais da pra modificar....

    Scren:

    [SYS] Mouse Event Moving Script Sanst16

    Script:
    Spoiler:
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # Déplacement/selection d'events a la souris
    # berka 0.3 Rgss2
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # http://www.rpgmakervx-fr.com
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    #===========================================
    # Mouse
    # par Berka d'apres SephirothSpawn
    #===========================================
    module Berka
    module Deplace_Event
    Commentaire="bouge" # pour distinguer les events déplacables
    Couleur_Cadre_Selection=Color.new(0,255,50,255)
    Couleur_Fond_Selection=Color.new(0,255,50,75)
    Icone='Graphics/system/icone.ico'
    end
    end
    include Berka::Deplace_Event
    module Mouse
    GetAsyncKeyState=Win32API.new("user32","GetAsyncKeyState",'i','i')
    GetKeyState=Win32API.new("user32","GetKeyState",'i','i')
    SetCursorPos=Win32API.new('user32','SetCursorPos','nn','n')
    GetCursorPo=Win32API.new('user32','GetCursorPos','p','i')
    ScreenToClient=Win32API.new('user32','ScreenToClient','lp','i')
    GetPrivateProfileStringA=Win32API.new('kernel32','GetPrivateProfileStringA','pppplp','l')
    FindWindowA=Win32API.new('user32','FindWindowA','pp','l')
    GetClientRect=Win32API.new('user32','GetClientRect','lp','i')
    GetWindowRect=Win32API.new('user32','GetWindowRect','lp','i')
    game_name="\0"*256
    GetPrivateProfileStringA.call('Game','Title','',game_name,255,".\\Game.ini")
    game_name.delete!("\0")
    @handle=FindWindowA.call('RGSS Player',game_name)
    module_function
    def click?(button)
    return true if @keys.include?(button)
    return false
    end
    def press?(button)
    return true if @press.include?(button)
    return false
    end
    def set_pos(x_pos=0,y_pos=0)
    width,height=client_size
    if (x_pos.between?(0,width)&&y_pos.between?(0,height))
    SetCursorPos.call(client_pos[0]+x_pos,client_pos[1]+y_pos)
    end
    end
    def update
    @pos=Mouse.pos
    @keys,@press=[],[]
    @keys.push(1)if GetAsyncKeyState.call(1)&0x01==1
    @keys.push(2)if GetAsyncKeyState.call(2)&0x01==1
    @keys.push(3)if GetAsyncKeyState.call(4)&0x01==1
    @press.push(1)if pressed?(1)
    @press.push(2)if pressed?(2)
    @press.push(3)if pressed?(4)
    end
    def pressed?(key)
    return true unless GetKeyState.call(key).between?(0,1)
    return false
    end
    def global_pos
    pos=[0,0].pack('ll')
    GetCursorPo.call(pos)!=0 ? (return pos.unpack('ll')):(return nil)
    end
    def pos
    x,y=screen_to_client(*global_pos)
    width,height=client_size
    begin
    x=0 if x<=0;y=0 if y<=0
    x=width if x>=width;y=height if y>=height
    return x,y
    end
    end
    def screen_to_client(x,y)
    return nil unless x&&y
    pos=[x,y].pack('ll')
    ScreenToClient.call(@handle,pos)!=0?(return pos.unpack('ll')):(return nil)
    end
    def client_size
    rect=[0,0,0,0].pack('l4')
    GetClientRect.call(@handle,rect)
    right,bottom=rect.unpack('l4')[2..3]
    return right,bottom
    end
    def client_pos
    rect=[0,0,0,0].pack('l4')
    GetWindowRect.call(@handle,rect)
    left,upper=rect.unpack('l4')[0..1]
    return left+4,upper+30
    end
    def grid
    return nil if @pos.nil?
    return [(@pos[0]+$game_map.display_x/8)/32,(@pos[1]+$game_map.display_y/8)/32]
    end
    end
    #===========================================
    # Pathfinding
    # par SephirothSpawn
    #===========================================
    include Input
    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,@runpath=nil,false
    end
    def update
    run_path if @runpath
    nf_pf_game_character_update
    end
    def run_path
    return if moving?
    step=@map[@x,@y]
    (@map,@runpath=nil,false;return)if step==1
    case rand(2)
    when 0
    move_right if @map[@x+1,@y]==step-1&&step!=0
    move_down if @map[@x,@y+1]==step-1&&step!=0
    move_left if @map[@x-1,@y]==step-1&&step!=0
    move_up if @map[@x,@y-1]==step-1&&step!=0
    when 1
    move_up if @map[@x,@y-1]==step-1&&step!=0
    move_left if @map[@x-1,@y]==step-1&&step!=0
    move_down if @map[@x,@y+1]==step-1&&step!=0
    move_right if @map[@x+1,@y]==step-1&&step!=0
    end
    end
    def find_path(x,y)
    sx,sy=@x,@y
    result=setup_map(sx,sy,x,y)
    @runpath,@map=result[0],result[1]
    @map[sx,sy]=result[2] if !result[2].nil?
    end
    def clear_path;@map,@runpath=nil,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=10
    depth.upto(100){|step|
    loop do
    break if old_positions[0].nil?
    x,y=old_positions.shift
    return [true,map,step] if x==sx&&y+1==sy
    if $game_map.passable?(x,y)&&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&&y==sy
    if $game_map.passable?(x,y)&&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&&y==sy
    if $game_map.passable?(x,y)&&map[x+1,y]==0
    map[x+1,y]=step
    new_positions.push([x+1,y])
    end
    return [true,map,step] if x==sx&&y-1==sy
    if $game_map.passable?(x,y)&&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
    for event in events.values
    event.clear_path
    end
    end
    end
    #===========================================
    # Rect Select
    # par Berka
    #===========================================
    class Rect_Select def initialize
    super
    self.x,self.y=Mouse.pos
    self.bitmap=Bitmap.new(544,416)
    self.visible=false
    end
    def update(ox=0,oy=0)
    self.visible=true
    self.bitmap.clear
    (Mouse.pos[0]-ox>0)?(self.x=ox;@cib_x=Mouse.pos[0]-self.x):(self.x=Mouse.pos[0];@cib_x=ox-Mouse.pos[0])
    (Mouse.pos[1]-oy>0)?(self.y=oy;@cib_y=Mouse.pos[1]-self.y):(self.y=Mouse.pos[1];@cib_y=oy-Mouse.pos[1])
    self.bitmap.fill_rect(0,0,@cib_x,@cib_y,Couleur_Cadre_Selection)
    self.bitmap.fill_rect(1,1,@cib_x-2,@cib_y-2,Couleur_Fond_Selection)
    end
    def chk_dessous?(x,y)
    x-=$game_map.display_x/8
    y-=$game_map.display_y/8
    return true if x.between?(self.x,@cib_x)&&y.between?(self.y,@cib_y)
    return false
    end
    end
    #===========================================
    # Scene_Map: Select
    # par Berka
    #===========================================
    class Scene_Map alias :select_update :update
    alias :select_start :start
    alias :select_terminate :terminate
    def start
    select_start
    @rect=Rect_Select.new
    @x,@y,@events=Mouse.pos[0],Mouse.pos[1],[]
    @base=[]
    end
    def update
    Mouse.update
    select_update
    @rect.visible=false
    if !Mouse.press?(1);@x,@y=Mouse.pos[0],Mouse.pos[1]
    else;@rect.visible=true;@rect.update(@x,@y)
    for event in $game_map.events.values
    if event.list[0].parameters==Commentaire.to_a
    (@events << event) if @rect.chk_dessous?(event.x*32,event.y*32)
    end
    end
    end
    if Mouse.click?(1)
    for event in $game_map.events.values
    if event.list[0].parameters==Commentaire.to_a
    @events << event if Mouse.grid==[event.x,event.y]
    end
    end
    elsif Mouse.click?(2)
    if !@events.empty?
    @events.each{|event|event.find_path(Mouse.grid[0],Mouse.grid[1])
    @events.delete(event) if event.runpath}
    @events.clear
    else;$game_player.find_path(Mouse.grid[0],Mouse.grid[1])
    end
    elsif Mouse.click?(3)
    @events.clear
    end
    end
    def terminate
    select_terminate
    @rect.dispose
    end
    end

    Demo:
    Ainda ñ tem, e to com preguiça de fazer.....


    _________________

    Se inscreva em meu Canal no YouTube:
    https://www.youtube.com/localnerd

    Faça uma doação para ajudar nos custos:

    https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3N8T2RJ977RCQ

    DeaN
    DeaN
    Colaborador
    Colaborador

    Mensagens : 1243
    Créditos : 48

    [SYS] Mouse Event Moving Script Empty Re: [SYS] Mouse Event Moving Script

    Mensagem por DeaN em Ter Ago 16, 2011 10:52 am

    Legal Cara 1+


    _________________
    Dean, Programador Geral :)

    Contato: Skype:matucarvalho e Facebook
    The Enze - Vulzt

    Shield Block
    Anti-Cheat para jogos de FPS, agora vou adaptar para jogos de RPG principalmente para o RMXP.
    www.shieldblock.net
    fb.com/shieldblockoficial

    [SYS] Mouse Event Moving Script MiB0H
    Hanna.A
    Hanna.A
    Iniciante
    Iniciante

    Mensagens : 55
    Créditos : 31

    [SYS] Mouse Event Moving Script Empty Re: [SYS] Mouse Event Moving Script

    Mensagem por Hanna.A em Ter Ago 16, 2011 11:40 am

    Muito Bom
    Espero que Saia Um desses Pra XP ^-^
    +1 Credito Taáh ?!


    _________________
    [SYS] Mouse Event Moving Script IcxBy6
    Felix Blayder
    Felix Blayder
    Membro de Honra
    Membro de Honra

    Mensagens : 1406
    Créditos : 219

    Ficha do personagem
    Nível: 1
    Experiência:
    [SYS] Mouse Event Moving Script Left_bar_bleue0/0[SYS] Mouse Event Moving Script Empty_bar_bleue  (0/0)
    Vida:
    [SYS] Mouse Event Moving Script Left_bar_bleue30/30[SYS] Mouse Event Moving Script Empty_bar_bleue  (30/30)

    [SYS] Mouse Event Moving Script Empty Re: [SYS] Mouse Event Moving Script

    Mensagem por Felix Blayder em Ter Ago 16, 2011 12:12 pm

    @Hanna.A escreveu:Muito Bom
    Espero que Saia Um desses Pra XP ^-^
    +1 Credito Taáh ?!

    já tem pra xp e o nome é o mesmo c vc pesquisar vc acha... só ñ postei porq tava com preguiça, c vc ñ postar depois eu posto.


    _________________

    Se inscreva em meu Canal no YouTube:
    https://www.youtube.com/localnerd

    Faça uma doação para ajudar nos custos:

    https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3N8T2RJ977RCQ

    ZeroXP
    ZeroXP
    Membro Ativo
    Membro Ativo

    Mensagens : 341
    Créditos : 31

    [SYS] Mouse Event Moving Script Empty Re: [SYS] Mouse Event Moving Script

    Mensagem por ZeroXP em Qua Ago 17, 2011 12:54 pm

    e bem legal, obrigado por compartilhar
    +1 Cred por disponibilizar!


    _________________
    Clique e ajude a Lunact Cast !
    [SYS] Mouse Event Moving Script 15yi05i

    Conteúdo patrocinado

    [SYS] Mouse Event Moving Script Empty Re: [SYS] Mouse Event Moving Script

    Mensagem por Conteúdo patrocinado


      Data/hora atual: Qua Jun 03, 2020 11:00 pm