Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Moving player/events with mouse

Mouse event moving system
]Version: 0.3

Introduction

This script allows events movments with the mouse

Features
  • Rect Selector
  • Full Screen Cursor display

Screenshots
sans_t16.png


Demo
none

Script

Code:
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#        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 Curseur_Mod
    Bmp_Curs='Graphics/System/Curseur.png'
    Scroll_Actif=true
  end
  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::Curseur_Mod
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
#===========================================
# Sprite_Curseur
#                                 par Berka
#===========================================
class Sprite_Curseur<Sprite_Base
  def initialize
    super
    Win32API.new('user32','ShowCursor','i','i').call(0)
    self.z=5000
    creer_curseur(Bmp_Curs)
    update
  end
  def creer_curseur(curseur="")
    (self.bitmap=Bitmap.new(curseur);return)rescue nil
    self.bitmap=Bitmap.new(24,24)
    bitmap=Cache.system("Iconset")
    rect=Rect.new(2%16*24,2/16*24,24,24)
    self.bitmap.blt(0,0,bitmap,rect)
  end
  def update;super;self.x,self.y=Mouse.pos;end
  def dispose;super;end
end
Curseur=Sprite_Curseur.new
#===========================================
# 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<Sprite
  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<Scene_Base
  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
module Graphics
  class<<self
    alias :graphics_update :update unless Graphics.methods.include?('graphics_update')
    def update
      graphics_update
      Curseur.update
    end
  end
end
Code:
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#         Déplacement/selection d'events a la souris
#   berka                    0.2                     Rgss1
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#               http://www.rpgmakervx-fr.com
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

#===========================================
# Mouse
#           par Berka d'apres SephirothSpawn
#===========================================
module Berka
  module Curseur_Mod
    Bmp_Curs='Graphics/System/Curseur.png'
    Scroll_Actif=true
  end
  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)
  end
end

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')
  @mouse_menu=0
  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
#===========================================
# Sprite_Curseur
#                                 par Berka
#===========================================
class Sprite_Curseur < RPG::Sprite
  def initialize
    super
    Win32API.new('user32','ShowCursor','i','i').call(0)
    self.z=5000
    creer_curseur(Berka::Curseur_Mod::Bmp_Curs)
    update
  end
  def creer_curseur(curseur="")
    (self.bitmap=Bitmap.new(curseur);return)rescue nil
    self.bitmap=Bitmap.new(24,24)
    bitmap=RPG::Cache.icon("001-Weapon01")
    rect=Rect.new(0,0,24,24)
    self.bitmap.blt(0,0,bitmap,rect)
  end
  def update;super;self.x,self.y=Mouse.pos;end
  def dispose;super;end
end
Curseur=Sprite_Curseur.new
#===========================================
# Pathfinding
#                         par SephirothSpawn
#===========================================
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=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&&y+1==sy
        if $game_map.passable?(x,y,2)&&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,4)&&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,6)&&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,8)&&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<Sprite
  def initialize
    super
    self.x,self.y=Mouse.pos
    self.z=5000
    self.bitmap=Bitmap.new(640,480)
    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,Berka::Deplace_Event::Couleur_Cadre_Selection) 
    self.bitmap.fill_rect(1,1,cib_x-2,cib_y-2,Berka::Deplace_Event::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,Mouse.pos[0]-self.x)&&y.between?(self.y,Mouse.pos[1]-self.y)
    return false
  end
end
#===========================================
# Scene_Map: Select
#                                  par Berka
#===========================================
class Scene_Map
  alias :select_main :main
  alias :select_update :update
  def main
    @rect=Rect_Select.new
    @x,@y,@events=Mouse.pos[0],Mouse.pos[1],[]
    select_main
    @spriteset = Spriteset_Map.new
    @message_window = Window_Message.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      break if $scene != self
    end
    Graphics.freeze
    @spriteset.dispose
    @message_window.dispose
    @rect.dispose
    if $scene.is_a?(Scene_Title)
      Graphics.transition
      Graphics.freeze
    end
  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==Berka::Deplace_Event::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==Berka::Deplace_Event::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=[]
      else;$game_player.find_path(Mouse.grid[0],Mouse.grid[1])
      end  
    elsif Mouse.click?(3)
      @events=[]
    end
  end
