Project1

标题: 自写战斗朝向各种死 [打印本页]

作者: 糖克鸡    时间: 2011-6-19 18:37
标题: 自写战斗朝向各种死
  1. module RPG
  2.   attr_accessor :actor
  3.   @actor = []
  4.   @actor[0] = {"名字" => "蛐蛐", "装备" => [], "技能" => [], "能力" => {"命" => 100, "魔" => 50, "体" => 50, "攻" => 10, "防" => 10,"敏" => 10}, "行走图" => nil, "战斗图" => "蛐蛐1"}
  5.   # 暂时定 par 为 命 魔 体 攻 防 敏
  6.   @actor[1] = {"名字" => "白痴", "装备" => [], "技能" => [], "能力" => {"命" => 100, "魔" => 50, "体" => 50, "攻" => 10, "防" => 10,"敏" => 10}, "行走图" => nil, "战斗图" => "坦克2"}
  7. end
复制代码
  1. module RPG
  2.   attr_accessor :enemy
  3.   @enemy = []
  4.   @enemy[0] = {"名字" => "坦克", "装备" => [], "技能" => [], "能
  5.   力" => {"命" => 100, "魔" => 50, "体" => 50, "攻" => 10, "防" => 10,
  6.   "敏" => 10}, "战斗图" => "坦克1"}
  7. end
复制代码
  1. #==========================================================
  2. # 处理战斗的类
  3. #==========================================================
  4. class Battle
  5. #==========================================================
  6. # 部分一:初始化
  7. #==========================================================
  8.   def initialize
  9.   end
  10.   def main
  11.   # 生成战斗活动块
  12.     @back = Sprite.new
  13.     @back.bitmap = Bitmap.new("Pictures/Back/battle")
  14.     @back.zoom_x = 0.6
  15.     @back.zoom_y = 0.6
  16.     @actor = []
  17.     @status = []
  18.     for i in 0...$actor.size
  19.       @actor[i] = Sprite_zoom.new
  20.       $actor[i]["刷新时间"] = 0
  21.       @actor[i].bitmap = Bitmap.new(32, 80)
  22.       @actor[i].bitmap.font.size = 16
  23.       @actor[i].bitmap.stretch_blt(Rect.new(0, 32, 32, 48),
  24.       Bitmap.new("Pictures/Battle/" + $actor[i]["战斗图"]),
  25.       Rect.new(0, 48, 32, 48))
  26.       @actor[i].x = 40
  27.       @actor[i].y = 20 * i + 200
  28.       $actor[i]["朝向"] = 2
  29.       #@actor[i].zoom_x = @actor[i].zoom_y = @actor[i].y/480.0
  30.       @actor[i].bitmap.blur_draw_text(0, 0, @actor[i].bitmap.width, 32, $actor[i]["名字"], 1)
  31.     end
  32.     @enemy = []
  33.     for i in 0...$enemy.size
  34.       @enemy[i] = Sprite_zoom.new
  35.       $enemy[i]["刷新时间"] = 0
  36.       @enemy[i].bitmap = Bitmap.new(32, 80)
  37.       @enemy[i].bitmap.font.size = 16
  38.       @enemy[i].bitmap.stretch_blt(Rect.new(0, 32, 32, 48),
  39.       Bitmap.new("Pictures/Battle/" + $enemy[i]["战斗图"]),
  40.       Rect.new(0, 48, 32, 48))
  41.       @enemy[i].x = 500
  42.       @enemy[i].y = 20 * i + 200
  43.       @enemy[i].bitmap.blur_draw_text(0, 0, @enemy[i].bitmap.width, 32, $enemy[i]["名字"], 1)
  44.     end
  45.     loop do
  46.       Graphics.update
  47.       Mouse.update
  48.       Input.update
  49.       update
  50.       $sprite[0].x, $sprite[0].y = Mouse.get_pos
  51.     end
  52.   end
  53.   def update
  54.     for i in [email protected]
  55.       $actor[i]["刷新时间"] += 1
  56.       $actor[i]["刷新时间"] = 0 if $actor[i]["刷新时间"] == 4
  57.       @actor[i].bitmap.blt(0, 32,
  58.       Bitmap.new("Pictures/Battle/" + $actor[i]["战斗图"]),
  59.       Rect.new($actor[i]["刷新时间"]*32, 48 * $actor[i]["朝向"], 32, 48))
  60.       #@actor[i].update
  61.     end
  62.     for i in [email protected]
  63.       $enemy[i]["刷新时间"] += 1
  64.       $enemy[i]["刷新时间"] = 0 if $enemy[i]["刷新时间"] == 4
  65.       @enemy[i].bitmap.blt(0, 32, Bitmap.new("Pictures/Battle/" + $enemy[i]["战斗图"]),
  66.       Rect.new($enemy[i]["刷新时间"]*32, 48, 32, 48))
  67.       # stretch_
  68.       #@enemy[i].update
  69.     end
  70.     if Input.press?(Input::LEFT)
  71.       @actor[0].x -= 4
  72.       $actor[0]["朝向"] = 1
  73.     elsif Input.press?(Input::RIGHT)
  74.       @actor[0].x += 4
  75.       $actor[0]["朝向"] = 2
  76.     elsif Input.press?(Input::UP)
  77.       @actor[0].y -= 4
  78.       $actor[0]["朝向"] = 3
  79.     elsif Input.press?(Input::DOWN)
  80.       @actor[0].y += 4
  81.       $actor[0]["朝向"] = 0
  82.     end
  83.   end
  84. end
复制代码
于是当朝向=2时ACTOR的朝向会一下左一下右OTL,求解决。
然后这种更新方法很可能卡死,如果可以的话求提供效率更高的解决方法。dsu_plus_rewardpost_czw
作者: fux2    时间: 2011-6-20 10:36
早就说不要用hash这诡异的东西啦,这串脚本在默认工程里有效么?有效的话等等
作者: zh99998    时间: 2011-6-20 20:35
请用符号来代替字符串




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1