Night.png);">
Apprendre


Vous êtes
nouveau sur
Oniromancie?

Visite guidée
du site


Découvrir
RPG Maker

RM 95
RM 2000/2003
RM XP
RM VX/VX Ace
RM MV/MZ

Apprendre
RPG Maker

Tutoriels
Guides
Making-of

Dans le
Forum

Section Entraide

Sorties: "Dread Mac Farlane", (...) / Tutos: Checklist de la composition (...) / Sorties: Dread Mac Farlane - episode 8 / Sorties: Dread Mac Farlane - episode 7 / Jeux: Ce qui vit Dessous / Chat

Bienvenue
visiteur !




publicité RPG Maker!

Statistiques

Liste des
membres


Contact

Mentions légales

331 connectés actuellement

29425488 visiteurs
depuis l'ouverture

9715 visiteurs
aujourd'hui



Barre de séparation

Partenaires

Indiexpo

Akademiya RPG Maker

Blog Alioune Fall

Fairy Tail Constellations

Eclipso

New RPG Maker

RPG Maker Détente

Kingdom Ultimate

Level Up!

Tous nos partenaires

Devenir
partenaire



Déplacer le héros avec la souris

Permet de diriger le héros avec la souris.

Script pour RPG Maker XP
Ecrit par SephirothSpawn et Berka
Publié par Berka (lui envoyer un message privé)
Signaler un script cassé

❤ 0

Logiciel : RPG Maker XP
Nombre de scripts : 3
Options : 1

Description : Ce script permet de diriger le héros a l'aide de la souris.

Crédits : SephirothSpawn (base), Berka (ajouts)

# clic gauche: definir le point d'arrivée
# clic droit: suivre/ne pas suivre le héros
# touche directionnelles: deplacer la map

a placer au dessus de main, dans l'ordre :

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#===========================================
#                      Module Keyboard/Mouse
#                        par SephirothSpawn
#===========================================
 
module Keyboard
  @keys = []
  @pressed = []
  Mouse_Left = 1
  Mouse_Right = 2
  State = Win32API.new("user32","GetKeyState",['i'],'i')
  Key = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
  def Keyboard.getstate(key)
    return true unless State.call(key).between?(0, 1)
    return false
  end
  def Keyboard.testkey(key)
    Key.call(key) & 0x01 == 1
  end
  def Keyboard.update
    @keys = []
    @keys.push(Keyboard::Mouse_Left) if Keyboard.testkey(Keyboard::Mouse_Left)
    @keys.push(Keyboard::Mouse_Right) if Keyboard.testkey(Keyboard::Mouse_Right)
    @pressed = []
    @pressed.push(Keyboard::Mouse_Left) if Keyboard.getstate(Keyboard::Mouse_Left)
    @pressed.push(Keyboard::Mouse_Right) if Keyboard.getstate(Keyboard::Mouse_Right)
  end
  def Keyboard.trigger?(key)
    return true if @keys.include?(key)
    return false
  end
  def Keyboard.pressed?(key)
    return true if @pressed.include?(key)
    return false
  end
end
 
module Mouse
  @mouse_menu = 0
  def Mouse.click?(button)
    return true if @keys.include?(button)
    return false
  end  
  def Mouse.press?(button)
    return true if @press.include?(button)
    return false
  end
  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
  def Mouse.pixels
    return @pos == nil ? [0, 0] : @pos
  end
  def Mouse.tiles
    return nil if @pos == nil
    x = @pos[0] / 32
    y = @pos[1] / 32
    return [x, y]
  end
  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
  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  
  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
  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
  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
  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
  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
  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  
  def Mouse.grid
    return nil if @pos == nil
    offsetx = $game_map.display_x / 8
    offsety = $game_map.display_y / 8
    x = (@pos[0] + offsetx) / 32
    y = (@pos[1] + offsety) / 32
    return [x, y]
  end
end



Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#===========================================
#                          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 = 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



Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#===========================================
#                      Mouvement par souris
#                            par berka
#===========================================
#
# clic gauche: definir le point d'arrivée
# clic droit: suivre/ne pas suivre le héros
# touche directionnelles: deplacer la map
#===========================================
 
 
Vitesse = 8  #vitesse du scroll de la map
 
