| 赞 | 1 |
| VIP | |
| 好人卡 | |
| 积分 | 19 |
| 经验 | |
| 最后登录 | 2026-6-17 |
| 在线时间 | 380 小时 |
- 梦石
- 0
- 星屑
- 1918
- 在线时间
- 380 小时
- 注册时间
- 2012-12-10
- 回帖
- 402
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
下面是三个脚本和前面的说明:
说明:
STG脚本:
Srpite_aaaagq
Bul_aaaagq
Scene_Show
参数:
$maxbul = 100 #全弹量
$maxenemy = 6 #敌人量
$伤害显示 = true #就是伤害显示
Srpite_aaaagq:
- class Srpite_aaaagq < RPG::Sprite
- attr_accessor :hp
- attr_accessor :maxhp
-
- attr_accessor :nextpx
- attr_accessor :nextpy
-
- attr_accessor :tdam
- attr_accessor :dam
- attr_accessor :damagerange
-
- attr_accessor :wt
- attr_accessor :rwt
-
- attr_accessor :showdt
- attr_accessor :speed
-
-
- #------------------------------------------------------------------------
- #------------------------------------------------------------------------
- #------------------------------------------------------------------------
- #------------------------------------------------------------------------
- def init
- initialize
- end
- def initialize
- super
- @damagerange = 20
- @tdam = 0
- @dam = 0
- @nextpx = 0
- @nextpy = 0
- @maxhp = 1000
- @hp = @maxhp
- @wt = 0
- @rwt = 34
- @showdt = 0
- @speed = 2
- update
- end
-
- def recover
- @wt=[@wt-@rwt,0].max
- end
-
- def moving
- if (self.x>-@damagerange) and (self.x<640+@damagerange) and
- (self.y>-@damagerange) and (self.y<480+@damagerange)
- tx = self.x
- ty = self.y
- self.x = @nextpx
- self.y = @nextpy
- @nextpx = @nextpx + @nextpx - tx
- @nextpy = @nextpy + @nextpy - ty
- else
- self.x=-2000
- self.y=-2000
- end
- end
-
- #------------------------------------------------------------------------
- #------------------------------------------------------------------------
- #------------------------------------------------------------------------
- def adddamage()
- if @dam > @tdam
- @tdam = @dam
- damage(@dam, false)
- end
- end
-
- def damage(value, critical)
- if value.is_a?(Numeric)
- damage_string = value.to_s
- end
- dispose_damage
- bitmap = Bitmap.new(160, 48)
- bitmap.font.name = "Arial Black"
- bitmap.font.size = 32
- bitmap.font.color.set(0, 0, 0)
- bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
- bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
- bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
- bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
- if value.is_a?(Numeric) and value < 0
- bitmap.font.color.set(176, 255, 144)
- else
- bitmap.font.color.set(255, 255, 255)
- end
- bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
- if critical
- bitmap.font.size = 20
- bitmap.font.color.set(0, 0, 0)
- bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
- bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
- bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
- bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
- bitmap.font.color.set(255, 255, 255)
- bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
- end
- @_damage_sprite = ::Sprite.new(self.viewport)
- @_damage_sprite.bitmap = bitmap
- @_damage_sprite.ox = 80#rand(40) - 20, rand(30) + 50
- @_damage_sprite.oy = 20
- @_damage_sprite.x = self.x
- @_damage_sprite.y = self.y - self.oy / 2
- @_damage_sprite.z = 3000
- @_damage_duration = 40
- end
-
- def update
- super
- if @_whiten_duration > 0
- @_whiten_duration -= 1
- self.color.alpha = 128 - (16 - @_whiten_duration) * 10
- end
- if @_appear_duration > 0
- @_appear_duration -= 1
- self.opacity = (16 - @_appear_duration) * 16
- end
- if @_escape_duration > 0
- @_escape_duration -= 1
- self.opacity = 256 - (32 - @_escape_duration) * 10
- end
- if @_collapse_duration > 0
- @_collapse_duration -= 1
- self.opacity = 256 - (48 - @_collapse_duration) * 6
- end
- adddamage
- if @_damage_duration > 0
- @_damage_duration -= 1
- case @_damage_duration
- when 38..39
- @_damage_sprite.y -= 4
- when 36..37
- @_damage_sprite.y -= 2
- when 34..35
- @_damage_sprite.y += 2
- when 28..33
- @_damage_sprite.y += 4
- end
- @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
- if @_damage_duration == 0
- dispose_damage
- end
- else
- @dam = 0
- @tdam = 0
- end
- if @_animation != nil and (Graphics.frame_count % 2 == 0)
- @_animation_duration -= 1
- update_animation
- end
- if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
- update_loop_animation
- @_loop_animation_index += 1
- @_loop_animation_index %= @_loop_animation.frame_max
- end
- if @_blink
- @_blink_count = (@_blink_count + 1) % 32
- if @_blink_count < 16
- alpha = (16 - @_blink_count) * 6
- else
- alpha = (@_blink_count - 16) * 6
- end
- self.color.set(255, 255, 255, alpha)
- end
- @@_animations.clear
- end
-
- end
复制代码
Bul_aaaagq:
- class Bul_aaaagq < Sprite
- attr_accessor :nextpx
- attr_accessor :nextpy
-
- attr_accessor :dam
- attr_accessor :damagerange
-
- attr_accessor :bul_st
-
- def init
- @bul_st = 0
- @damagerange = 20
- @nextpx = 0
- @nextpy = 0
- self.x = -2000
- self.y = -2000
- end
-
- def initialize
- super
- @bul_st = 0
- @damagerange = 20
- @dam = 100
- @nextpx = 0
- @nextpy = 0
- self.x = -2000
- self.y = -2000
- update
- end
-
- def moving(spr)
- if @bul_st == 0 #直线
- if (self.x>-@damagerange) and (self.x<640+@damagerange) and
- (self.y>-@damagerange) and (self.y<480+@damagerange)
- self.x += @nextpx
- self.y += @nextpy
- else
- self.x=-2000
- self.y=-2000
- end
- end
- if @bul_st == 1 #等待
- self.x = spr.x + @nextpx
- self.y = spr.y + @nextpy
- end
- end
- def c10(x,y)
- if @bul_st == 1
- @bul_st = 0
- @nextpx = x
- @nextpy = y
- end
- end
- end
复制代码
- class Scene_Show
- def main
- @maxbul = $maxbul
- @maxenemy = $maxenemy
- @lastB = false #集气相关
- @numB = 0 #集气相关
-
- @mysprite = Srpite_aaaagq
- @mysprite = Srpite_aaaagq.new
- @mysprite.bitmap = Bitmap.new("Graphics/Battlers/001-Fighter01.png")
- @mysprite.ox = @mysprite.bitmap.width / 2
- @mysprite.oy = @mysprite.bitmap.height / 2
- @mysprite.x = 100
- @mysprite.y = 100
- @enemy = [Srpite_aaaagq.new,Srpite_aaaagq.new]
- for i in 0 .. @maxenemy
- @enemy[i] = Srpite_aaaagq.new
- @enemy[i].bitmap = Bitmap.new("Graphics/Battlers/075-Devil01")
- @enemy[i].ox = @enemy[i].bitmap.width / 2
- @enemy[i].oy = @enemy[i].bitmap.height / 2
- @enemy[i].x = -2000
- @enemy[i].y = -2000
- end
- @enemy[0].x = 580
- @enemy[0].y = 150
- @enemy[1].x = 590
- @enemy[1].y = 400
- @bul = [Bul_aaaagq.new,Bul_aaaagq.new]
- for i in 0 .. @maxbul
- @bul[i] = Bul_aaaagq.new
- @bul[i].bitmap = Bitmap.new("Graphics/Icons/001-Weapon01.png")
- @bul[i].ox = @bul[i].bitmap.width / 2
- @bul[i].oy = @bul[i].bitmap.height / 2
- @bul[i].x = -2000
- @bul[i].y = -2000
- end
- Audio.bgm_play("bgm30.ogg")
- Graphics.transition
-
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- if $scene != self
- break
- end
- end
- alldispose
- Graphics.freeze
- rescue Errno::ENOENT
- Graphics.transition
-
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- if $scene != self
- break
- end
- end
- alldispose
- Graphics.freeze
- end
- #------------------------------------------------------------------
- def alldispose
- @mysprite.dispose
- for i in 0 .. @maxenemy
- @enemy[i].dispose
- end
- for i in 0 .. @maxbul
- @bul[i].dispose
- end
- end
- def update
- @mysprite.recover
-
- for i in 0 .. @maxenemy
- for j in 0 .. @maxbul
- if distance(@enemy[i],@bul[j])
- if $伤害显示
- @enemy[i].dam += @bul[j].dam*(150-rand(100))/100
- end
- #@bul[j].x = -2000
- #@bul[j].y = -2000
- @bul[j].init
- end
- end
- end
- for i in 0 .. @maxenemy
- @enemy[i].update
- end
- for i in 0 .. @maxbul
- @bul[i].moving(@mysprite)
- end
- if Input.press?(Input::UP)
- @mysprite.y -= @mysprite.speed
- end
- if Input.press?(Input::DOWN)
- @mysprite.y += @mysprite.speed
- end
- if Input.press?(Input::LEFT)
- @mysprite.x -= @mysprite.speed
- end
- if Input.press?(Input::RIGHT)
- @mysprite.x += @mysprite.speed
- end
- if Input.press?(Input::A)#普通攻击
- onfire(@mysprite,0,0,13,0)
- onfire(@mysprite,0,0,10,2)
- onfire(@mysprite,0,0,10,-2)
- if @maxbul>50
- onfire(@mysprite,0,10,12,0)
- onfire(@mysprite,0,-10,12,0)
- onfire(@mysprite,0,20,11,0)
- onfire(@mysprite,0,-20,11,0)
- onfire(@mysprite,0,50,11,0)
- onfire(@mysprite,0,-50,11,0)
- end
- if @mysprite.wt == 0
- Audio.se_play("Audio/SE/043-Knock04.ogg")
- @mysprite.wt = 100
- end
- end
- if Input.press?(Input::B)#集气攻击
- @lastB = true
- for i in 0 .. 5
- if onfire1(@mysprite, -rand(20), 2*(@numB%50)-50) != -1
- @numB += 1
- end
- end
- elsif @lastB
- @lastB = false
- @numB = 0
- for i in 0 .. @maxbul
- @bul[i].c10(10+rand(10),-5+rand(10))
- end
- Audio.se_play("Audio/SE/142-Burst02.ogg")
- if @mysprite.wt == 0
- @mysprite.wt = 500
- end
- end
- if Input.press?(Input::C)
- $scene = Scene_Map.new
- end
- end
- #-------------------------------功能------------------------------------
- def onfire(spr,px,py,x,y)
- if spr.wt == 0
- for i in 0 .. @maxbul
- if @bul[i].x <= 0 or @bul[i].x >= 700
- @bul[i].x = spr.x + px
- @bul[i].y = spr.y + py
- @bul[i].nextpx = x
- @bul[i].nextpy = y
- return i
- end
- end
- end
- return -1
- end
- def onfire1(spr,x,y)
- #if spr.wt == 0
- for i in 0 .. @maxbul
- if @bul[i].x <= 0 or @bul[i].x >= 700
- @bul[i].x = spr.x + x
- @bul[i].y = spr.y + y
- @bul[i].nextpx = x
- @bul[i].nextpy = y
- @bul[i].bul_st = 1
- return i
- end
- end
- #end
- return -1
- end
-
- def distance(spr,bul)
- if spr.x<-1000 or bul.x<-1000
- return false
- end
- if spr.x>bul.x-bul.damagerange-spr.bitmap.width / 3.0 and spr.x<bul.x+bul.damagerange+spr.bitmap.width / 3.0 and
- spr.y>bul.y-bul.damagerange-spr.bitmap.height / 3.0 and spr.y<bul.y+bul.damagerange+spr.bitmap.height / 3.0
- return true
- else
- return false
- end
- end
-
- end
复制代码 |
|