Mémoire d'Ames
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.

Mémoire d'Ames

Forum du jeu amateur Mémoire d'Ames.
 
AccueilPortailRechercherDernières imagesS'enregistrerConnexion
Le Deal du moment :
Cartes Pokémon EV6.5 : où trouver le ...
Voir le deal

 

 Déplacement Réaliste -> 8 Directions ~ Courir

Aller en bas 
2 participants
AuteurMessage
Sire
Troufion
Troufion
Sire


Nombre de messages : 25
Age : 32
Localisation : -M-D-A's Forum-
Date d'inscription : 29/04/2007

Déplacement Réaliste -> 8 Directions ~ Courir Empty
MessageSujet: Déplacement Réaliste -> 8 Directions ~ Courir   Déplacement Réaliste -> 8 Directions ~ Courir Icon_minitimeDim 29 Avr - 19:07

Ce script permet au personnage de bouger dans 8 directions au lieu de 4 et permet de courir sur la map en maintenant la touche "Espace" du Clavier. C'est une réunion de plusieurs scripts de déplacements différents, c'est le script ultime ( Pour Moi Wink ) !
<1> Créez un script au-dessus de "Main" portant le nom de "Game_Player2". <1>
<2> Collez le code ultime à l'intérieur! <2>

Code:
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# œ ’è”
#--------------------------------------------------------------------------
UP = 48 # ã•ûŒü‚Ì—]—T(0 < UP < 63)
DOWN = 16 # ‰º•ûŒü‚Ì—]—T(0 < DOWN <63)
SIDE = 32 # ¶‰E•ûŒü‚Ì—]—T(0 < SIDE <63)
SLANT = false # ˆÚ“®ƒ‹[ƒg‚̎΂߈ړ®ŽžA‘¬“xC³
#--------------------------------------------------------------------------
# œ ŒöŠJƒCƒ“ƒXƒ^ƒ“ƒX•Ï”
#--------------------------------------------------------------------------
attr_reader :event # ƒCƒxƒ“ƒgŽžˆÚ“®‘¬“x
attr_accessor :move_speed # ˆÚ“®‘¬“x
#--------------------------------------------------------------------------
# œ ƒtƒŒ[ƒ€XV
#--------------------------------------------------------------------------
alias :update_original :update
def update
# @walk:•às‘¬“x @dash:ƒ_ƒbƒVƒ…ŽžˆÚ“®‘¬“x
# @event:ƒCƒxƒ“ƒgŽžˆÚ“®‘¬“xi0‚ÌŽž‚ÍAƒCƒxƒ“ƒgŽž‚É‘¬“x•ÏX‚ð‚µ‚È‚¢j
@walk = 4
@dash = 5
@event = 4
@dot_m = true
#ƒ_ƒbƒVƒ…‹@”BƒGƒ“ƒ^[ƒL[‚ª‰Ÿ‚³‚ê‚Ä‚¢‚éŠÔAˆÚ“®‘¬“x‚ð•ÏX‚·‚éB
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
if @walk != @dash
if Input.press?(Input::C)
if @move_speed != @dash
@move_speed = @dash
end
else
if @move_speed != @walk
@move_speed = @walk
end
end
end
end
if @revise_x == nil and @revise_y == nil
@revise_x = 0
@revise_y = 0
end
unless @dot_m
update_original
return
end
if @move_route_forcing
# ƒ[ƒJƒ‹•Ï”‚Ɉړ®’†‚©‚Ç‚¤‚©‚ð‹L‰¯
last_moving = moving?
# ƒ[ƒJƒ‹•Ï”‚ÉÀ•W‚ð‹L‰¯
last_real_x = @real_x
last_real_y = @real_y
# À•W‚ª‚¸‚ê‚Ä‚¢‚éê‡
if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
@revise_x = @real_x - @x * 128
@revise_y = @real_y - @y * 128
end
# ˆÚ“®‹——£distance1‚Æ–Ú•W‹——£distance2‚ðÝ’è
distance1 = 2 ** @move_speed
distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
# ˆÚ“®‹——£‚ª–Ú•W‹——£‚ð‰z‚¦‚½ê‡
if distance1 > distance2
# ‹­§“I‚É•â³À•W‚ð—ë‚É‚·‚é
@real_x = @real_x - @revise_x
@real_y = @real_y - @revise_y
@revise_x = 0
@revise_y = 0
anime_update
# ˆÚ“®‹——£‚ª–Ú•W‹——£‚É’B‚µ‚È‚¢ê‡
else
# ˆÚ“®‹——£•ª–Ú•W‹——£‚ɋ߂­
@real_x -= (distance1 * @revise_x / distance2).round
@real_y -= (distance1 * @revise_y / distance2).round
@revise_x = @real_x - @x * 128
@revise_y = @real_y - @y * 128
anime_update
end
else
super
end
else
@move = false
# ˆÚ“®’†AƒCƒxƒ“ƒgŽÀs’†AˆÚ“®ƒ‹[ƒg‹­§’†A
# ƒƒbƒZ[ƒWƒEƒBƒ“ƒhƒE•Ž¦’†‚Ì‚¢‚¸‚ê‚Å‚à‚È‚¢ê‡
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
@event_run = false
# •ûŒüƒ{ƒ^ƒ“‚ª‰Ÿ‚³‚ê‚Ä‚¢‚ê‚ÎA‚»‚Ì•ûŒü‚ÖƒvƒŒƒCƒ„[‚ðˆÚ“®
case Input.dir8