class Scene_Map
  alias scroll_update update
  def update
    Keyboard.update
    Mouse.update
    if Keyboard.trigger?(Keyboard::Mouse_Left)
      $game_player.find_path(Mouse.grid[0], Mouse.grid[1])
    end
    scroll_update
  end
end
class Game_Player < Game_Character
  alias scroll_init initialize
  def initialize
    scroll_init
    @scroll = false 
  end
  def update
    last_real_x = @real_x
    last_real_y = @real_y
    last_moving = moving?
    move_by_input
    super
    if Keyboard.trigger?(Keyboard::Mouse_Right)
      if @scroll == false
        $game_player.center($game_player.x, $game_player.y) 
        @scroll = true
      else
        @scroll = false
      end
    end
    @scroll = false if Input.dir4 != 0
    $game_player.update_scroll(last_real_x, last_real_y) if @scroll == true    
    update_vehicle
    update_nonmoving(last_moving)
  end
  def move_by_input
    return unless movable?
    return if $game_map.interpreter.running?
    case Input.dir4
    when 2; $game_map.start_scroll(2, 1, Vitesse)
    when 4; $game_map.start_scroll(4, 1, Vitesse)
    when 6; $game_map.start_scroll(6, 1, Vitesse)
    when 8; $game_map.start_scroll(8, 1, Vitesse)
    end
  end
end






Z-Raptor (visiteur non enregistré) - posté le 25/08/2008 à 00:50:41

❤ 0

Idem ce script est cool sa marche impect j'ai RMVX


quesquonsenfout (visiteur non enregistré) - posté le 28/09/2008 à 21:25:14

❤ 0

le forum n'existe plus :'(


Monos - posté le 28/09/2008 à 21:32:50 (57322 messages postés)

❤ 0

Vive le homebrew

ga? quelle forum?

Signer du nez ?


makeur pro (visiteur non enregistré) - posté le 01/10/2008 à 18:24:01

❤ 0

Génial!Mais...en mode pleine on voit pas la souris!
Il n'y aurait pas un truc?...Par hazard?...:hihi


makeur pro (visiteur non enregistré) - posté le 06/10/2008 à 14:33:25

❤ 0

ON fait comment svp?


yop - posté le 09/07/2010 à 18:45:03 (296 messages postés)

❤ 0

à quoi sert exactement le clic droit ?

"Thousands of years ago the old empire had enforced the Pax Morporkia, which had said to the world: 'Do not fight or we will kill you.' The Pax had arisen again, but this time it said: 'If you fight, we'll call in your mortgages. And incidentally, that's my pike you're pointing at me. I paid for that shield you're holding. And take my helmet off when you speak to me, you horrible little debtor.'" ~Terry Pratchett, Feet of Clay

Suite à de nombreux abus, le post en invités a été désactivé. Veuillez vous inscrire si vous souhaitez participer à la conversation.

Haut de page

Merci de ne pas reproduire le contenu de ce site sans autorisation.
Contacter l'équipe - Mentions légales

Plan du site

Communauté: Accueil | Forum | Chat | Commentaires | News | Flash-news | Screen de la semaine | Sorties | Tests | Gaming-Live | Interviews | Galerie | OST | Blogs | Recherche
Apprendre: Visite guidée | RPG Maker 95 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker MV | Tutoriels | Guides | Making-of
Télécharger: Programmes | Scripts/Plugins | Ressources graphiques / sonores | Packs de ressources | Midis | Eléments séparés | Sprites
Jeux: Au hasard | Notre sélection | Sélection des membres | Tous les jeux | Jeux complets | Le cimetière | RPG Maker 95 | RPG Maker 2000 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker VX Ace | RPG Maker MV | Autres | Proposer
Ressources RPG Maker 2000/2003: Chipsets | Charsets | Panoramas | Backdrops | Facesets | Battle anims | Battle charsets | Monstres | Systems | Templates
Ressources RPG Maker XP: Tilesets | Autotiles | Characters | Battlers | Window skins | Icônes | Transitions | Fogs | Templates
Ressources RPG Maker VX: Tilesets | Charsets | Facesets | Systèmes
Ressources RPG Maker MV: Tilesets | Characters | Faces | Systèmes | Title | Battlebacks | Animations | SV/Ennemis
Archives: Palmarès | L'Annuaire | Livre d'or | Le Wiki | Divers