Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Pixel Moviment

2 participantes

Ir para baixo

Pixel Moviment Empty Pixel Moviment

Mensagem por Ure¢a Qua Fev 03, 2010 12:47 pm

Pixel Moviment
Autor: Desconhecido
Screens: Não necessita
Descrição: Faz com o que o personagem anda mais realista. Sem ser tile por tile.
Instrução: Cole acima do main

Código:
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
#  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロ���ルなどの
# 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
#==============================================================================
module Q
SLANT_SUFFIX = "#"
end

class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias bulletActionPlayer_initialize initialize
def initialize
bulletActionPlayer_initialize # 呼び戻し
@shot_angle = Math::PI / 2
end
#--------------------------------------------------------------------------
# ● マップ通行可能判定
# !上書き
# x : X 座標
# y : Y 座標
#--------------------------------------------------------------------------
def map_passable?(mode)
super(mode)
end
#--------------------------------------------------------------------------
# ● 正面のイベント起動判定
# !上書き
# triggers : トリガーの配列
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
return false if $game_map.interpreter.running?
result = false
if @direction == 4 or @direction == 6
front_x = @real_x
front_x -= 64 if @direction == 4 # 8 << 3
front_x += 320 if @direction == 6 # 40 << 3
front_y = @real_y + 128
else
front_y = @real_y
front_y -= 64 if @direction == 8 # 8 << 3
front_y += 320 if @direction == 2 # 40 << 3
front_x = @real_x + 128
end
for event in $game_map.events.values
if event.real_x < front_x && event.real_x + 256 > front_x # 32 << 3
if event.real_y < front_y && event.real_y + 256 > front_y # 32 << 3
if triggers.include?(event.trigger)
event.start
result = true
end
end
end
end
return result
end
#--------------------------------------------------------------------------
# ● 接触(重なり)によるイベント起動判定
# !上書き
#--------------------------------------------------------------------------
def check_touch_event
return false
end
#--------------------------------------------------------------------------
# ● 決定ボタンによるイベント起動判定
# !上書き
#--------------------------------------------------------------------------
def check_action_event
return false if in_airship?
return check_event_trigger_there([0,1,2])
end
#--------------------------------------------------------------------------
# ● 移動可能判定
# !上書き
#--------------------------------------------------------------------------
def movable?
return false if @move_route_forcing # 移動ルート強制中
return false if @vehicle_getting_on # 乗る動作の途中
return false if @vehicle_getting_off # 降りる動作の途中
return false if $game_message.visible # メッセージ表示中
return false if in_airship? and not $game_map.airship.movable?
return true
end
#--------------------------------------------------------------------------
# ● X方向の移動処理
#--------------------------------------------------------------------------
def move_x(max_speed)
max_speed *= 2 if dash? # ダッシュ状態なら倍
@xv = [@xv + 2, max_speed].min if @xv < max_speed
@xv = [@xv - 2, max_speed].max if @xv > max_speed
@move_count = 1
end
#--------------------------------------------------------------------------
# ● Y方向の移動処理
#--------------------------------------------------------------------------
def move_y(max_speed)
max_speed *= 2 if dash? # ダッシュ状態なら倍
@yv = [@yv + 2, max_speed].min if @yv < max_speed
@yv = [@yv - 2, max_speed].max if @yv > max_speed
@move_count = 1
end
#--------------------------------------------------------------------------
# ● 左に移動
# !上書き
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_left(turn_ok = true)
turn_left
@shot_angle = Math::PI
move_x(-16)
end
#--------------------------------------------------------------------------
# ● 右に移動
# !上書き
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_right(turn_ok = true)
turn_right
@shot_angle = 0.0
move_x(16)
end
#--------------------------------------------------------------------------
# ● 上に移動
# !上書き
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_up(turn_ok = true)
turn_up
@shot_angle = Math::PI * 3 / 2
move_y(-16)
end
#--------------------------------------------------------------------------
# ● 下に移動
# !上書き
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_down(turn_ok = true)
turn_down
@shot_angle = Math::PI / 2
move_y(16)
end
#--------------------------------------------------------------------------
# ● 左下に移動
# !上書き
#--------------------------------------------------------------------------
def move_lower_left
turn_left
@shot_angle = Math::PI * 3 / 4
move_x(-12)
move_y(6)
end
#--------------------------------------------------------------------------
# ● 右下に移動
# !上書き
#--------------------------------------------------------------------------
def move_lower_right
turn_right
@shot_angle = Math::PI / 4
move_x(12)
move_y(6)
end
#--------------------------------------------------------------------------
# ● 左上に移動
# !上書き
#--------------------------------------------------------------------------
def move_upper_left
turn_left
@shot_angle = Math::PI * 5 / 4
move_x(-12)
move_y(-6)
end
#--------------------------------------------------------------------------
# ● 右上に移動
# !上書き
#--------------------------------------------------------------------------
def move_upper_right
turn_right
@shot_angle = Math::PI * 7 / 4
move_x(12)
move_y(-6)
end
#--------------------------------------------------------------------------
# ● move_countの更新
#--------------------------------------------------------------------------
def update_move_count
@move_count -= 1
end
#--------------------------------------------------------------------------
# ● x座標の更新
#--------------------------------------------------------------------------
def update_x
unless (Input.press?(Input::LEFT) or Input.press?(Input::RIGHT))
@xv = [@xv + 1, 0].min if @xv < 0
@xv = [@xv - 1, 0].max if @xv > 0
end
last_x = @real_x
@real_x += @xv
@x = @real_x >> 8
@touch_flag = -1
unless passable?(0)
@real_x = last_x
@x = @real_x >> 8
@xv = 0
check_event_trigger_touch() # 接触起動判定
end
end
#--------------------------------------------------------------------------
# ● y座標の更新
#--------------------------------------------------------------------------
def update_y
unless (Input.press?(Input::UP) or Input.press?(Input::DOWN))
@yv = [@yv + 1, 0].min if @yv < 0
@yv = [@yv - 1, 0].max if @yv > 0
end
last_y = @real_y
@real_y += @yv
@y = @real_y >> 8
@touch_flag = -1
unless passable?(1)
@real_y = last_y
@y = @real_y >> 8
@yv = 0
check_event_trigger_touch() # 接触起動判定
end

