Eu quero fazer o seguinte.
usar um evento comum para que toda vez que a tecla for pressionada alterar o gráfico do herói ate ai blz.
Sendo que eu estou usando um Input module no teclado. (abs pearl)
Então como ficaria o comando?
tipo um Input.trigger?(:C)
Ou como funciona o comando sem que o jogador aperte a tecla?
um pedaço do script
# Pearl ABS Input module
module PearlKey
# numbers
N0 = 0x30; N1 = 0x31; N2 = 0x32; N3 = 0x33; N4 = 0x34
N5 = 0x35; N6 = 0x36; N7 = 0x37; N8 = 0x38; N9 = 0x39
# keys
A = 0x41; B = 0x42; C = 0x43; D = 0x44; E = 0x45
F = 0x46; G = 0x47; H = 0x48; I = 0x49; J = 0x4A
K = 0x4B; L = 0x4C; M = 0x4D; N = 0x4E; O = 0x4F
P = 0x50; Q = 0x51; R = 0x52; S = 0x53; T = 0x54
U = 0x55; V = 0x56; W = 0x57; X = 0x58; Y = 0x59; Z = 0x5A
@unpack_string = 'b'*256
@last_array = '0'*256
@press = Array.new(256, false)
@trigger = Array.new(256, false)
@release = Array.new(256, false)
@getKeyboardState = Win32API.new('user32', 'GetKeyboardState', ['P'], 'V')
@getAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
@getKeyboardState.call(@last_array)
@last_array = @last_array.unpack(@unpack_string)
for i in 0...@last_array.size
@press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
end
def self.update
@trigger = Array.new(256, false)
@release = Array.new(256, false)
array = '0'*256
@getKeyboardState.call(array)
array = array.unpack(@unpack_string)
for i in 0...array.size
if array[i] != @last_array[i]
@press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
if !@press[i]
@release[i] = true
else
@trigger[i] = true
end
else
if @press[i] == true
@press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
@release[i] = true if !@press[i]
end
end
end
@last_array = array
end
def self.press?(key)
return @press[key]
end
def self.trigger?(key)
return @trigger[key]
end
end
Um cara desenvolvendo um jogo de RPG...
" Faça o melhor que puder em tudo, simples assim."
- Hategum RPG.