maybe the rest of the refactor?

This commit is contained in:
Kistaro Windrider 2024-09-02 12:59:49 -07:00
parent 7869192dee
commit 01ab6d3969
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -123,7 +123,7 @@ end
function _init() function _init()
init_blip_pals() init_blip_pals()
wipe_level() wipe_level()
primary_ship.main_gun = zap_gun.new() primary_ship.main_gun = zap_gun_p.new() -- redundant?
load_level(example_level_csv) load_level(example_level_csv)
state = game state = game
pal(2,129) pal(2,129)
@ -755,8 +755,7 @@ mknew(blast_gun)
protron_e = bullet_base.new{ protron_e = bullet_base.new{
--shape --shape
psprite = 23, --index of player ammo sprite sprite - 24,
esprite = 24, -- index of enemy ammo sprite
width = 1, --in 8x8 blocks width = 1, --in 8x8 blocks
height = 1, height = 1,
hurt = { -- hurtbox - where this ship can be hit hurt = { -- hurtbox - where this ship can be hit
@ -769,62 +768,58 @@ protron_e = bullet_base.new{
y_off = 4, y_off = 4,
damage = 1, damage = 1,
dx = 0, -- px/frame dym = -0.5, -- gun sets dy;
dy = -3, -- this is mult
category = enemy_blt_cat, category = enemy_blt_cat,
} }
mknew(protron_e) mknew(protron_e)
protron_p = protron_e.new{ protron_p = protron_e.new{
sprite=23, sprite=23,
dy = 6, dym = 1,
y_off = 0, y_off = 0,
category=player_blt_cat, category=player_blt_cat,
} }
mknew(protron_p) mknew(protron_p)
-- XXX Bookmark for bullet refactor protron_gun_e = gun_base.new{
protron_gun = gun_base.new{
icon = 25, icon = 25,
enemy = false,
power = 60, power = 60,
cooldown = 0x0.000f, -- frames between shots cooldown = 0x0.000f, -- frames between shots
ammo = nil, ammo = nil,
maxammo = nil, maxammo = nil,
actually_shoot = function(self, x, y) munition = protron_e
local sprite = protron.psprite
if (self.enemy) sprite=protron.esprite
for i=1,3 do
local b = protron.new{
enemy=self.enemy,
sprite=sprite,
dx = i,
dy = 4-i
}
b:spawn_at(x,y)
local b2 = protron.new{
enemy=self.enemy,
sprite=sprite,
dx = -i,
dy = 4-i
}
b2:spawn_at(x,y)
end
local bup = protron.new{
enemy=self.enemy,
sprite=sprite,
dy=4
}
bup:spawn_at(x,y)
end
} }
mknew(protron_gun) mknew(protron_gun_e)
vulcan = bullet_base.new{ function protron_gun_e:actually_shoot(x, y)
local m = self.munition.dym
for i=1,3 do
local b = self.munition.new{
dx = i*m,
dy = (4-i)*m,
}
b:spawn_at(x,y)
local b2 = self.munition.new{
dx = -i*m,
dy = (4-i)*m,
}
b2:spawn_at(x,y)
end
local bup = self.munition.new{
dy=4*m
}
bup:spawn_at(x,y)
end
protron_gun_p = protron_gun_e.new{
munition = protron_p,
}
mknew(protron_gun_p)
vulcan_e = bullet_base.new{
--shape --shape
psprite = 22, --index of player ammo sprite sprite = 21,
esprite = 21, -- index of enemy ammo sprite
width = 1, --in 8x8 blocks width = 1, --in 8x8 blocks
height = 1, height = 1,
hurt = { -- hurtbox - where this ship can be hit hurt = { -- hurtbox - where this ship can be hit
@ -833,31 +828,34 @@ vulcan = bullet_base.new{
width = 1, width = 1,
height = 4 height = 4
}, },
center_x_off = 0.5, -- how to position by ship x_off = 0.5, -- how to position by ship
bottom_y_off = 4, y_off = 0,
top_y_off = 0,
damage = 0.5, damage = 0.5,
dx = 0, -- px/frame -- dx from gun
dy = 4, dy = -2,
} }
mknew(vulcan) mknew(vulcan_e)
vulcan_gun = gun_base.new{ vulcan_p = vulcan_e.new{
sprite=22,
y_off = 4,
}
mknew(vulcan_e)
vulcan_gun_e = gun_base.new{
icon = 37, icon = 37,
enemy = false, enemy = false,
power = 8, power = 8,
cooldown = 0x0.0002, -- frames between shots cooldown = 0x0.0002, -- frames between shots
ammo = nil, ammo = nil,
maxammo = nil, maxammo = nil,
munition=vulcan_p,
dxs = {0.35, -0.35, -0.7, 0.7, 0.35, -0.35}, dxs = {0.35, -0.35, -0.7, 0.7, 0.35, -0.35},
xoffs = {1, 0, -1, 1, 0, -1}, xoffs = {1, 0, -1, 1, 0, -1},
dxidx = 1, dxidx = 1,
actually_shoot = function(self, x, y) actually_shoot = function(self, x, y)
local sprite = self.enemy and vulcan.esprite or vulcan.psprite local b = self.munition.new{
local b = vulcan.new{
enemy=self.enemy,
sprite=sprite,
dx = self.dxs[self.dxidx], dx = self.dxs[self.dxidx],
} }
b:spawn_at(self.xoffs[self.dxidx]+x,y) b:spawn_at(self.xoffs[self.dxidx]+x,y)
@ -865,7 +863,11 @@ vulcan_gun = gun_base.new{
if (self.dxidx > #self.dxs) self.dxidx = 1 if (self.dxidx > #self.dxs) self.dxidx = 1
end end
} }
mknew(vulcan_gun) mknew(vulcan_gun_e)
vulcan_gun_p = vulcan_gun_e.new{
munition=vulcan_p,
}
-->8 -->8
--ships, including player --ships, including player
@ -927,7 +929,7 @@ player = ship_m.new{
} }
mknew(player, mknew(player,
function(p) function(p)
p.main_gun = zap_gun.new() p.main_gun = zap_gun_p.new()
-- ONE HIT MODE -- ONE HIT MODE
-- --
-- p.hp = 0 -- p.hp = 0
@ -1012,7 +1014,7 @@ spewy = frownie.new{
end end
} }
mknew(spewy, function(ship) mknew(spewy, function(ship)
ship.main_gun=ship.main_gun or protron_gun.new{enemy=true} ship.main_gun=ship.main_gun or protron_gun_e.new{enemy=true}
end) end)
chasey = ship_m.new{ chasey = ship_m.new{
@ -1040,7 +1042,7 @@ chasey = ship_m.new{
slip = true, slip = true,
} }
mknew(chasey, function(ship) mknew(chasey, function(ship)
ship.main_gun=ship.main_gun or zap_gun.new{enemy=true} ship.main_gun=ship.main_gun or zap_gun_e.new{}
end) end)
function chasey:act() function chasey:act()
@ -1074,7 +1076,7 @@ xl_chasey=chasey.new{
end, end,
} }
mknew(xl_chasey, function(ship) mknew(xl_chasey, function(ship)
ship.main_gun=ship.main_gun or zap_gun.new{enemy=true} ship.main_gun=ship.main_gun or zap_gun_e.new{}
end) end)
-->8 -->8
-- collisions -- collisions
@ -1283,9 +1285,9 @@ end
function spawn_bonus_vulcan_chasey() function spawn_bonus_vulcan_chasey()
local c = spawn_chasey() local c = spawn_chasey()
c.main_gun=vulcan_gun.new{enemy=true} c.main_gun=vulcan_gun_e.new{enemy=true}
c.die = function(self) c.die = function(self)
spawn_main_gun_at(self.x-1, self.y-1, vulcan_gun) spawn_main_gun_at(self.x-1, self.y-1, vulcan_gun_p)
chasey.die(self) chasey.die(self)
end end
c.sprite=4 c.sprite=4
@ -1388,7 +1390,7 @@ example_level_csv=[[1,spawn_frownie
310,spawn_blocking_blocky 310,spawn_blocking_blocky
310,spawn_blocking_blocky 310,spawn_blocking_blocky
311,spawn_frownie 311,spawn_frownie
350,spawn_main_gun_at,70,-11,protron_gun 350,spawn_main_gun_at,70,-11,protron_gun_p
401,spawn_frownie 401,spawn_frownie
420,spawn_blocking_frownie 420,spawn_blocking_frownie
430,spawn_bonus_vulcan_chasey 430,spawn_bonus_vulcan_chasey
@ -1498,8 +1500,9 @@ bullets
shots much easier to dodge shots much easier to dodge
* damage - damage per hit; * damage - damage per hit;
used by ships used by ships
* psprite, esprite - index of * sprite - sprite index.
player or enemy sprite. * x_off, y_off - renamed for
the next two vars. may revert
* center_off_x - the horizontal * center_off_x - the horizontal
centerpoint of the bullet, centerpoint of the bullet,
for positioning when firing. for positioning when firing.