end
#--------------------------------------------------------------------------
# ● ショット
#--------------------------------------------------------------------------
def shot
$game_map.screen.shot_bullet(@real_x + 128, @real_y + 128,
@shot_angle, 64, 1, 30, 0)
end
#--------------------------------------------------------------------------
# ● 方向ボタン入力による移動処理
# !上書き
#--------------------------------------------------------------------------
def move_by_input
return unless movable?
return if $game_map.interpreter.running?
if Input.press?(Input::LEFT)
if Input.press?(Input::UP)
move_upper_left
elsif Input.press?(Input::DOWN)
move_lower_left
else
move_left
end
elsif Input.press?(Input::RIGHT)
if Input.press?(Input::UP)
move_upper_right
elsif Input.press?(Input::DOWN)
move_lower_right
else
move_right
end
elsif Input.press?(Input::UP)
move_up
elsif Input.press?(Input::DOWN)
move_down
end
shot if Input.trigger?(Input::X) # ショット
end
#--------------------------------------------------------------------------
# ● 接触イベントの起動判定
# !上書き
#--------------------------------------------------------------------------
def check_event_trigger_touch
return if $game_map.interpreter.running?
for event in $game_map.events.values
next if event.id != @touch_flag
if event.trigger == 2
event.start
break
end
end
end
#--------------------------------------------------------------------------
# ● 角度の取得
#--------------------------------------------------------------------------
def get_angle(x, y)
angle = Math.atan2( $game_player.real_y + 128 - y, $game_player.real_x + 128 - x )
return angle
end
#--------------------------------------------------------------------------
# ● ダメージ
#--------------------------------------------------------------------------
def damage(atk)
for actor in $game_party.members
d = atk - (TACT::Option::PLAYER_DEF_MODE ? actor.def : 0)
d = 1 if d < 1
if TACT::Option::UNDEAD_MODE and actor.hp <= d
d = actor.hp - 1
end
actor.hp -= d
end
@damaged = true
@animation_id = TACT::Option::HIT_ANIME_ID
if $game_party.all_dead? # パーティ全滅判定
if TACT::Option::DEAD_EVENT_ID > 0
$game_temp.common_event_id = TACT::Option::DEAD_EVENT_ID
end
end
end
end