when 1
move_lower_left_p
when 2
move_down_p
when 3
move_lower_right_p
when 4
move_left_p
when 6
move_right_p
when 7
move_upper_left_p
when 8
move_up_p
when 9
move_upper_right_p
end
end
# ƒ[ƒJƒ‹•Ï”‚ÉÀ•W‚ð‹L‰¯
last_real_x = @real_x
last_real_y = @real_y
# ˆÚ“®ˆ—
@real_x = @x * 128 + @revise_x
@real_y = @y * 128 + @revise_y
# ƒ[ƒJƒ‹•Ï”‚Ɉړ®’†‚©‚Ç‚¤‚©‚ð‹L‰¯
last_moving = moving?
# À•WXV
move_on
# Œ»Ý‚ÌÀ•W‚ƈȑO‚ÌÀ•W‚ªˆÙ‚È‚éê‡
if (last_real_x != @real_x or last_real_y != @real_y)
@move_distance = 0 if @move_distance == nil
@move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
(last_real_y - @real_y) ** 2)
if @move_distance >= 128
@move_distance %= 128
increase_steps
end
# ƒAƒjƒ[ƒVƒ‡ƒ“‚ðXV
anime_update
else
@pattern = 0
end
end
# ƒLƒƒƒ‰ƒNƒ^[‚ª‰º‚Ɉړ®‚µA‚©‚‰æ–Êã‚̈ʒu‚ª’†‰›‚æ‚艺‚Ìê‡
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# ƒ}ƒbƒv‚ð‰º‚ÉƒXƒNƒ[ƒ‹
$game_map.scroll_down(@real_y - last_real_y)
end
# ƒLƒƒƒ‰ƒNƒ^[‚ª¶‚Ɉړ®‚µA‚©‚‰æ–Êã‚̈ʒu‚ª’†‰›‚æ‚趂Ìê‡
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# ƒ}ƒbƒv‚ð¶‚ɃXƒNƒ[ƒ‹
$game_map.scroll_left(last_real_x - @real_x)
end
# ƒLƒƒƒ‰ƒNƒ^[‚ª‰E‚Ɉړ®‚µA‚©‚‰æ–Êã‚̈ʒu‚ª’†‰›‚æ‚è‰E‚Ìê‡
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# ƒ}ƒbƒv‚ð‰E‚ɃXƒNƒ[ƒ‹
$game_map.scroll_right(@real_x - last_real_x)
end
# ƒLƒƒƒ‰ƒNƒ^[‚ªã‚Ɉړ®‚µA‚©‚‰æ–Êã‚̈ʒu‚ª’†‰›‚æ‚èã‚Ìê‡
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# ƒ}ƒbƒv‚ðã‚ɃXƒNƒ[ƒ‹
$game_map.scroll_up(last_real_y - @real_y)
end
# ‘O‰ñƒvƒŒƒCƒ„[‚ªˆÚ“®’†‚¾‚Á‚½ê‡
if last_moving
# “¯ˆÊ’u‚̃Cƒxƒ“ƒg‚Æ‚ÌÚG‚É‚æ‚éƒCƒxƒ“ƒg‹N“®”»’è
result = check_event_trigger_here([1,2])
# ‹N“®‚µ‚½ƒCƒxƒ“ƒg‚ª‚È‚¢ê‡
if result == false
# ƒfƒoƒbƒOƒ‚[ƒh‚ª ON ‚©‚ CTRL ƒL[‚ª‰Ÿ‚³‚ê‚Ä‚¢‚éꇂ𜂫
unless $DEBUG and Input.press?(Input::CTRL)
# ƒGƒ“ƒJƒEƒ“ƒg ƒJƒEƒ“ƒgƒ_ƒEƒ“
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# C ƒ{ƒ^ƒ“‚ª‰Ÿ‚³‚ꂽê‡
if Input.trigger?(Input::C)
# “¯ˆÊ’u‚¨‚æ‚ѳ–ʂ̃Cƒxƒ“ƒg‹N“®”»’è
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
#--------------------------------------------------------------------------
# œ ƒIƒuƒWƒFƒNƒg‰Šú‰»

