/!\Ceci est un tuto pour rpg maker et non pour le R-H/!\
Bonjour à tous,
marre de la pokéflute ou on ne fait que "utiliser" alors ce script est pour vous
En premier, ajoutez ces 4 scripts:
PS: les deux premiers scripts sont de lloyd,le troisième de Zeus81 et le quatrième de General_Yorr
Spoiler
PokePiano
Interface_PokéPiano
Souris
Clavier
Ensuite remplacez le script "Tactile" par celui ci :
Tactile
Code: [Sélectionner]
#==============================================================================
# ■ PokePiano
#-----------------------------------------------------------------------------
# Scène modifiable
#-----------------------------------------------------------------------------
# Utilisation :: Faites "insérer un script" et mettez $scene = PokePiano.new
#-----------------------------------------------------------------------------
module POKEMON_S
class PokePiano < Window_Base
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
super(0,0,640,480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.z = 11
@interface2 = Sprite.new
@interface2.x = 13
@interface2.y = 200-19
@interface2.z = 20
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
@interface = Interface_Piano.new
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@interface.dispose
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@spriteset.update
@interface.update
# コマンドウィンドウがアクティブの場合: update_command を呼ぶ
update_command
end
def dispose
super
end
#--------------------------------------------------------------------------
# ● フレーム更新 (コマンドウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_command
# B ボタンが押された場合
if Input.trigger?(Input::B)
$scene = Scene_Map.new
return
end
if TACTILE.det_clique_release(14+8,14+8+19,228,228+81+39) or Input.trigger?(Keys::KEY_Q)
Audio.se_play("Audio/SE/" + "piano0.mp3", 100, 100)
end
if TACTILE.det_clique_release(14+18+10,16+26+10,228,228+81) or TACTILE.det_clique_release(14+18+10,51+10,228+81,228+39+81) or Input.trigger?(Keys::KEY_S)
Audio.se_play("Audio/SE/" + "piano1.mp3", 100, 100)
end
if TACTILE.det_clique_release(42+10,42+13+10,228,228+81) or Input.trigger?(Keys::KEY_E)
Audio.se_play("Audio/SE/" + "piano2.mp3", 100, 100)
$scene = PokePiano.new
end
if TACTILE.det_clique_release(52+4+10,52+4+10+9,228,228+81) or TACTILE.det_clique_release(52+10,52+10+19,228+81,228+39+81) or Input.trigger?(Keys::KEY_D)
Audio.se_play("Audio/SE/" + "piano3.mp3", 100, 100)
end
if TACTILE.det_clique_release(64+10,64+10+13,228,228+81) or Input.trigger?(Keys::KEY_R)
Audio.se_play("Audio/SE/" + "piano4.mp3", 100, 100)
end
if TACTILE.det_clique_release(77+10,77+10+9,228,228+81) or TACTILE.det_clique_release(72+10,72+10+19,228+81,228+39+81) or Input.trigger?(Keys::KEY_F)
Audio.se_play("Audio/SE/" + "piano5.mp3", 100, 100)
end
if TACTILE.det_clique_release(77+10+9,86+10+13,228,228+81) or Input.trigger?(Keys::KEY_T)
Audio.se_play("Audio/SE/" + "piano6.mp3", 100, 100)
end
if TACTILE.det_clique_release(99+10,99+10+12,228,228+81) or TACTILE.det_clique_release(92+10,92+10+19,228+81,228+39+81) or Input.trigger?(Keys::KEY_G)
Audio.se_play("Audio/SE/" + "piano7.mp3", 100, 100)
end
if TACTILE.det_clique_release(112+10,112+10+11,228,228+81) or TACTILE.det_clique_release(112+10,112+10+19,228+81,228+39+81) or Input.trigger?(Keys::KEY_V)
Audio.se_play("Audio/SE/" + "piano8.mp3", 100, 100)
end
if TACTILE.det_clique_release(123+10,123+10+13,228,228+81) or Input.trigger?(Keys::KEY_Y)
Audio.se_play("Audio/SE/" + "piano9.mp3", 100, 100)
end
if TACTILE.det_clique_release(136+10,136+10+11,228,228+81) or TACTILE.det_clique_release(132+10,132+10+19,228+81,228+39+81) or Input.trigger?(Keys::KEY_B)
Audio.se_play("Audio/SE/" + "piano10.mp3", 100, 100)
end
if TACTILE.det_clique_release(147+10,147+10+13,228,228+81) or Input.trigger?(Keys::KEY_U)
Audio.se_play("Audio/SE/" + "piano11.mp3", 100, 100)
end
if TACTILE.det_clique_release(160+10,160+10+11,228,228+81) or TACTILE.det_clique_release(152+10,152+10+19,228+81,228+39+81) or Input.trigger?(Keys::KEY_N)
Audio.se_play("Audio/SE/" + "piano12.mp3", 100, 100)
end
if TACTILE.det_clique_release(172+10,172+10+10,228,228+81) or TACTILE.det_clique_release(172+10,172+10+19,228+81,228+39+81) or Input.trigger?(Keys::KEY_J)
Audio.se_play("Audio/SE/" + "piano13.mp3", 100, 100)
end
if TACTILE.det_clique_release(182+10,182+10+13,228,228+81) or Input.trigger?(Keys::KEY_I)
Audio.se_play("Audio/SE/" + "piano14.mp3", 100, 100)
end
if TACTILE.det_clique_release(195+10,190+10+14,228,228+81) or TACTILE.det_clique_release(192+10,192+10+19,228+81,228+39+81) or Input.trigger?(Keys::KEY_K)
Audio.se_play("Audio/SE/" + "piano15.mp3", 100, 100)
end
if TACTILE.det_clique_release(204+10,204+10+13,228,228+81) or Input.trigger?(Keys::KEY_O)
Audio.se_play("Audio/SE/" + "piano16.mp3", 100, 100)
end
if TACTILE.det_clique_release(217+10,212+14+10,228,228+81) or TACTILE.det_clique_release(212+10,212+10+19,228+81,228+39+81) or Input.trigger?(Keys::KEY_L)
Audio.se_play("Audio/SE/" + "piano17.mp3", 100, 100)
end
if TACTILE.det_clique_release(226+10,226+13+10,228,228+81) or Input.trigger?(Keys::KEY_P)
Audio.se_play("Audio/SE/" + "piano18.mp3", 100, 100)
end
if TACTILE.det_clique_release(239+10,239+10+12,228,228+81) or TACTILE.det_clique_release(232+10,232+10+19,228+81,228+39+81) or Input.trigger?(Keys::KEY_M)
Audio.se_play("Audio/SE/" + "piano19.mp3", 100, 100)
end
return
end
end
end
Interface_PokéPiano
Code: [Sélectionner]
#==============================================================================
# ■ Interface_Piano
#-----------------------------------------------------------------------------
# Scène modifiable
#-----------------------------------------------------------------------------
# Interface graphique du PokéPiano
#-----------------------------------------------------------------------------
class Interface_Piano < Window_Base
include POKEMON_S
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.opacity = 0
self.z = 21
@interface = Sprite.new
@interface.x = 13
@interface.y = 227
@interface.z = 30
refresh
end
def dispose
super
@interface.dispose
end
def refresh
@interface.bitmap = RPG::Cache.picture("PokéPiano.png")
end
end
Souris
Code: [Sélectionner]
# Mouse Ultimate v1.2
# Il y a trois touches possibles : Mouse::LEFT, Mouse::RIGHT et Mouse::MIDDLE
# pour respectivement clic gauche, clic droit et clic milieu.
# Vous pouvez trouvez les fonctions trigger?, press? et repeat? comme dans Input
# Mais aussi Mouse.release?(key) pour voir si une touche est relachée
# et Mouse.double_trigger?(key) pour les double clics.
# On récupère les coordonnées du curseur avec Mouse.x et Mouse.y
# On peut aussi déplacer le curseur avec Mouse.x = new_x et Mouse.y = new_y
# Pour changer la visibilité du curseur : Mouse.visible = true ou false
# Ajouts v1.2 :
# Optimisation des performances.
# Vous pouvez sélectionner l'image du curseur ligne 44.
# La souris est mise à jour automatiquement tant qu'elle est visible.
unless Input.method_defined?(:zeus_mouse_update)
class << Input
alias zeus_mouse_update update
def update
Mouse.update if Mouse.visible
zeus_mouse_update
end
end
end
module Mouse
FindWindow = Win32API.new("user32", "FindWindow", "PP", "I")
ShowCursor = Win32API.new("user32", "ShowCursor", "I", "I" )
GetKeyState = Win32API.new("user32", "GetKeyState", "I", "I")
GetCursorPos = Win32API.new("user32", "GetCursorPos", "P", "I")
SetCursorPos = Win32API.new("user32", "SetCursorPos", "II", "I")
ScreenToClient = Win32API.new("user32", "ScreenToClient", "IP", "I")
ClientToScreen = Win32API.new("user32", "ClientToScreen", "IP", "I")
GetDoubleClickTime = Win32API.new("user32", "GetDoubleClickTime", "", "I")
LEFT, RIGHT, MIDDLE = 1, 2, 4
HWindow = FindWindow.call("RGSS Player", open("Game.ini") {|f|
f.read=~/^\s*Title\s*=(.*)$/i ? $1.strip : "Untitled"})
DoubleClickTime = GetDoubleClickTime.call*Graphics.frame_rate/1000
RA, RB = Graphics.frame_rate*4/10, Graphics.frame_rate/10
Cursor = Sprite.new
Cursor.z, Cursor.visible = 0xFFFF, false
begin
Cursor.bitmap = Bitmap.new("Graphics/Pictures/Cursor.png")
rescue
Cursor.bitmap = Bitmap.new(8, 8)
Cursor.bitmap.fill_rect(0, 0, 3, 7, Color.new(0,0,0))
Cursor.bitmap.fill_rect(0, 0, 7, 3, Color.new(0,0,0))
Cursor.bitmap.fill_rect(5, 5, 3, 3, Color.new(0,0,0))
Cursor.bitmap.fill_rect(1, 1, 1, 5, Color.new(255,255,255))
Cursor.bitmap.fill_rect(1, 1, 5, 1, Color.new(255,255,255))
Cursor.bitmap.fill_rect(6, 6, 1, 1, Color.new(255,255,255))
end
@@pos, @@count = "\0"*8, {LEFT=>[0, 0], RIGHT=>[0, 0], MIDDLE=>[0, 0]}
def self.update
GetCursorPos.call(@@pos)
ScreenToClient.call(HWindow, @@pos)
Cursor.x, Cursor.y = @@pos.unpack("ii")
dct = Graphics.frame_count - DoubleClickTime
for k,v in @@count
v[0] = get_press(k) ? v[0]+1 : v[0]>0 ? -1 : 0
v[1] = v[1]>dct ? v[0]==1 ? -1 : v[1] : v[0]==1 ? Graphics.frame_count : 0
end
end
def self.press?(k) valid?(k) and @@count[k][0] > 0 end
def self.trigger?(k) valid?(k) and @@count[k][0] == 1 end
def self.double_trigger?(k) valid?(k) and @@count[k][1] == -1 end
def self.release?(k) valid?(k) and @@count[k][0] == -1 end
def self.repeat?(k) valid?(k) and ((c=@@count[k][0])==1 or (c>RA and c%RB==0)) end
def self.x() Cursor.x end
def self.y() Cursor.y end
def self.visible() Cursor.visible end
def self.x=(x) set_pos(x, y) end
def self.y=(y) set_pos(x, y) end
def self.visible=(v)
loop {break if v ? ShowCursor.call(0)<0 : ShowCursor.call(1)>0}
Cursor.visible = v
end
private
def self.valid?(k) @@count.include?(k) end
def self.get_press(k) GetKeyState.call(k)[15] == 1 end
def self.set_pos(x, y)
pos = [Cursor.x=x, Cursor.y=y].pack("ii")
ClientToScreen.call(HWindow, pos)
SetCursorPos.call(*pos.unpack("ii"))
end
end
Mouse.visible = true
Clavier
Code: [Sélectionner]
module Keys
KEY_SOURISGAUCHE = 0x01 # LEFT MOUSE Keys
KEY_BACK = 0x08 # BACKSPACE Keys
KEY_TAB = 0x09 # TAB Keys
KEY_RETURN = 0x0D # ENTER Keys
KEY_SHIFT = 0x10 # SHIFT Keys
KEY_PAUSE = 0x13 # PAUSE Keys
KEY_CAPITAL = 0x14 # CAPS LOCK Keys
KEY_CAPSLOCK = 0x14 # CAPS LOCK Key
KEY_ESCAPE = 0x1B # ESC Keys
KEY_SPACE = 0x20 # SPACEBAR
KEY_PRIOR = 0x21 # PAGE UP Keys
KEY_NEXT = 0x22 # PAGE DOWN Keys
KEY_END = 0x23 # END Keys
KEY_HOME = 0x24 # HOME Keys
KEY_LEFT = 0x25 # LEFT ARROW Keys
KEY_UP = 0x26 # UP ARROW Keys
KEY_RIGHT = 0x27 # RIGHT ARROW Keys
KEY_DOWN = 0x28 # DOWN ARROW Keys
KEY_SELECT = 0x29 # SELECT Keys
KEY_PRINT = 0x2A # PRINT Keys
KEY_SNAPSHOT = 0x2C # PRINT SCREEN Keys
KEY_INSERT = 0x2D # INS Keys
KEY_DELETE = 0x2E # DEL Keys
KEY_0 = 0x30 # 0 Keys
KEY_1 = 0x31 # 1 Keys
KEY_2 = 0x32 # 2 Keys
KEY_3 = 0x33 # 3 Keys
KEY_4 = 0x34 # 4 Keys
KEY_5 = 0x35 # 5 Keys
KEY_6 = 0x36 # 6 Keys
KEY_7 = 0x37 # 7 Keys
KEY_8 = 0x38 # 8 Keys
KEY_9 = 0x39 # 9 Keys
KEY_A = 0x41 # A Keys
KEY_B = 0x42 # B Keys
KEY_C = 0x43 # C Keys
KEY_D = 0x44 # D Keys
KEY_E = 0x45 # E Keys
KEY_F = 0x46 # F Keys
KEY_G = 0x47 # G Keys
KEY_H = 0x48 # H Keys
KEY_I = 0x49 # I Keys
KEY_J = 0x4A # J Keys
KEY_K = 0x4B # K Keys
KEY_L = 0x4C # L Keys
KEY_M = 0x4D # M Keys
KEY_N = 0x4E # N Keys
KEY_O = 0x4F # O Keys
KEY_P = 0x50 # P Keys
KEY_Q = 0x51 # Q Keys
KEY_R = 0x52 # R Keys
KEY_S = 0x53 # S Keys
KEY_T = 0x54 # T Keys
KEY_U = 0x55 # U Keys
KEY_V = 0x56 # V Keys
KEY_W = 0x57 # W Keys
KEY_X = 0x58 # X Keys
KEY_Y = 0x59 # Y Keys
KEY_Z = 0x5A # Z Keys
KEY_LWIN = 0x5B # Left Windows Keys (Microsoft Natural Keysboard)
KEY_RWIN = 0x5C # Right Windows Keys (Natural Keysboard)
KEY_APPS = 0x5D # Applications Keys (Natural Keysboard)
KEY_NUMPAD0 = 0x60 # Numeric Keyspad 0 Keys
KEY_NUMPAD1 = 0x61 # Numeric Keyspad 1 Keys
KEY_NUMPAD2 = 0x62 # Numeric Keyspad 2 Keys
KEY_NUMPAD3 = 0x63 # Numeric Keyspad 3 Keys
KEY_NUMPAD4 = 0x64 # Numeric Keyspad 4 Keys
KEY_NUMPAD5 = 0x65 # Numeric Keyspad 5 Keys
KEY_NUMPAD6 = 0x66 # Numeric Keyspad 6 Keys
KEY_NUMPAD7 = 0x67 # Numeric Keyspad 7 Keys
KEY_NUMPAD8 = 0x68 # Numeric Keyspad 8 Keys
KEY_NUMPAD9 = 0x69 # Numeric Keyspad 9 Keys
KEY_MULTIPLY = 0x6A # Multiply Keys (*)
KEY_ADD = 0x6B # Add Keys (+)
KEY_SEPARATOR = 0x6C # Separator Keys
KEY_SUBTRACT = 0x6D # Subtract Keys (-)
KEY_DECIMAL = 0x6E # Decimal Keys
KEY_DIVIDE = 0x6F # Divide Keys (/)
KEY_F1 = 0x70 # F1 Keys
KEY_F2 = 0x71 # F2 Keys
KEY_F3 = 0x72 # F3 Keys
KEY_F4 = 0x73 # F4 Keys
KEY_F5 = 0x74 # F5 Keys
KEY_F6 = 0x75 # F6 Keys
KEY_F7 = 0x76 # F7 Keys
KEY_F8 = 0x77 # F8 Keys
KEY_F9 = 0x78 # F9 Keys
KEY_F10 = 0x79 # F10 Keys
KEY_F11 = 0x7A # F11 Keys
KEY_F12 = 0x7B # F12 Keys
KEY_NUMLOCK = 0x90 # NUM LOCK Keys
KEY_SCROLL = 0x91 # SCROLL LOCK Keys
KEY_LSHIFT = 0xA0 # Left SHIFT Keys
KEY_RSHIFT = 0xA1 # Right SHIFT Keys
KEY_LCONTROL = 0xA2 # Left CONTROL Keys
KEY_RCONTROL = 0xA3 # Right CONTROL Keys
KEY_L_ALT = 0xA4 # Left ALT Keys
KEY_R_ALT = 0xA5 # Right ALT Keys
KEY_SEP = 0xBC # , Keys
KEY_DASH = 0xBD # - Keys
KEY_DOTT = 0xBE # . Keys
#par berka -----------------------------------------
KEY_POURCENT = 0xC0 # % or ù Keys
KEY_DOLLARD = 0xBA # $ Keys
KEY_UNDER = 0xDD # ^ Keys
KEY_STAR = 0xDC # * or µ Keys
KEY_DDOTT = 0xBF # : keys
KEY_DEG = 0xDB # ) or ° keys
KEY_DOTTS = 0xDF # ! keys
KEY_SQUARD = 0xDE # ² key
for i in self.constants
attr_reader i
end
module_function
def each
for i in self.constants
yield self.const_get(i)
end
end
end
module Input
# Constants that need to be defined for overriding purposes
F5 = Keys::KEY_F5
F6 = Keys::KEY_F6
F7 = Keys::KEY_F7
F8 = Keys::KEY_F8
F9 = Keys::KEY_F9
UP = 1000
DOWN = 1001
LEFT = 1002
RIGHT = 1003
A = 2000
B = 2001
C = 2002
X = 3000
Y = 3001
Z = 3002
R = 4000
L = 4001
SHIFT = 5000
CTRL = 5001
ALT = 5002
for i in self.constants
attr_reader i
end
@KeysMap = Hash.new
@trigger = Hash.new(false)
@repeat = Hash.new(false)
@toggle = Hash.new(false)
@counts = Hash.new(0)
@delay = 5 # The number of frames in which repeat? will only return true once
# an array containing all the Keyss that correspond to the direction up, down,
# left, right, 'A', 'B', 'C', 'X', 'Y', 'Z', 'L', 'R', SHIFT, CTRL, and ALT,
# respectively.
@KeysMap[UP] = [Keys::KEY_UP]
@KeysMap[DOWN] = [Keys::KEY_DOWN]
@KeysMap[LEFT] = [Keys::KEY_LEFT]
@KeysMap[RIGHT] = [Keys::KEY_RIGHT]
@KeysMap[A] = [Keys::KEY_LSHIFT, Keys::KEY_RSHIFT, Keys::KEY_Z]
@KeysMap[B] = [Keys::KEY_ESCAPE, Keys::KEY_NUMPAD0, Keys::KEY_X]
@KeysMap[C] = [Keys::KEY_SPACE, Keys::KEY_RETURN, Keys::KEY_C]
@KeysMap[X] = [Keys::KEY_A]
@KeysMap[Y] = [Keys::KEY_S]
@KeysMap[Z] = [Keys::KEY_D]
@KeysMap[L] = [Keys::KEY_Q]
@KeysMap[R] = [Keys::KEY_W]
@KeysMap[SHIFT] = [Keys::KEY_SHIFT, Keys::KEY_LSHIFT, Keys::KEY_RSHIFT]
@KeysMap[CTRL] = [Keys::KEY_LCONTROL, Keys::KEY_RCONTROL]
@KeysMap[ALT] = [Keys::KEY_L_ALT, Keys::KEY_R_ALT]
@KeyStates = 0.chr * 256
@getKeyStates = Win32API.new('user32', 'GetKeyboardState', ['P'], 'N')
for i in Keys
@trigger = false
@repeat = false
@counts = 4
end
module_function
# Determines whether the button num was pressed agian at the last update.
# "Pressed again" is seen as time having passed between the button being not
# pressed and being pressed.
# If the button is being pressed, returns TRUE. If not, returns FALSE.
def trigger?(num)
if @KeysMap.has_key?(num)
for i in @KeysMap[num]
return true if @trigger
end
return false
end
return @trigger[num]
end
alias triggered? trigger?
# Determines whether the button num was being pressed at the last update.
# Unlike trigger?, takes into account the repeat input of a button being held
# down continuously.
# If the button is being pressed, returns TRUE. If not, returns FALSE.
# Has a delay to prevent things from moving to fast, E.G. menu indecies.
def repeat?(num)
if @KeysMap.has_key?(num)
for i in @KeysMap[num]
return true if(@repeat and @counts == 0)
end
return false
end
return (@repeat[num] and @counts == 0)
end
alias repeated? repeat?
alias repeating? repeat?
# Same as repeat without the delay
def press?(num)
if @KeysMap.has_key?(num)
for i in @KeysMap[num]
return true if @repeat
end
return false
end
return @repeat
end
alias pressed? press?
def toggle?(num)
if @KeysMap.has_key?(num)
return false if @KeysMap[num].size != 1
return @toggle[@KeysMap[num][0]]
end
return @toggle[num]
end
alias toggled? toggle?
# Checks the status of the directional buttons, translates the data into a
# specialized 4-direction input format, and returns the number pad equivalent
# (2, 4, 6, 8) .
# If no directional buttons are being pressed (or the equivalent), returns 0.
def dir4
dir = 0
for i in @KeysMap[UP]
if @repeat
dir = 8
end
end
for i in @KeysMap[DOWN]
if @repeat
if dir == 0
dir = 2
else
return 0
end
end
end
for i in @KeysMap[LEFT]
if @repeat
if dir == 0
dir = 4
else
return 0
end
end
end
for i in @KeysMap[RIGHT]
if @repeat
if dir == 0
dir = 6
else
return 0
end
end
end
return dir
end
# Checks the status of the directional buttons, translates the data into a
# specialized 8-direction input format, and returns the number pad equivalent
# (1, 2, 3, 4, 6, 7, 8, 9).
# If no directional buttons are being pressed (or the equivalent), returns 0.
def dir8
dir = dir4
if dir > 0
return dir
end
for i in @KeysMap[UP]
if @repeat
dir = 8
end
end
for i in @KeysMap[LEFT]
if @repeat
case dir
when 0, 4
dir = 4
when 7, 8
dir = 7
end
end
end
for i in @KeysMap[RIGHT]
if @repeat
case dir == 0
when 0, 6
dir = 6
when 4, 9
dir = 9
else
return 0
end
end
end
for i in @KeysMap[DOWN]
if @repeat
case dir
when 0, 2
dir = 2
when 3, 6
dir = 3
when 1, 4
dir = 1
else
return 0
end
end
end
return dir
end
# Updates input data. As a rule, this method is called once per frame.
def update
@getKeyStates.call(@KeyStates)
for i in Keys
@toggle = (@KeyStates & 0x01 == 0x01)
if (@KeyStates & 0x80 > 0)
@trigger = !@repeat
@repeat = true
@counts += 1
@counts %= @delay
else
@repeat = false
@trigger = false
@counts = -1
end
end
end
# Additional functions of use
def getKeys(keyType)
if @KeysMap.has_key?(keyType)
return @KeysMap[keyType].dup
end
return [keyType]
end
def addKey(keyType, key)
legit = true
@KeysMap.each_key {| i | legit = remKey(i, key)}
return false if !legit
if @KeysMap.has_key?(keyType)
@KeysMap[keyType] = @KeysMap[keyType] | [key]
else
@KeysMap[KeyType] = [key]
end
return true
end
def addKeys(keyType, keys)
legits = Hash.new(false)
for i in keys
legits = addKey(keyType, i)
end
return legits
end
def removeKey(keyType, key)
return true if !@KeysMap.has_key?(keyType)
return false if @KeysMap[keyType] == [key]
@KeysMap[keyType] -= key
return true
end
def removeKeys(keyType, keys)
return true if !@KeysMap.has_key?(keyType)
return false if @KeysMap[keyType].size <= keys.size
for i in keys
return false if !@KeysMap[keyType].include?(i)
end
for i in keys
@KeysMap[keyType].remove(i)
end
return true
end
alias remKey removeKey
alias remKeys removeKeys
def removeGroup(keyGroup)
return false if !@KeysMap.has_key?(keyGroup)
@KeysMap[keyGroup] = []
return true;
end
alias remGroup removeGroup
def removeGroups(keyGroups)
ligits = Hash.new(false)
for i in keyGroups
ligits = removeGroup(i)
end
return legits
end
end
Ensuite remplacez le script "Tactile" par celui ci :
Tactile
Code: [Sélectionner]
#==============================================================================#
# Script de gestion de la souris
# Amélioré par Sunmat
# N'oubliez pas d'inclure le DLL à la racine du jeu
# Donner par Youri
#==============================================================================#
# Mouse.mouse_pos
module Mouse
gsm = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
@cursor_pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
module_function
# Variables globales contenant la position de la souris
$mouse_x = 0
$mouse_y = 0
# Position de la souris sur l'écran de l'ordinateur
def mouse_global_pos
pos = [0, 0].pack('ll')
if @cursor_pos.call(pos) != 0
return pos.unpack('ll')
else
return nil
end
end
# Position de la souris sur l'écran du jeu
def mouse_pos(catch_anywhere = false)
x, y = screen_to_client(*mouse_global_pos)
width, height = client_size
$mouse_x = x
$mouse_y = y
return x, y
end
def del
if @oldcursor == nil
return
else
@SetClassLong.call(handel ,-12, @oldcursor)
@oldcursor = nil
end
end
end
$scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
$client_rect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
$readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
$findwindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
# Fonction de conversion de la position sur l'écran à la position sur le jeu
def screen_to_client(x, y)
return nil unless x and y
pos = [x, y].pack('ll')
if $scr2cli.call(hwnd, pos) != 0
return pos.unpack('ll')
else
return nil
end
end
# Fonction de collecte des données de la fenêtre du jeu
def hwnd
game_name = "\0" * 256
$readini.call('Game','Title','',game_name,255,".\\Game.ini")
game_name.delete!("\0")
return $findwindow.call('RGSS Player',game_name)
end
# Fonction de collecte de la taille de la fenêtre
def client_size
rect = [0, 0, 0, 0].pack('l4')
$client_rect.call(hwnd, rect)
right, bottom = rect.unpack('l4')[2..3]
return right, bottom
end
module TACTILE
def self.det_clique(x,xmax,y,ymax)
$dx=x
$dx1=xmax
$dy=y
$dy1=ymax
Mouse.mouse_pos
if $mouse_x >= $dx and $mouse_x <= $dx1 and $mouse_y >= $dy and $mouse_y<= $dy1 and ms_rl
return true
end
end
def self.det_clique_release(x,xmax,y,ymax)
$dx=x
$dx1=xmax
$dy=y
$dy1=ymax
Mouse.mouse_pos
if $mouse_x >= $dx and $mouse_x <= $dx1 and $mouse_y >= $dy and $mouse_y<= $dy1 and Mouse.release?(Mouse::LEFT)
return true
end
end
end
#==================================#
# Detection de la touche #
# Fait par Yourii54 #
# Grâce à un script de Slash #
#==================================#
def ms_rl
return true unless Win32API.new("user32","GetKeyState",['i'],'i').call(0x01).between?(0, 1)
return false
end
Enfin ajoutez ces sons dans le dossier Audio/SE
http://www.megaupload.com/?d=0DBCYH8B
Et ces images dans le dossier Pictures
Nom : Cursor
Nom : PokePiano
Explication ::
Le piano est tactile mais il y a aussi des touches pour chaque note que voici:
Note1 = Q Note11 = B
Note2 = S Note12(noir) = U
Note3(noir) = E Note13 = N
Note4 = D Note14 = J
Note5(noir) = R Note15(noir) = I
Note6 = F Note16 = K
Note7(noir) = T Note17(noir) = O
Note8 = G Note18 = L
Note9 = V Note19(noir) = P
Note10(noir) = Y Note20 = M
Pour afficher le Piano, il faut "insérer un script" et y mettre $scene = PokePiano.new
Pour faire à ce que si une certaine mélodie est joué tel interrupteur est activé allez dans le script PokePiano et sur les notes que vous
voulez être joué vous rajoutez après if ce qui suit:
Code: [Sélectionner]
if $game_variables[256] = 0
$game_variables[256] + 1
end
Vous changez le 0 par le numéro de passage de la note moins 1
exemple: 1ère note = 0
2ème note = 1
14ème note = 13
et pour la dernière note vous rajoutez avant le end
Code: [Sélectionner]
$game_switches[XX] = true #xx étant le numéro de votre interrupteur
$scene = Scene_Map.new
Facultatif:si vous voulez en faire un objet vous avez besion de:Un nouvel objet
Un nouvel evenement commun
Tout d'abord vous cliquer sur l'icone de la base de données, ensuite vous allez onglet Objet.
Vous créer un nouvel objet apellé "Piano" ou "PokePiano".Il faut qu'il appelle le nouvel evenement commun que nous allons créer.Vous allez onglet EC(Evenement Commun), sur l'EC que votre objet appelle.Cilquez sur "<>" ensuite vous allez page 3, appeller un script et vous mettez
Code: [Sélectionner]
$scene = PokePiano.new
et vous cliquer sur "OK" 3 fois.En espérant que ça plaira à quelqu'un.