Project1
标题:
自写战斗朝向各种死
[打印本页]
作者:
糖克鸡
时间:
2011-6-19 18:37
标题:
自写战斗朝向各种死
module RPG
attr_accessor :actor
@actor = []
@actor[0] = {"名字" => "蛐蛐", "装备" => [], "技能" => [], "能力" => {"命" => 100, "魔" => 50, "体" => 50, "攻" => 10, "防" => 10,"敏" => 10}, "行走图" => nil, "战斗图" => "蛐蛐1"}
# 暂时定 par 为 命 魔 体 攻 防 敏
@actor[1] = {"名字" => "白痴", "装备" => [], "技能" => [], "能力" => {"命" => 100, "魔" => 50, "体" => 50, "攻" => 10, "防" => 10,"敏" => 10}, "行走图" => nil, "战斗图" => "坦克2"}
end
复制代码
module RPG
attr_accessor :enemy
@enemy = []
@enemy[0] = {"名字" => "坦克", "装备" => [], "技能" => [], "能
力" => {"命" => 100, "魔" => 50, "体" => 50, "攻" => 10, "防" => 10,
"敏" => 10}, "战斗图" => "坦克1"}
end
复制代码
#==========================================================
# 处理战斗的类
#==========================================================
class Battle
#==========================================================
# 部分一:初始化
#==========================================================
def initialize
end
def main
# 生成战斗活动块
@back = Sprite.new
@back.bitmap = Bitmap.new("Pictures/Back/battle")
@back.zoom_x = 0.6
@back.zoom_y = 0.6
@actor = []
@status = []
for i in 0...$actor.size
@actor[i] = Sprite_zoom.new
$actor[i]["刷新时间"] = 0
@actor[i].bitmap = Bitmap.new(32, 80)
@actor[i].bitmap.font.size = 16
@actor[i].bitmap.stretch_blt(Rect.new(0, 32, 32, 48),
Bitmap.new("Pictures/Battle/" + $actor[i]["战斗图"]),
Rect.new(0, 48, 32, 48))
@actor[i].x = 40
@actor[i].y = 20 * i + 200
$actor[i]["朝向"] = 2
#@actor[i].zoom_x = @actor[i].zoom_y = @actor[i].y/480.0
@actor[i].bitmap.blur_draw_text(0, 0, @actor[i].bitmap.width, 32, $actor[i]["名字"], 1)
end
@enemy = []
for i in 0...$enemy.size
@enemy[i] = Sprite_zoom.new
$enemy[i]["刷新时间"] = 0
@enemy[i].bitmap = Bitmap.new(32, 80)
@enemy[i].bitmap.font.size = 16
@enemy[i].bitmap.stretch_blt(Rect.new(0, 32, 32, 48),
Bitmap.new("Pictures/Battle/" + $enemy[i]["战斗图"]),
Rect.new(0, 48, 32, 48))
@enemy[i].x = 500
@enemy[i].y = 20 * i + 200
@enemy[i].bitmap.blur_draw_text(0, 0, @enemy[i].bitmap.width, 32, $enemy[i]["名字"], 1)
end
loop do
Graphics.update
Mouse.update
Input.update
update
$sprite[0].x, $sprite[0].y = Mouse.get_pos
end
end
def update
for i in
[email protected]
$actor[i]["刷新时间"] += 1
$actor[i]["刷新时间"] = 0 if $actor[i]["刷新时间"] == 4
@actor[i].bitmap.blt(0, 32,
Bitmap.new("Pictures/Battle/" + $actor[i]["战斗图"]),
Rect.new($actor[i]["刷新时间"]*32, 48 * $actor[i]["朝向"], 32, 48))
#@actor[i].update
end
for i in
[email protected]
$enemy[i]["刷新时间"] += 1
$enemy[i]["刷新时间"] = 0 if $enemy[i]["刷新时间"] == 4
@enemy[i].bitmap.blt(0, 32, Bitmap.new("Pictures/Battle/" + $enemy[i]["战斗图"]),
Rect.new($enemy[i]["刷新时间"]*32, 48, 32, 48))
# stretch_
#@enemy[i].update
end
if Input.press?(Input::LEFT)
@actor[0].x -= 4
$actor[0]["朝向"] = 1
elsif Input.press?(Input::RIGHT)
@actor[0].x += 4
$actor[0]["朝向"] = 2
elsif Input.press?(Input::UP)
@actor[0].y -= 4
$actor[0]["朝向"] = 3
elsif Input.press?(Input::DOWN)
@actor[0].y += 4
$actor[0]["朝向"] = 0
end
end
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