#--------------------------------------------------------------------------
def initialize
@revise_x = 0
@revise_y = 0
@move == false
super
end
#--------------------------------------------------------------------------
# œ ˆÚ“®”»’è
#--------------------------------------------------------------------------
def moving?
unless @dot_m
result = super
return result
end
# ‹­§ˆÚ“®‚ÌꇃIƒŠƒWƒiƒ‹‚Ì”»’è‚ð‚³‚¹‚é
if @move_route_forcing
if @move == false
return false
end
super
# ’Ê펞‚ÍŒ»À•W‚ªŽÀÀ•W‚ƈقȂéꇂ݈̂ړ®’†‚Æ”»’è
else
return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
end
end
#--------------------------------------------------------------------------
# œ ˆÚ“®”»’è
#--------------------------------------------------------------------------
def moving_a?
if @move == false
if (@move_route.list[@move_route_index].code <= 14 or
@move_route.list[@move_route_index].code == 25)
@move = true
end
return false
end
moving?
end
#--------------------------------------------------------------------------
# œ ƒtƒŒ[ƒ€XV (ƒWƒƒƒ“ƒv)
#--------------------------------------------------------------------------
def update_jump
# ƒWƒƒƒ“ƒvƒJƒEƒ“ƒg‚ð 1 Œ¸‚ç‚·
@jump_count -= 1
# V‚µ‚¢À•W‚ðŒvŽZ
@real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
@real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
if @jump_count == 0
@revise_x = 0
@revise_y = 0
end
end
#--------------------------------------------------------------------------
# œ ˆÚ“®ƒ^ƒCƒv : ƒJƒXƒ^ƒ€
#--------------------------------------------------------------------------
def move_type_custom
unless @dot_m
super
return
end
# ’âŽ~’†‚Å‚È‚¯‚ê‚Î’†’f
if jumping? or moving_a?
return
end
# ˆÚ“®ƒRƒ}ƒ“ƒh‚̃ŠƒXƒg‚ÌÅŒã‚É“ž’B‚·‚é‚܂Ń‹[ƒv
while @move_route_index < @move_route.list.size
# ˆÚ“®ƒRƒ}ƒ“ƒh‚ðŽæ“¾
command = @move_route.list[@move_route_index]
# ƒRƒ}ƒ“ƒhƒR[ƒh 0 ”Ô (ƒŠƒXƒg‚ÌÅŒã) ‚Ìê‡
if command.code == 0
# ƒIƒvƒVƒ‡ƒ“ [“®ì‚ðŒJ‚è•Ô‚·] ‚ª ON ‚Ìê‡
if @move_route.repeat
# ˆÚ“®ƒ‹[ƒg‚̃Cƒ“ƒfƒbƒNƒX‚ðʼn‚É–ß‚·
@move_route_index = 0
end
# ƒIƒvƒVƒ‡ƒ“ [“®ì‚ðŒJ‚è•Ô‚·] ‚ª OFF ‚Ìê‡
unless @move_route.repeat
# ˆÚ“®ƒ‹[ƒg‹­§’†‚Ìê‡
if @move_route_forcing and not @move_route.repeat
# ˆÚ“®ƒ‹[ƒg‚Ì‹­§‚ð‰ðœ
@move_route_forcing = false
# ƒIƒŠƒWƒiƒ‹‚̈ړ®ƒ‹[ƒg‚𕜋A
@move_route = @original_move_route
@move_route_index = @original_move_route_index
@original_move_route = nil
end
# ’âŽ~ƒJƒEƒ“ƒg‚ðƒNƒŠƒA
@stop_count = 0
end
return
end
# ˆÚ“®ŒnƒRƒ}ƒ“ƒh (‰º‚Ɉړ®`ƒWƒƒƒ“ƒv) ‚Ìê‡
if command.code <= 14
# ƒRƒ}ƒ“ƒhƒR[ƒh‚Å•ªŠò
case command.code
when 1 # ‰º‚Ɉړ®
move_down
when 2 # ¶‚Ɉړ®
move_left
when 3 # ‰E‚Ɉړ®
move_right
when 4 # ã‚Ɉړ®
move_up
when 5 # ¶‰º‚Ɉړ®
move_lower_left
when 6 # ‰E‰º‚Ɉړ®
move_lower_right
when 7 # ¶ã‚Ɉړ®
move_upper_left
when 8 # ‰Eã‚Ɉړ®
move_upper_right
when 9 # ƒ‰ƒ“ƒ_ƒ€‚Ɉړ®
move_random
when 10 # ƒvƒŒƒCƒ„[‚ɋ߂­
move_toward_player
when 11 # ƒvƒŒƒCƒ„[‚©‚牓‚´‚©‚é
move_away_from_player
when 12 # ˆê•à‘Oi
move_forward
when 13 # ˆê•àŒã‘Þ
move_backward
when 14 # ƒWƒƒƒ“ƒv
jump(command.parameters[0], command.parameters[1])
end
# ƒIƒvƒVƒ‡ƒ“ [ˆÚ“®‚Å‚«‚È‚¢ê‡‚Í–³Ž‹] ‚ª OFF ‚ÅAˆÚ“®Ž¸”s‚Ìê‡
if not @move_route.skippable and not moving? and not jumping?
return
end
@move_route_index += 1
return
end
# ƒEƒFƒCƒg‚Ìê‡
if command.code == 15
# ƒEƒFƒCƒgƒJƒEƒ“ƒg‚ðÝ’è
@wait_count = command.parameters[0] * 2 - 1
@move_route_index += 1
return
end
# Œü‚«•ÏXŒn‚̃Rƒ}ƒ“ƒh‚Ìê‡
if command.code >= 16 and command.code <= 26
# ƒRƒ}ƒ“ƒhƒR[ƒh‚Å•ªŠò
case command.code
when 16 # ‰º‚ðŒü‚­
turn_down
when 17 # ¶‚ðŒü‚­
turn_left
when 18 # ‰E‚ðŒü‚­
turn_right
when 19 # ã‚ðŒü‚­
turn_up
when 20 # ‰E‚É 90 “x‰ñ“]
turn_right_90
when 21 # ¶‚É 90 “x‰ñ“]
turn_left_90
when 22 # 180 “x‰ñ“]
turn_180
when 23 # ‰E‚©¶‚É 90 “x‰ñ“]
turn_right_or_left_90
when 24 # ƒ‰ƒ“ƒ_ƒ€‚É•ûŒü“]Š·
turn_random
when 25 # ƒvƒŒƒCƒ„[‚Ì•û‚ðŒü‚­
turn_toward_player
when 26 # ƒvƒŒƒCƒ„[‚Ì‹t‚ðŒü‚­
turn_away_from_player
end
@move_route_index += 1
return
end
# ‚»‚Ì‘¼‚̃Rƒ}ƒ“ƒh‚Ìê‡
if command.code >= 27
# ƒRƒ}ƒ“ƒhƒR[ƒh‚Å•ªŠò
case command.code
when 27 # ƒXƒCƒbƒ` ON
$game_switches[command.parameters[0]] = true
$game_map.need_refresh = true
when 28 # ƒXƒCƒbƒ` OFF
$game_switches[command.parameters[0]] = false
$game_map.need_refresh = true
when 29 # ˆÚ“®‘¬“x‚Ì•ÏX
@move_speed = command.parameters[0]
when 30 # ˆÚ“®•p“x‚Ì•ÏX
@move_frequency = command.parameters[0]
when 31 # ˆÚ“®ŽžƒAƒjƒ ON
@walk_anime = true
when 32 # ˆÚ“®ŽžƒAƒjƒ OFF
@walk_anime = false
when 33 # ’âŽ~ŽžƒAƒjƒ ON
@step_anime = true
when 34 # ’âŽ~ŽžƒAƒjƒ OFF
@step_anime = false
when 35 # Œü‚«ŒÅ’è ON
@direction_fix = true
when 36 # Œü‚«ŒÅ’è OFF
@direction_fix = false
when 37 # ‚·‚蔲‚¯ ON
@through = true
when 38 # ‚·‚蔲‚¯ OFF
@through = false
when 39 # Å‘O–Ê‚É•Ž¦ ON
@always_on_top = true
when 40 # Å‘O–Ê‚É•Ž¦ OFF
@always_on_top = false
when 41 # ƒOƒ‰ƒtƒBƒbƒN•ÏX
@tile_id = 0
@character_name = command.parameters[0]
@character_hue = command.parameters[1]
if @original_direction != command.parameters[2]
@direction = command.parameters[2]
@original_direction = @direction
@prelock_direction = 0
end
if @original_pattern != command.parameters[3]
@pattern = command.parameters[3]
@original_pattern = @pattern
end
when 42 # •s“§–¾“x‚Ì•ÏX
@opacity = command.parameters[0]
when 43 # ‡¬•û–@‚Ì•ÏX
@blend_type = command.parameters[0]
when 44 # SE ‚̉‰‘t
$game_system.se_play(command.parameters[0])
when 45 # ƒXƒNƒŠƒvƒg
result = eval(command.parameters[0])
end
@move_route_index += 1
return
end
end
end
#--------------------------------------------------------------------------
# œ ‰º‚Ɉړ®
#--------------------------------------------------------------------------
def move_down_p
# ‰º‚ðŒü‚­
turn_down
# ˆÚ“®‹——£‚ðŽZo
distance = 2 ** @move_speed
down1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
#--------------------------------------------------------------------------
# œ ‰º‚Ɉړ®‰Â”‚©‚Ç‚¤‚©‚Ì”»’è‚P
#--------------------------------------------------------------------------
def down1(x, y, distance, down = false)
result = down2(x, y, distance)
if result == false
@event_run = check_event_trigger_touch(x, y+1)
return result
end
if @revise_x < -SIDE
result = down2(x, y + 1, distance, 4)
result &= down2(x - 1, y, distance)
if result == false
if down
move_lower_right_p
if @revise_x > SIDE
@revise_x = SIDE
end
end
return result
end
elsif @revise_x > SIDE
result = down2(x, y + 1, distance, 6)
result &= down2(x + 1, y, distance)
if result == false
if down
move_lower_left_p
if @revise_x < -SIDE
@revise_x = -SIDE
end
end
return result
end
end
# ‰º‚Ɉړ®‰Â”‚È‚ç‚΋——£•ªˆÚ“®
@revise_y += distance
return result
end
#--------------------------------------------------------------------------
# œ ‰º‚Ɉړ®‰Â”‚©‚Ç‚¤‚©‚Ì”»’è‚Q
#--------------------------------------------------------------------------
def down2(x, y, distance, d = 2)
if @revise_y + distance > DOWN
unless passable?(x, y, d)
if @revise_y < DOWN
@revise_y = DOWN
end
return false
end
end
return true
end
#--------------------------------------------------------------------------
# œ ¶‚Ɉړ®
#--------------------------------------------------------------------------
def move_left_p
# ¶‚ðŒü‚­
turn_left
distance = 2 ** @move_speed
left1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
#--------------------------------------------------------------------------
# œ ¶‚Ɉړ®‰Â”‚©‚Ç‚¤‚©‚Ì”»’è‚P
#--------------------------------------------------------------------------
def left1(x, y, distance, left = false)
result = left2(x, y, distance)
if result == false
@event_run = check_event_trigger_touch(x-1, y)
return result
end
if @revise_y < -UP
result = left2(x - 1, y, distance, 8)
result &= left2(x, y - 1, distance)
if result == false
if left
move_lower_left_p
if @revise_y > DOWN
@revise_y = DOWN
end
end
return result
end
elsif @revise_y > DOWN
result = left2(x - 1, y, distance, 2)
result &= left2(x, y + 1, distance)
if result == false
if left
move_upper_left_p
if @revise_y < -UP
@revise_y = -UP
end
end
return result
end
end
@revise_x -= distance
return result
end
#--------------------------------------------------------------------------
# œ ¶‚Ɉړ®‰Â”‚©‚Ç‚¤‚©‚Ì”»’è‚Q
#--------------------------------------------------------------------------
def left2(x, y, distance, d = 4)
if @revise_x - distance < -SIDE
unless passable?(x, y, d)
if @revise_x > -SIDE
@revise_x = -SIDE
end
return false
end
end
return true
end
#--------------------------------------------------------------------------
# œ ‰E‚Ɉړ®
#--------------------------------------------------------------------------
def move_right_p
# ‰E‚ðŒü‚­
turn_right
distance = 2 ** @move_speed
right1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
Revenir en haut Aller en bas
http://dark-univers.ifrance.com
Sigur
Dieu Administrateur
Dieu Administrateur
Sigur


Nombre de messages : 212
Age : 33
Localisation : Le monde de Istraya.
Date d'inscription : 28/04/2007

Déplacement Réaliste -> 8 Directions ~ Courir Empty
MessageSujet: Re: Déplacement Réaliste -> 8 Directions ~ Courir   Déplacement Réaliste -> 8 Directions ~ Courir Icon_minitimeLun 30 Avr - 1:36

Pratique mes moin compliquer je pense en évents. ^^
Revenir en haut Aller en bas
https://m-d-a.forumactif.fr
 
Déplacement Réaliste -> 8 Directions ~ Courir
Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Mémoire d'Ames :: Le making :: Scripts-
Sauter vers:  
Ne ratez plus aucun deal !
Abonnez-vous pour recevoir par notification une sélection des meilleurs deals chaque jour.
IgnorerAutoriser