设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
Project1 查看内容

人物倒影

2008-8-6 22:57| 发布者: 秀秀| 查看: 4089| 评论: 0|原作者: ★_茄孓|来自: 点此进入发布帖

摘要: 放个脚本,贴几张图给大家看看!不过我在写时不知道影子到底是从那边发射来的所以弄了3种类型的影子请自行在脚本中修改样式P $影子类型 = 1 # 可写1与2.3更换影子类型根据大家的建议,我也

放个脚本,贴几张图给大家看看!
不过我在写时不知道影子到底是从
那边发射来的
所以弄了3种类型的影子
请自行在脚本中修改样式

P $影子类型 = 1 # 可写1与2.3更换影子类型

根据大家的建议,我也弄了第三种影子类型。
应该与现实比较符合了。大家可以使用看看。
另:
很不要脸的借用别人的图片来使用下~

叫这张shadow图片放在picture下,做为一般影子图!
在水中则有倒影图!切记需要改地形标志为1才有倒影
更新内容:
新增类型3-在地形标志为1的元件图内有倒影,其他则为普通影子
且影子随水流有点荡漾的感觉(伪造的不太形象)

#==============================================================================
# ■ Sprite_Character_Shadow
# ■ By 茄子 联系QQ 9244579
# ■ 要地图元件有倒影出现请将
# ■ 地形标志改为1
#==============================================================================
$影子类型 = 3
# $影子类型可以选为1.2.3来测试效果
# 类型3是比较完善真实的类型
#==============================================================================
#==============================================================================
class Sprite_Character_False < RPG::Sprite
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize(viewport, character = nil)
    super(viewport)
    @character = character
    @direction = 2
    update
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        @cw = bitmap.width / 4
        @ch = bitmap.height / 4
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    self.opacity = 102
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    if $影子类型 == 1  # ★
    if @tile_id == 0
    sx = @character.pattern * @cw
    sy = (@direction - 2) / 2 * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
    end
    self.mirror = false
    if @character.direction == 2
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    self.angle = 180
    elsif @character.direction == 4
    self.x = @character.screen_x-10
    self.y = @character.screen_y-10
    self.z = @character.screen_z(@ch)
    self.angle = 90
    elsif @character.direction == 6
    self.x = @character.screen_x+10
    self.y = @character.screen_y-10
    self.z = @character.screen_z(@ch)
    self.angle = 270
    elsif @character.direction == 8
    self.x = @character.screen_x
    self.y = @character.screen_y-15
    self.z = @character.screen_z(@ch)
    self.angle = 0
    end  
    elsif $影子类型 == 2  # ★
    if @tile_id == 0
    sx = @character.pattern * @cw
    sy = (@character.direction - 2) / 2 * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
    end
    self.mirror = true
    if @character.direction == 2
    if @tile_id == 0
    sx = @character.pattern * @cw
    sy = (@direction - 2) / 2 * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
    end
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    self.angle = 180
    elsif @character.direction == 4
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    elsif @character.direction == 6
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    elsif @character.direction == 8
    self.x = @character.screen_x
    self.y = @character.screen_y-15
    self.z = @character.screen_z(@ch)
    self.angle = 0
    end   
  elsif $影子类型 == 3  # ★
    @x = @character.x
    @y = @character.y
    if @tile_id == 0
    sx = @character.pattern * @cw
    sy = (@character.direction - 2) / 2 * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
    end
  if $game_map.terrain_tag(@x, @y+1) == 1
    self.mirror = true
    self.angle = 180
    if @character.direction == 2
    self.visible = true
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    elsif @character.direction == 4
    self.visible = true
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    elsif @character.direction == 6
    self.visible = true
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    end
  elsif $game_map.terrain_tag(@x, @y-1) == 1  # …
    self.mirror = false
    if @tile_id == 0
    sx = @character.pattern * @cw
    sy = (@direction - 2) / 2 * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
    end
    if @character.direction == 8 # …
    self.visible = true
    @direction = 2
    self.x = @character.screen_x
    self.y = @character.screen_y-35
    self.z = @character.screen_z(@ch)
    self.angle = 0
    elsif @character.direction == 4
    self.visible = true
    @direction = 4
    self.x = @character.screen_x
    self.y = @character.screen_y-35
    self.z = @character.screen_z(@ch)
    self.angle = 0
    elsif @character.direction == 6
    self.visible = true
    @direction = 6
    self.x = @character.screen_x
    self.y = @character.screen_y-35
    self.z = @character.screen_z(@ch)
    self.angle = 0
    end  # …
  elsif $game_map.terrain_tag(@x+1, @y) == 1
    if @tile_id == 0
    sx = @character.pattern * @cw
    sy = (@direction - 2) / 2 * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
    end
    self.angle = 270
    self.visible = true
    if @character.direction == 8
    @direction = 6
    self.x = @character.screen_x+20
    self.y = @character.screen_y-20
    self.z = @character.screen_z(@ch)
    elsif @character.direction == 2
    @direction = 4
    self.x = @character.screen_x+20
    self.y = @character.screen_y-20
    self.z = @character.screen_z(@ch)
    elsif @character.direction == 6
    @direction = 2
    self.x = @character.screen_x+20
    self.y = @character.screen_y-20
    self.z = @character.screen_z(@ch)
    end 
  elsif $game_map.terrain_tag(@x-1, @y) == 1
    if @tile_id == 0
    sx = @character.pattern * @cw
    sy = (@direction - 2) / 2 * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
    end
    self.visible = true
    self.angle = 90
    if @character.direction == 8
    @direction = 4
    self.x = @character.screen_x-20
    self.y = @character.screen_y-20
    self.z = @character.screen_z(@ch)
    elsif @character.direction == 2
    @direction = 6
    self.x = @character.screen_x-20
    self.y = @character.screen_y-20
    self.z = @character.screen_z(@ch)
    elsif @character.direction == 4
    @direction = 2
    self.x = @character.screen_x-20
    self.y = @character.screen_y-20
    self.z = @character.screen_z(@ch)
    end
  elsif
  self.visible = false
  end  # …
end
  self.opacity = rand(25)+100
  self.bush_depth = rand(25)+100
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
end
class Sprite_Character_Shadow < RPG::Sprite
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize(viewport, character = nil)
    super(viewport)
    @character = character
    self.bitmap = RPG::Cache.picture("shadow")
    update
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    if $影子类型 == 3
    if @character.character_name == ""
    self.x = @character.screen_x-5000
    self.y = @character.screen_y-5000
    else
    self.x = @character.screen_x-16
    self.y = @character.screen_y-20
    self.z = 10
    self.opacity = 255
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    end
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
    end
  end
end
#==============================================================================
# ■ Spriteset_Map
#==============================================================================
class Spriteset_Map
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
 def initialize
    @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
    @fog = Plane.new(@viewport1)
    @fog.z = 3000
    @character_sprites = []
    for i in $game_map.events.keys.sort
      s = Sprite_Character.new(@viewport1, $game_map.events[i])
      @character_sprites.push(s)
      s = Sprite_Character_Shadow.new(@viewport1, $game_map.events[i])
      @character_sprites.push(s)
      s = Sprite_Character_False.new(@viewport1, $game_map.events[i])
      @character_sprites.push(s)
    end
    @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
    @character_sprites.push(Sprite_Character_False.new(@viewport1, $game_player))
    @character_sprites.push(Sprite_Character_Shadow.new(@viewport1, $game_player))
    @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
end

5

鲜花

刚表态过的朋友 (5 人)

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-25 04:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部