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