end
module Graphics
  class<<self
    alias :graphics_update :update unless Graphics.methods.include?('graphics_update')
    def update
      graphics_update
      Curseur.update
    end
  end
end
Instructions
write:
in each event's commentbox to allow it to move
left button to select, right to move

FAQ
place it above main

Compatibility
I don't know

Credits and Thanks
Near Fantastica: Mouse module
SephirothSpawn : Pathfinding and Mouse module additions

Terms and Conditions
Free but Credits are needed
 
The original author of the module Mouse and Pathfinding was Near Fantastica. Though I did some modifications, Near is the original author. If you are going to credit either of us, credit him.
 
@seph' : all right, I've updated credits.

@gameline: you select events with the rect selector and click right to move them
 
sorry for bumping this topic, but I just realize I forgot to translate something:

You 've to add a comment for each event with the word bouge to be able to move it
 

Jason

Awesome Bro

Okay well in the script on line 130 I got an error, the line was:

Code:
      move_right if @map[@x+1,@y]==step-1&!=0

So I changed it to;

Code:
      move_right if @map[@x+1,@y]==step-1&&step!=0

And now it works, however, the events only move if I left click them and right click somewhere, I can't move more than one at a time, the rectangle selector doesn't work, unless I highlight the whole screen and click somewhere, then 3 of the 4 events move, one doesn't, any idea why ?
 

Jason

Awesome Bro

berka":1t9ejfp2 said:
thanks, i 'll correct it

Just wondering, the error in the script, or the "not being able to drag the rectangle selection over an event and allowing it to move" ? lol

It's still a really nice script, I mean, it'd do fine for me having to click an event and right clicking to make it move, cause it would make use in alot of ideas I have for games, but I mean, if the selection did work properly, then RMXP/VX could also become RTS Makers too, lol

Oh also another "iffy problem" I see, it's the pathfinding, if you're stood for example, at the side of the wall, and you click at the other side of it, your character/event doesn't move to the other side, they just stay still, however, stand one tile away from the wall and try it, and it works fine, is there any way this could be fixed ? If not it doesn't matter, it's not THAT much of a problem.

Thanks.
 
yeah, this quite an old pathfinding system... I used it, since it's short, but it doesn't manage event/player collisions.
If someone has a better or faster pathfinding...
 

Jason

Awesome Bro

berka":39t3ldvz said:
yeah, this quite an old pathfinding system... I used it, since it's short, but it doesn't manage event/player collisions.
If someone has a better or faster pathfinding...

Hmm if I were to find another pathfinding script (More up-to-date), and placed it ABOVE this script, would it overwrite the pathfinding in this script ?
 
You cant use this script on full screen because your cursor disappears

That, and I tried to test this out and I made a made that had a width of 60 and it got to a certain point where my character would move 1 space forward, Id click again, and he'd just run back several steps D:
 
@jony: I add a cursor sprite


if you use Modern Algebra's pathfinding system, you can change the scene map rewriting (end of the script)
Code:
class Scene_Map<Scene_Base
  alias :select_update :update
  alias :select_start :start
  alias :select_terminate :terminate
  def start
    select_start
    @rect,@x,@y,@events=Rect_Select.new,Souris.pos[0],Souris.pos[1],[]
  end
  def update
    select_update
    @rect.visible=false
    if !Input.press?(Input::WLEFT);@x,@y=Souris.pos[0],Souris.pos[1] 
      else;@rect.visible=true;@rect.update(@x,@y)
        (@events<<$game_player)if @rect.chk_dessous?($game_player.x*32,$game_player.y*32)
          for event in $game_map.events.values
            ((@events<<event)if @rect.chk_dessous?(event.x*32,event.y*32))if event.list[0].parameters==Commentaire.to_a
          end
        end
      if Input.press?(Input::WLEFT)
        for event in $game_map.events.values
          (@events<<event if Souris.grid==[event.x,event.y])if event.list[0].parameters==Commentaire.to_a
        end
      elsif Input.press?(Input::WRIGHT)
        if !@events.empty?
          @events.each{|event|event.force_path(Souris.grid[0],Souris.grid[1])
          @events.delete(event)}
        else;$game_player.force_path(Souris.grid[0],Souris.grid[1]);end  
      elsif Input.press?(Input::WMIDDLE);@events.clear;end
  end
  def terminate;select_terminate;@rect.dispose;end
end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top