赞 | 23 |
VIP | 0 |
好人卡 | 0 |
积分 | 9 |
经验 | 297497 |
最后登录 | 2018-10-13 |
在线时间 | 94 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 910
- 在线时间
- 94 小时
- 注册时间
- 2005-10-22
- 帖子
- 397
|
3楼
楼主 |
发表于 2006-11-16 21:53:09
|
只看该作者
再来一个三层远景图的直接用地图做战斗背景
- #==============================================================================
- # 本脚本来自www.66rpg.com,使用前请参考制作录像
- # 作者:柳柳
- #
- # 脚本的功能:
- #
- # 1、设置第二层远景,做遮挡
- # 2、设置第三层远景,做通行判定
- # 这个通行判定,以图的判定为最高,如果要求某地通行,请把那个地方擦白。
- # 本通行判定和录像中讲的方法并不冲突
- #==============================================================================
- # ■ Spriteset_Map
- #------------------------------------------------------------------------------
- # 处理地图画面活动块和元件的类。本类在
- # Scene_Map 类的内部使用。
- #==============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize(flag = false)
- # 生成显示端口
- @viewport1 = Viewport.new(0, 0, 640, 480)
- @viewport2 = Viewport.new(0, 0, 640, 480)
- @viewport3 = Viewport.new(0, 0, 640, 480)
- @viewport2.z = 200
- @viewport3.z = 5000
- # 生成元件地图
- @tilemap = Tilemap.new(@viewport1)
- @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
- for i in 0..6
- autotile_name = $game_map.autotile_names[i]
- @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
- end
- @tilemap.map_data = $game_map.data
- @tilemap.priorities = $game_map.priorities
- # 生成远景平面
- @panorama = Plane.new(@viewport1)
- @panorama.z = -1000
- @panorama2 = Plane.new(@viewport1)
- @panorama2.z = 3000
- # 生成雾平面
- @fog = Plane.new(@viewport1)
- @fog.z = 3000
- unless flag
- # 生成角色活动块
- @character_sprites = []
- for i in $game_map.events.keys.sort
- sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
- @character_sprites.push(sprite)
- end
- @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
- end
- # 生成天气
- @weather = RPG::Weather.new(@viewport1)
- # 生成图片
- @picture_sprites = []
- for i in 1..50
- @picture_sprites.push(Sprite_Picture.new(@viewport2,
- $game_screen.pictures[i]))
- end
- # 生成计时器块
- @timer_sprite = Sprite_Timer.new
- # 刷新画面
- update
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose(flag = false)
- # 释放元件地图
- @tilemap.tileset.dispose
- for i in 0..6
- @tilemap.autotiles[i].dispose
- end
- @tilemap.dispose
- # 释放远景平面
- @panorama.dispose
- @panorama2.dispose
- # 释放雾平面
- @fog.dispose
- unless flag
- # 释放角色活动块
- for sprite in @character_sprites
- sprite.dispose
- end
- end
- # 释放天候
- @weather.dispose
- # 释放图片
- for sprite in @picture_sprites
- sprite.dispose
- end
- # 释放计时器块
- @timer_sprite.dispose
- # 释放显示端口
- @viewport1.dispose
- @viewport2.dispose
- @viewport3.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 远景与现在的情况有差异发情况下
- if @panorama_name != $game_map.panorama_name or
- @panorama_hue != $game_map.panorama_hue
- @panorama_name = $game_map.panorama_name
- @panorama_hue = $game_map.panorama_hue
- if @panorama.bitmap != nil
- @panorama.bitmap.dispose
- @panarama2.bitmap.dispose
- @panorama2.bitmap = nil
- @panarama.bitmap = nil
- end
- if @panorama_name != ""
- if $panorama3 != nil
- $panorama3.dispose
- end
- $panorama3 = Sprite.new
- $panorama3.bitmap = RPG::Cache.panorama(@panorama_name+"_3", @panorama_hue)
- $panorama3.visible = false
- @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
- @panorama2.bitmap = RPG::Cache.panorama(@panorama_name+"_2", @panorama_hue)
- end
- Graphics.frame_reset
- end
- # 雾与现在的情况有差异的情况下
- if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
- @fog_name = $game_map.fog_name
- @fog_hue = $game_map.fog_hue
- if @fog.bitmap != nil
- @fog.bitmap.dispose
- @fog.bitmap = nil
- end
- if @fog_name != ""
- @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
- end
- Graphics.frame_reset
- end
- # 刷新元件地图
- @tilemap.ox = $game_map.display_x / 4
- @tilemap.oy = $game_map.display_y / 4
- @tilemap.update
- # 刷新远景平面
- @panorama.ox = $game_map.display_x / 4
- @panorama.oy = $game_map.display_y / 4
- @panorama2.ox = @panorama.ox
- @panorama2.oy = @panorama.oy
- # 刷新雾平面
- @fog.zoom_x = $game_map.fog_zoom / 100.0
- @fog.zoom_y = $game_map.fog_zoom / 100.0
- @fog.opacity = $game_map.fog_opacity
- @fog.blend_type = $game_map.fog_blend_type
- @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
- @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
- @fog.tone = $game_map.fog_tone
- if @character_sprites != nil
- # 刷新角色活动块
- for sprite in @character_sprites
- sprite.update
- end
- end
- # 刷新天候图形
- @weather.type = $game_screen.weather_type
- @weather.max = $game_screen.weather_max
- @weather.ox = $game_map.display_x / 4
- @weather.oy = $game_map.display_y / 4
- @weather.update
- # 刷新图片
- for sprite in @picture_sprites
- sprite.update
- end
- # 刷新计时器块
- @timer_sprite.update
- # 设置画面的色调与震动位置
- @viewport1.tone = $game_screen.tone
- @viewport1.ox = $game_screen.shake
- # 设置画面的闪烁色
- @viewport3.color = $game_screen.flash_color
- # 刷新显示端口
- @viewport1.update
- @viewport3.update
- end
- end
- #==============================================================================
- # 本脚本来自www.66rpg.com,使用前请参考制作录像
- #==============================================================================
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # 处理地图的类。包含卷动以及可以通行的判断功能。
- # 本类的实例请参考 $game_map 。
- #==============================================================================
- class Game_Map
- attr_accessor :map
- attr_accessor :map_id
- #--------------------------------------------------------------------------
- # ● 可以通行判定
- # x : X 坐标
- # y : Y 坐标
- # d : 方向 (0,2,4,6,8,10)
- # ※ 0,10 = 全方向不能通行的情况的判定 (跳跃等)
- # self_event : 自己 (判定事件可以通行的情况下)
- #--------------------------------------------------------------------------
- def passable?(x, y, d, self_event = nil)
- # 被给予的坐标地图外的情况下
- unless valid?(x, y)
- # 不能通行
- return false
- end
- martix = [false,false,false,false,false,false,false,false,false]
- for panorama_x in 32*x..32*x+10
- next if panorama_x %2 == 0
- for panorama_y in 32*y..32*y+10
- next if panorama_y %2 == 0
- color = $panorama3.bitmap.get_pixel(panorama_x,panorama_y)
- if color.green.to_i==0
- martix[0] = true
- break
- end
- end
- break if martix[0]
- end
- for panorama_x in 32*x+10..32*x+22
- next if panorama_x %2 == 0
- for panorama_y in 32*y..32*y+10
- next if panorama_y %2 == 0
- color = $panorama3.bitmap.get_pixel(panorama_x,panorama_y)
- if color.green.to_i==0
- martix[1] = true
- break
- end
- end
- break if martix[1]
- end
- for panorama_x in 32*x+23..32*x+32
- next if panorama_x %2 == 0
- for panorama_y in 32*y..32*y+10
- next if panorama_x %y == 0
- color = $panorama3.bitmap.get_pixel(panorama_x,panorama_y)
- if color.green.to_i==0
- martix[2] = true
- break
- end
- end
- break if martix[2]
- end
- for panorama_x in 32*x..32*x+10
- next if panorama_x %2 == 0
- for panorama_y in 32*y+10..32*y+22
- next if panorama_y %2 == 0
- color = $panorama3.bitmap.get_pixel(panorama_x,panorama_y)
- if color.green.to_i==0
- martix[3] = true
- break
- end
- end
- break if martix[3]
- end
- for panorama_x in 32*x+10..32*x+22
- next if panorama_x %2 == 0
- for panorama_y in 32*y+10..32*y+22
- next if panorama_y %2 == 0
- color = $panorama3.bitmap.get_pixel(panorama_x,panorama_y)
- if color.green.to_i==0
- martix[4] = true
- break
- end
- end
- break if martix[4]
- end
- for panorama_x in 32*x+23..32*x+32
- next if panorama_x %2 == 0
- for panorama_y in 32*y+10..32*y+22
- next if panorama_x %y == 0
- color = $panorama3.bitmap.get_pixel(panorama_x,panorama_y)
- if color.green.to_i==0
- martix[5] = true
- break
- end
- end
- break if martix[5]
- end
- for panorama_x in 32*x..32*x+10
- next if panorama_x %2 == 0
- for panorama_y in 32*y+23..32*y+32
- next if panorama_y %2 == 0
- color = $panorama3.bitmap.get_pixel(panorama_x,panorama_y)
- if color.green.to_i==0
- martix[6] = true
- break
- end
- end
- break if martix[6]
- end
- for panorama_x in 32*x+10..32*x+22
- next if panorama_x %2 == 0
- for panorama_y in 32*y+23..32*y+32
- next if panorama_y %2 == 0
- color = $panorama3.bitmap.get_pixel(panorama_x,panorama_y)
- if color.green.to_i==0
- martix[7] = true
- break
- end
- end
- break if martix[7]
- end
- for panorama_x in 32*x+23..32*x+32
- next if panorama_x %2 == 0
- for panorama_y in 32*y+23..32*y+32
- next if panorama_x %y == 0
- color = $panorama3.bitmap.get_pixel(panorama_x,panorama_y)
- if color.green.to_i==0
- martix[8] = true
- break
- end
- end
- break if martix[8]
- end
- pass_up = true
- pass_down = true
- pass_left = true
- pass_right = true
- #---------------------------------------------------------------------
- # 注意,如果打算严格要求,则把and前加井号。我测试感觉放松似乎更自然一些,看情况吧。
- # 这种算法是把一个小格分为9个格(参考小键盘)
- #
- # 放松要求是2,4,6,8格决定能否通行
- # 而严格要求则是2,4,6,8格并且要求至少附带临近旁一格才能通行
- #---------------------------------------------------------------------
- if martix[1] and (martix[0] or martix[2])
- pass_up = false
- end
- if martix[3] and (martix[0] or martix[6])
- pass_left = false
- end
- if martix[7] and (martix[6] or martix[8])
- pass_down = false
- end
- if martix[5] and (martix[2] or martix[8])
- pass_right = false
- end
- if martix[4]
- pass_up = false
- pass_down = false
- pass_left = false
- pass_right = false
- end
- pass_up = pass_up== false ? 0 : 1
- pass_left = pass_left== false ? 0 : 1
- pass_right = pass_right== false ? 0 : 1
- pass_down = pass_down== false ? 0 : 1
- pass = pass_down * 1 + pass_left * 2 + pass_right * 4 + pass_up * 8
- pass = 15-pass
-
- # 方向 (0,2,4,6,8,10) 与障碍物接触 (0,1,2,4,8,0) 后变换
- bit = (1 << (d / 2 - 1)) & 0x0f
- # 循环全部的事件
- for event in events.values
- # 自己以外的元件与坐标相同的情况
- if event.tile_id >= 0 and event != self_event and
- event.x == x and event.y == y and not event.through
- # 如果障碍物的接触被设置的情况下
- if @passages[event.tile_id] & bit != 0
- # 不能通行
- return false
- # 如果全方向的障碍物的接触被设置的情况下
- elsif @passages[event.tile_id] & 0x0f == 0x0f
- # 不能通行
- return false
- # 这以外的优先度为 0 的情况下
- elsif @priorities[event.tile_id] == 0
- # 可以通行
- return true
- end
- end
- end
- # 从层按从上到下的顺序调查循环
- for i in [2, 1, 0]
- # 取得元件 ID
- tile_id = data[x, y, i]
- # 取得元件 ID 失败
- if tile_id == nil
- # 不能通行
- return false
- # 如果障碍物的接触被设置的情况下
- elsif @passages[tile_id] & bit != 0
- # 不能通行
- return false
- # 如果全方向的障碍物的接触被设置的情况下
- elsif @passages[tile_id] & 0x0f == 0x0f
- # 不能通行
- return false
- # 这以外的优先度为 0 的情况下
- elsif @priorities[tile_id] == 0
- # 可以通行
- #p pass
- if pass & bit != 0
- return false
- elsif pass & 0x0f == 0x0f
- return false
- end
- end
- end
- # 可以通行
- return true
- end
- end
- #==============================================================================
- # 本脚本的用途请参考制作录像
- #==============================================================================
- #===============================================================
- # 本脚本来自www.66rpg.com
- # 功能:对于没有设置战斗背景的地图,直接用地图做战斗背景
- #===============================================================
- class Scene_Battle
- alias battleback_map_main main
- def main
- @battleback_sprite = Spriteset_Map.new(true)
- battleback_map_main
- @battleback_sprite.dispose(true)
- end
- end
- #===============================================================
- # 申请者:张永;脚本作者:bluefool 改进人:亿万星辰 完美化:IKKI
- #===============================================================
复制代码 |
|