more efficient bullet spawning
This commit is contained in:
@ -618,14 +618,6 @@ end
|
|||||||
-->8
|
-->8
|
||||||
-- bullet and gun behaviors
|
-- bullet and gun behaviors
|
||||||
|
|
||||||
function player_blt_cat()
|
|
||||||
return pbullets
|
|
||||||
end
|
|
||||||
|
|
||||||
function enemy_blt_cat()
|
|
||||||
return ebullets
|
|
||||||
end
|
|
||||||
|
|
||||||
-- x, y: position
|
-- x, y: position
|
||||||
-- dx, dy: movement (linear)
|
-- dx, dy: movement (linear)
|
||||||
-- f: frames remaining; nil for no limit
|
-- f: frames remaining; nil for no limit
|
||||||
@ -638,9 +630,9 @@ end
|
|||||||
-- details, check impl
|
-- details, check impl
|
||||||
-- damage -- damage to do to
|
-- damage -- damage to do to
|
||||||
-- a ship that gets hit
|
-- a ship that gets hit
|
||||||
-- category -- function that
|
-- category -- string naming
|
||||||
-- returns which bullet list
|
-- which bullet list to spawn
|
||||||
-- to spawn onto
|
-- onto, from _ENV
|
||||||
-- hitship -- event handler,
|
-- hitship -- event handler,
|
||||||
-- takes ship as argument.
|
-- takes ship as argument.
|
||||||
-- default: die, return true.
|
-- default: die, return true.
|
||||||
@ -785,7 +777,7 @@ end
|
|||||||
function bullet_base:spawn_at(x, y)
|
function bullet_base:spawn_at(x, y)
|
||||||
self.x = x - self.x_off
|
self.x = x - self.x_off
|
||||||
self.y = y - self.y_off
|
self.y = y - self.y_off
|
||||||
add(self.category(), self)
|
add(_ENV[self.category], self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function gun_base:shoot(x, y)
|
function gun_base:shoot(x, y)
|
||||||
@ -855,7 +847,7 @@ zap_p = mknew(bullet_base.new{
|
|||||||
|
|
||||||
hitship = const_fxn(true),
|
hitship = const_fxn(true),
|
||||||
|
|
||||||
category = player_blt_cat,
|
category = "pbullets",
|
||||||
})
|
})
|
||||||
|
|
||||||
zap_gun_p = mknew(gun_base.new{
|
zap_gun_p = mknew(gun_base.new{
|
||||||
@ -914,7 +906,7 @@ blast = mknew(bullet_base.new{
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
category=player_blt_cat
|
category="pbullets"
|
||||||
})
|
})
|
||||||
|
|
||||||
blast_gun = mknew(gun_base.new{
|
blast_gun = mknew(gun_base.new{
|
||||||
@ -953,14 +945,14 @@ protron_e = mknew(bullet_base.new{
|
|||||||
y_off = 4,
|
y_off = 4,
|
||||||
|
|
||||||
damage = 1,
|
damage = 1,
|
||||||
category = enemy_blt_cat,
|
category = "ebullets",
|
||||||
})
|
})
|
||||||
|
|
||||||
protron_p = mknew(protron_e.new{
|
protron_p = mknew(protron_e.new{
|
||||||
sprite=23,
|
sprite=23,
|
||||||
dym = -1,
|
dym = -1,
|
||||||
y_off = 0,
|
y_off = 0,
|
||||||
category=player_blt_cat,
|
category="pbullets",
|
||||||
})
|
})
|
||||||
|
|
||||||
protron_gun_e = mknew(gun_base.new{
|
protron_gun_e = mknew(gun_base.new{
|
||||||
@ -1007,13 +999,13 @@ vulcan_e = mknew(bullet_base.new{
|
|||||||
y_off = 0,
|
y_off = 0,
|
||||||
|
|
||||||
damage = 0.5,
|
damage = 0.5,
|
||||||
category=enemy_blt_cat
|
category="ebullets"
|
||||||
})
|
})
|
||||||
|
|
||||||
vulcan_p = mknew(vulcan_e.new{
|
vulcan_p = mknew(vulcan_e.new{
|
||||||
sprite=22,
|
sprite=22,
|
||||||
y_off = 4,
|
y_off = 4,
|
||||||
category=player_blt_cat
|
category="pbullets"
|
||||||
})
|
})
|
||||||
|
|
||||||
vulcan_gun_e = mknew(gun_base.new{
|
vulcan_gun_e = mknew(gun_base.new{
|
||||||
@ -1656,7 +1648,7 @@ xp_gem = mknew(bullet_base.new{
|
|||||||
dy = 0.75,
|
dy = 0.75,
|
||||||
width=1, -- not used for spr but
|
width=1, -- not used for spr but
|
||||||
height=1,-- bullet_base uses it
|
height=1,-- bullet_base uses it
|
||||||
category = enemy_blt_cat,
|
category = "ebullets",
|
||||||
damage = 0,
|
damage = 0,
|
||||||
hurt = {
|
hurt = {
|
||||||
x_off = -2,
|
x_off = -2,
|
||||||
|
Reference in New Issue
Block a user