class Sprite_Character < Sprite_Base
end

#==============================================================================
# ■ Game_Character
#------------------------------------------------------------------------------
#  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
# クラスのスーパークラスとして使用されます。
#==============================================================================

class Game_Character
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
#~ attr_accessor :hp # HP
attr_accessor :def # 防御力
#~ attr_accessor :undead # 無敵
attr_accessor :real_x # マップ X 座標 (実座標 * 256)
attr_accessor :real_y # マップ Y 座標 (実座標 * 256)
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias bulletActionCharacter_initialize initialize
def initialize
bulletActionCharacter_initialize # 呼び戻し
#~ @hp = 1
@def = 0
#~ @undead = false
@xv = 0
@yv = 0
@touch_flag = -1
@move_count = 0
end
#--------------------------------------------------------------------------
# ● 移動中判定
# !上書き
#--------------------------------------------------------------------------
def moving?
return @move_count > 0
end
#--------------------------------------------------------------------------
# ● 左に移動
# !上書き
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_left(turn_ok = true)
turn_left
d = 2 ** @move_speed
@xv = 0 - d
@move_count = 256 / d
end
#--------------------------------------------------------------------------
# ● 右に移動
# !上書き
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_right(turn_ok = true)
turn_right
d = 2 ** @move_speed
@xv = d
@move_count = 256 / d
end
#--------------------------------------------------------------------------
# ● 上に移動
# !上書き
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_up(turn_ok = true)
turn_up
d = 2 ** @move_speed
@yv = 0 - d
@move_count = 256 / d
end
#--------------------------------------------------------------------------
# ● 下に移動
# !上書き
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_down(turn_ok = true)
turn_down
d = 2 ** @move_speed
@yv = d
@move_count = 256 / d
end
#--------------------------------------------------------------------------
# ● 左下に移動
# !上書き
#--------------------------------------------------------------------------
def move_lower_left
turn_left
d = 2 ** @move_speed
@xv = 0 - d
@yv = d
@move_count = 256 / d
end
#--------------------------------------------------------------------------
# ● 右下に移動
# !上書き
#--------------------------------------------------------------------------
def move_lower_right
turn_right
d = 2 ** @move_speed
@xv = d
@yv = d
@move_count = 256 / d
end
#--------------------------------------------------------------------------
# ● 左上に移動
# !上書き
#--------------------------------------------------------------------------
def move_upper_left
turn_left
d = 2 ** @move_speed
@xv = 0 - d
@yv = 0 - d
@move_count = 256 / d
end
#--------------------------------------------------------------------------
# ● 右上に移動
# !上書き
#--------------------------------------------------------------------------
def move_upper_right
turn_right
d = 2 ** @move_speed
@xv = d
@yv = 0 - d
@move_count = 256 / d
end
#--------------------------------------------------------------------------
# ● マップ通行可能判定
# !上書き
# mode : 0でx方向、1でy方向
#--------------------------------------------------------------------------
def map_passable?(mode)
left_x = @real_x + 32 >> 8 # 4 <<3
right_x = @real_x + 224 >> 8 # 28 << 3
up_y = @real_y + 16 >> 8 # 2 << 3
down_y = @real_y + 224 >> 8 # 28 << 3
if mode == 0
if @xv > 0
return false unless $game_map.passable?(right_x, up_y)
return false unless $game_map.passable?(right_x, down_y)
else
return false unless $game_map.passable?(left_x, up_y)
return false unless $game_map.passable?(left_x, down_y)
end
else
if @yv > 0
return false unless $game_map.passable?(left_x, down_y)
return false unless $game_map.passable?(right_x, down_y)
else
return false unless $game_map.passable?(left_x, up_y)
return false unless $game_map.passable?(right_x, up_y)
end
end
return true
end
#--------------------------------------------------------------------------
# ● 通行可能判定
# !上書き
# mode : 0でx方向、1でy方向
#--------------------------------------------------------------------------
def passable?(mode = 0)
return false unless map_passable?(mode) # マップが通行不能?
return true if @through or debug_through? # すり抜け ON?
return false if collide_with_characters?(x, y, mode) # キャラクターに衝突?
return true # 通行可
end
#--------------------------------------------------------------------------
# ● 接触判定
# real_x : X 座標
# real_y : Y 座標
#--------------------------------------------------------------------------
def hit_pos?(real_x, real_y)
if @real_x + 32 < real_x + 224 && real_x + 32 < @real_x + 224 # 4 << 3, 28 << 3
if @real_y < real_y + 224 && real_y < @real_y + 224
return true
end
end
return false
end
#--------------------------------------------------------------------------
# ● キャラクター衝突判定
# !上書き
# x : X 座標
# y : Y 座標
# プレイヤーと乗り物を含め、通常キャラの衝突を検出する。
#--------------------------------------------------------------------------
def collide_with_characters?(x, y, mode)
for event in $game_map.events.values # 全イベントを検索
next if event.through # すり抜け OFF?
next if event.id == self.id # 自分自身を無視
if hit_pos?(event.real_x, event.real_y)
@touch_flag = event.id
return true
end
end
if @priority_type == 1 # 自分が通常キャラ
unless self.is_a?(Game_Player)
if hit_pos?($game_player.real_x, $game_player.real_y) # プレイヤーと接触
@touch_flag = 0
return true
end
end
end
return false
end
#--------------------------------------------------------------------------
# ● フレーム更新
# !上書き
#--------------------------------------------------------------------------
def update
update_x
update_y
if moving? # 移動中
update_move_count
if @walk_anime
@anime_count += 1.5
elsif @step_anime
@anime_count += 1
end
else # 停止中
if @step_anime
@anime_count += 1
elsif @pattern != @original_pattern
@anime_count += 1.5
end
@stop_count += 1 unless @locked
end
if @wait_count > 0 # ウェイト中
@wait_count -= 1
elsif @move_route_forcing # 移動ルート強制中
move_type_custom
elsif not @locked # ロック中以外
update_self_movement
end
update_animation
end
#--------------------------------------------------------------------------
# ● move_countの更新
#--------------------------------------------------------------------------
def update_move_count
@move_count -= 1
if @move_count == 0
@xv = 0
@yv = 0
end
end
#--------------------------------------------------------------------------
# ● x座標の更新
#--------------------------------------------------------------------------
def update_x
return if @xv == 0
last_x = @real_x
@real_x += @xv
@x = @real_x >> 8
@touch_flag = -1
unless passable?(0)
@real_x = last_x
@x = @real_x >> 8
@xv = 0
check_event_trigger_touch() # 接触起動判定
end
end
#--------------------------------------------------------------------------
# ● y座標の更新
#--------------------------------------------------------------------------
def update_y
return if @yv == 0
last_y = @real_y
@real_y += @yv
@y = @real_y >> 8
@touch_flag = -1
unless passable?(1)
@real_y = last_y
@y = @real_y >> 8
@yv = 0
check_event_trigger_touch() # 接触起動判定
end
end
#--------------------------------------------------------------------------
# ● 接触イベントの起動判定
#--------------------------------------------------------------------------
def check_event_trigger_touch()
end
end
Ure¢a
Ure¢a
Rei
Rei

Prêmio : Duelo de Pixel
Mensagens : 1179
Gold : 7090
Nível : 100

https://grandesmakersstaff.forumeiros.com

Ir para o topo Ir para baixo

Pixel Moviment Empty Re: Pixel Moviment

Mensagem por Khas Qua Mar 31, 2010 7:37 pm

Bom, tava olhando esse script esses dias
Observem as seguintes linhas
Código:
shot if Input.trigger?(Input::X) # ショット

def shot
$game_map.screen.shot_bullet(@real_x + 128, @real_y + 128,
@shot_angle, 64, 1, 30, 0)
end
 

Com base nessas duas linhas e mais outras, da para perceber facilmente que esse script funciona em conjunto com alguma coisa. Querem testar? Tecle A para ver o que acontece: o script pede o metodo "shot_bullet" que não existe.

Provavelmente foi tirado de algum projeto desencriptado, eu não usaria em projetos proprios...
Todos sabem que "roubar scripts" é um "crime" grave do mundo maker
Khas
Khas
Aldeão
Aldeão

Mensagens : 4
Gold : 5174
Nível : 11

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos