赞 | 11 |
VIP | 2 |
好人卡 | 1 |
积分 | 3 |
经验 | 36819 |
最后登录 | 2022-11-14 |
在线时间 | 2088 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 271
- 在线时间
- 2088 小时
- 注册时间
- 2011-7-28
- 帖子
- 1145
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 不会脚本 于 2012-1-13 18:27 编辑
- ==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # 一个类来处理地图。它如滚动并可通过确定功能。
- # 这个类的实例引用$ game_map。
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # ● 设置事件
- # !覆盖
- #--------------------------------------------------------------------------
- def setup_events
- @events = {} # 活动地图
- for i in @map.events.keys
- @events[i] = Game_Event.new(@map_id, @map.events[i])
- @events[i].gravity = 0 if @events[i].get_name =~ /<飛行>/i
- end
- @common_events = {} # 通用事件
- for i in 1...$data_common_events.size
- @common_events[i] = Game_CommonEvent.new(i)
- end
- end
- end
复制代码- #==============================================================================
- # ■ Game_Character
- #------------------------------------------------------------------------------
- # 一个类来处理字符。这个类的类Game_Player和Game_Event
- # 是用来作为类的超类。
- #==============================================================================
- class Game_Character
- #--------------------------------------------------------------------------
- # ● 公共实例变量
- #--------------------------------------------------------------------------
- attr_accessor :gravity # 重力
- #--------------------------------------------------------------------------
- # ● 对象初始化
- #--------------------------------------------------------------------------
- alias bulletActionCharacter_initialize initialize
- def initialize
- bulletActionCharacter_initialize # 召回
- @gravity = 5
- @xv = 0
- @yv = 0
- @jump_flag = false
- @touch_flag = -1
- @move_count = 0
- @dash_timer = 0
- end
- #--------------------------------------------------------------------------
- # ● 移动决定
- # !覆盖
- #--------------------------------------------------------------------------
- def moving?
- return @move_count > 0
- end
- #--------------------------------------------------------------------------
- # ● 向左移动
- # !覆盖
- # turn_ok :允许改变飞行方向
- #--------------------------------------------------------------------------
- def move_left(turn_ok = true)
- turn_left
- @xv = -4 * @move_speed
- @move_count = 16
- end
- #--------------------------------------------------------------------------
- # ● 向右移动
- # !覆盖
- # turn_ok :允许改变飞行方向
- #--------------------------------------------------------------------------
- def move_right(turn_ok = true)
- turn_right
- @xv = 4 * @move_speed
- @move_count = 16
- end
- #--------------------------------------------------------------------------
- # ● 向上移动
- # !覆盖
- # turn_ok : 允许改变飞行方向
- #--------------------------------------------------------------------------
- def move_up(turn_ok = true)
- @stop_count = 0
- @yv = -4 * @move_speed
- @move_count = 16
- end
- #--------------------------------------------------------------------------
- # ● 向下移动
- # !覆盖
- # turn_ok : 允许改变飞行方向
- #--------------------------------------------------------------------------
- def move_down(turn_ok = true)
- @stop_count = 0
- @yv = max_speed = 4 * @move_speed
- @move_count = 16
- end
- #--------------------------------------------------------------------------
- # ● 向左下移动
- # !覆盖
- #--------------------------------------------------------------------------
- def move_lower_left
- turn_left
- @xv = -4 * @move_speed
- @yv = max_speed = 4 * @move_speed
- @move_count = 16
- end
- #--------------------------------------------------------------------------
- # ● 向右下移动
- # !覆盖
- #--------------------------------------------------------------------------
- def move_lower_right
- turn_right
- @xv = 4 * @move_speed
- @yv = max_speed = 4 * @move_speed
- @move_count = 16
- end
- #--------------------------------------------------------------------------
- # ● 向左上移动
- # !覆盖
- #--------------------------------------------------------------------------
- def move_upper_left
- turn_left
- @xv = -4 * @move_speed
- @yv = -4 * @move_speed
- @move_count = 16
- end
- #--------------------------------------------------------------------------
- # ● 向右上移动
- # !覆盖
- #--------------------------------------------------------------------------
- def move_upper_right
- turn_right
- @xv = 4 * @move_speed
- @yv = -4 * @move_speed
- @move_count = 16
- end
- #--------------------------------------------------------------------------
- # ● 测定可通行地图
- # !覆盖
- # mode : X方向是0,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 : X方向是0,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) # 碰撞?
- 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)
- 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
- move_dash if dash?
- update_x
- update_y
- if moving? # 移动中
- @move_count -= 1
- 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
- #--------------------------------------------------------------------------
- # ● x坐标更新
- #--------------------------------------------------------------------------
- def update_x
- if !@jump_flag && !moving?
- @xv = 0
- return
- 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
- if @gravity > 0
- @yv += @gravity
- @yv = 64 if @yv > 64
- elsif !moving?
- @yv = 0
- return
- 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
- @jump_flag = false if @yv > 0
- @yv = 0
- check_event_trigger_touch() # 开始测试接触
- end
- end
- #--------------------------------------------------------------------------
- # ● 面对玩家
- # !覆盖
- #--------------------------------------------------------------------------
- def turn_toward_player
- if @real_x < $game_player.real_x
- turn_right
- else
- turn_left
- end
- end
- #--------------------------------------------------------------------------
- # ● 随机移动
- # !覆盖
- #--------------------------------------------------------------------------
- def move_random
- case rand(@gravity == 0 ? 4 : 2)
- when 0; move_left(false)
- when 1; move_right(false)
- when 2; move_up(false)
- when 3; move_down(false)
- end
- end
- #--------------------------------------------------------------------------
- # ● 更接近给玩家
- # !覆盖
- #--------------------------------------------------------------------------
- def move_toward_player
- sx = distance_x_from_player
- sx > 0 ? move_left : move_right
- end
- #--------------------------------------------------------------------------
- # ● 远离玩家
- # !覆盖
- #--------------------------------------------------------------------------
- def move_away_from_player
- sx = distance_x_from_player
- sx > 0 ? move_right : move_left
- end
- #--------------------------------------------------------------------------
- # ● 跳转
- # !覆盖
- # x_plus : X 坐标的总和
- # y_plus : Y 坐标的总和
- #--------------------------------------------------------------------------
- def jump(x_plus, y_plus)
- return if @jump_flag
- @yv = -80
- @jump_flag = true
- @stop_count = 0
- end
- #--------------------------------------------------------------------------
- # ● 开始的事件决定了接触
- #--------------------------------------------------------------------------
- def check_event_trigger_touch()
- end
- end
复制代码- #==============================================================================
- # ■ Game_Event
- #------------------------------------------------------------------------------
- # イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
- # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
- #==============================================================================
- class Game_Event < Game_Character
- #--------------------------------------------------------------------------
- # ● 接触イベントの起動判定
- # !上書き
- #--------------------------------------------------------------------------
- def check_event_trigger_touch()
- return if $game_map.interpreter.running?
- return if @touch_flag != 0
- if @trigger == 2
- start# if not jumping? and @priority_type == 1
- end
- end
- #--------------------------------------------------------------------------
- # ● イベント名の取得
- #--------------------------------------------------------------------------
- def get_name
- return @event.name
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- # !上書き
- #--------------------------------------------------------------------------
- def update
- #~ if @trigger != nil
- #~ if @trigger <= 2 # トリガーが自動でも並列でもない
- #~ return if @real_y > $game_map.display_y + (448 << 3)
- #~ return if @real_y < $game_map.display_y - (32 << 3)
- #~ end
- #~ end
- super
- check_event_trigger_auto # 自動イベントの起動判定
- if @interpreter != nil # 並列処理が有効
- unless @interpreter.running? # 実行中でない場合
- @interpreter.setup(@list, @event.id) # セットアップ
- end
- @interpreter.update # インタプリタを更新
- end
- end
- end
复制代码- #==============================================================================
- # ■ Game_Player
- #------------------------------------------------------------------------------
- # プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
- # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ● マップ通行可能判定
- # !上書き
- # 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
- 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 # 16 << 3
- 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
- #--------------------------------------------------------------------------
- # ● ダッシュ状態判定
- #--------------------------------------------------------------------------
- def dash?
- return false if @move_route_forcing
- return false if $game_map.disable_dash?
- return false if in_vehicle?
- return true if @dash_timer > 0
- return false
- end
- #--------------------------------------------------------------------------
- # ● 左に移動
- # !上書き
- # turn_ok : その場での向き変更を許可
- #--------------------------------------------------------------------------
- def move_left(turn_ok = true)
- turn_left
- max_speed = -16
- @xv = [@xv + 2, max_speed].min if @xv < max_speed and !@jump_flag
- @xv = [@xv - 2, max_speed].max if @xv > max_speed
- @move_count = 1
- end
- #--------------------------------------------------------------------------
- # ● 右に移動
- # !上書き
- # turn_ok : その場での向き変更を許可
- #--------------------------------------------------------------------------
- def move_right(turn_ok = true)
- turn_right
- max_speed = 16
- @xv = [@xv + 2, max_speed].min if @xv < max_speed
- @xv = [@xv - 2, max_speed].max if @xv > max_speed and !@jump_flag
- @move_count = 1
- end
- #--------------------------------------------------------------------------
- # ● x座標の更新
- #--------------------------------------------------------------------------
- def update_x
- if !@jump_flag && !moving?
- @xv = [@xv + 2, 0].min if @xv < 0
- @xv = [@xv - 2, 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
- #--------------------------------------------------------------------------
- # ● ダッシュ移動
- #--------------------------------------------------------------------------
- def move_dash
- @move_count = 1
- @dash_timer -= 1
- end
- #--------------------------------------------------------------------------
- # ● ジャンプ
- #--------------------------------------------------------------------------
- def move_jump(yv)
- Audio.se_play("Audio/SE/wind7.ogg", 70, 150)
- @yv = yv
- @jump_flag = true
- end
- #--------------------------------------------------------------------------
- # ● 方向ボタン入力による移動処理
- # !上書き
- #--------------------------------------------------------------------------
- def move_by_input
- return unless movable?
- return if $game_map.interpreter.running?
- unless dash?
- if Input.press?(Input::LEFT)
- move_left
- elsif Input.press?(Input::RIGHT)
- move_right
- end
- if Input.trigger?(Input::Z) # ダッシュ
- Audio.se_play("Audio/SE/wind10.ogg", 60, 150)
- @dash_timer = 20
- @yv = -24
- if @direction == 4
- @xv = -16 * 2 - 8
- turn_left
- else
- @xv = 16 * 2 + 8
- turn_right
- end
- end
- end
- if Input.trigger?(Input::Y) && @jump_flag == false # ジャンプ
- move_jump(-80)
- end
- 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
- end
复制代码- #==============================================================================
- # ■ Sprite_Character
- #==============================================================================
- class Sprite_Character < Sprite_Base
- #--------------------------------------------------------------------------
- # ○ 确定范围更新
- #--------------------------------------------------------------------------
- def within_update_range?
- sx = @character.screen_x - 272
- sy = @character.screen_y - 208
- return (sx.abs <= 336 && sy.abs <= 272)
- end
- end
复制代码- #==============================================================================
- # ■ Spriteset_Map
- #==============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # ● 字符精灵更新
- #--------------------------------------------------------------------------
- def update_characters
- for sprite in @character_sprites
- sprite.update if sprite.within_update_range?
- end
- end
- end
复制代码 其实很早以前就想发了,不过个人汉化注释有限……
还有这个脚本出自http://115.com/file/bhyt98va 这个游戏里面……还是我汉化不全的。
范例:
横版行走.rar
(217.19 KB, 下载次数: 4258)
脚本出处:http://www.famitsu.com/freegame/tool/chibi/index1.html |
|