drop xp gems
This commit is contained in:
parent
e0b784ce7d
commit
2c1ad0a0b3
113
vacuum_gambit.p8
113
vacuum_gambit.p8
@ -389,6 +389,7 @@ end
|
||||
|
||||
function vertmeter(x0,y0,x1,y1,val,maxval,cols)
|
||||
if ((val <= 0) or (maxval <= 0)) return
|
||||
val=min(val, maxval)
|
||||
local h = y1-y0
|
||||
local px = val/maxval * h \ 1
|
||||
local ncols = #cols
|
||||
@ -445,7 +446,26 @@ ship_m = mknew{
|
||||
|
||||
function ship_m:die()
|
||||
self.dead = true
|
||||
if (self.hp < 0) boom(self.x+self.size*4, self.y+self.size*4,12*self.size, self.boss)
|
||||
if (self.hp >= 0) return
|
||||
|
||||
-- blow up and drop xp
|
||||
local sz4 = self.size * 4
|
||||
local cx, cy, xp, z = self.x + sz4, self.y + sz4, self.xp or 0, 0
|
||||
boom(cx, cy, 3*sz4, self.boss)
|
||||
if xp > 499 then
|
||||
-- spawn a huge gem with all
|
||||
-- overage XP, min 100
|
||||
spawn_xp_at(cx, cy, 0, xp-399)
|
||||
xp = 399
|
||||
z += 1
|
||||
end
|
||||
for gsz in all{100, 25, 5, 1} do
|
||||
while xp >= gsz do
|
||||
spawn_xp_at(cx, cy, z, gsz)
|
||||
xp -= gsz
|
||||
z += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ship_m:calc_velocity(v0, t)
|
||||
@ -628,7 +648,7 @@ function bullet_base:move()
|
||||
self.x += self.dx
|
||||
self.y += self.dy
|
||||
if (self.f) self.f -= 1
|
||||
if (self.y > 128) or (self.y < -8 * self.height) or (self.f and self.f < 0) then
|
||||
if (self.y > 145) or (self.y < -8 * self.height) or (self.f and self.f < 0) then
|
||||
self:die()
|
||||
return true
|
||||
end
|
||||
@ -897,9 +917,9 @@ player = mknew(ship_m.new{
|
||||
shield = 2, -- regenerates
|
||||
maxshield = 2,
|
||||
|
||||
-- xp, increments of 0x0.01
|
||||
-- xp; watch out for 16-bit range limits
|
||||
xp = 0,
|
||||
xptarget = 0x0.05,
|
||||
xptarget = 4,
|
||||
level = 1,
|
||||
|
||||
-- gun
|
||||
@ -956,8 +976,8 @@ frownie = mknew(ship_m.new{
|
||||
sparks = smokespark,
|
||||
sparkodds = 8,
|
||||
|
||||
-- health
|
||||
hp = 0.5, -- enemy ships need no max hp
|
||||
xp = 1,
|
||||
|
||||
-- position
|
||||
x=60, -- x and y are for upper left corner
|
||||
@ -979,6 +999,7 @@ frownie = mknew(ship_m.new{
|
||||
blocky = mknew(frownie.new{
|
||||
sprite = 10,
|
||||
hp = 1.5,
|
||||
xp = 2,
|
||||
hurt = {
|
||||
x_off = 0,
|
||||
y_off = 0,
|
||||
@ -998,6 +1019,7 @@ blocky = mknew(frownie.new{
|
||||
|
||||
spewy = mknew(frownie.new{
|
||||
sprite=26,
|
||||
xp = 3,
|
||||
hurt = {
|
||||
x_off=0,
|
||||
y_off=1,
|
||||
@ -1018,6 +1040,7 @@ spewy = mknew(frownie.new{
|
||||
|
||||
chasey = mknew(ship_m.new{
|
||||
sprite = 5,
|
||||
xp = 4,
|
||||
size = 1,
|
||||
hurt = {
|
||||
x_off = 1,
|
||||
@ -1052,6 +1075,7 @@ end
|
||||
|
||||
xl_chasey=mknew(chasey.new{
|
||||
size=2,
|
||||
xp = 10,
|
||||
maxspd=1.25,
|
||||
hurt = {
|
||||
x_off = 2,
|
||||
@ -1499,6 +1523,61 @@ end
|
||||
-->8
|
||||
-- powerups
|
||||
|
||||
xp_gem = mknew(bullet_base.new{
|
||||
dx = 0,
|
||||
dy = 0.75,
|
||||
width=1, -- not used for spr but
|
||||
height=1,-- bullet_base uses it
|
||||
category = enemy_blt_cat,
|
||||
damage = 0,
|
||||
hurt = {
|
||||
x_off = -2,
|
||||
y_off = -2,
|
||||
width = 8,
|
||||
height = 8,
|
||||
},
|
||||
x_off = 2,
|
||||
y_off = 2,
|
||||
})
|
||||
|
||||
function xp_gem:draw()
|
||||
local s,qx,qy = self.qsprite,0,0
|
||||
-- sprite map position:
|
||||
-- sprite id to x and y,
|
||||
-- offset shifts specific low
|
||||
-- bits of lframe up to the the
|
||||
-- bit with value 4 as a cheap
|
||||
-- way to pick an anim frame
|
||||
if (lframe&0x0.003 == 0) qx, qy = (lframe&0x0.0004)<<16, (lframe&0x0.0008)<<15
|
||||
sspr(
|
||||
(s%16<<3)+qx,
|
||||
(s\16<<3)+qy,
|
||||
4, 4,
|
||||
self.x, self.y
|
||||
)
|
||||
end
|
||||
|
||||
-- todo: "magnetic" behavior
|
||||
-- when near player ship
|
||||
|
||||
function xp_gem:hitship(ship)
|
||||
if (ship ~= primary_ship) return false
|
||||
primary_ship.xp += self.val
|
||||
primary_ship.last_xp_frame = lframe
|
||||
return true
|
||||
end
|
||||
|
||||
-- small gems for 1, 5, 25
|
||||
-- exactly; else huge
|
||||
function spawn_xp_at(x, y, off, amt)
|
||||
x += rnd(off+off)-off
|
||||
y += rnd(off+off)-off
|
||||
xp_gem.new{
|
||||
qsprite=amt == 1 and 32 or amt == 5 and 33 or amt == 25 and 34 or 35,
|
||||
val = amt,
|
||||
}:spawn_at(mid(x, 0, 124),mid(y,-4,125))
|
||||
end
|
||||
|
||||
powerup = mknew(bullet_base.new{
|
||||
-- animated sprite array: "sprites"
|
||||
-- to draw under or over anim,
|
||||
@ -1514,7 +1593,7 @@ powerup = mknew(bullet_base.new{
|
||||
-- but powerups should feel
|
||||
-- easy to pick up
|
||||
dx = 0,
|
||||
dy = 1.5, -- 0.75 after enemyspd
|
||||
dy = 0.75,
|
||||
category = enemy_blt_cat, -- collides with player ship
|
||||
damage = 0,
|
||||
|
||||
@ -1525,11 +1604,6 @@ powerup = mknew(bullet_base.new{
|
||||
-- sprite indexes for "sheen" animation
|
||||
sheen8x8 = split"2,54,55,56,57,58,59,60,61"
|
||||
|
||||
-- todo: draw two sprites
|
||||
-- on top of each other here
|
||||
-- so all powerups can share
|
||||
-- the "sheen" animation?
|
||||
|
||||
function powerup:draw()
|
||||
spr(self.sprites[max(1,
|
||||
((lframe<<16)\self.anim_speed)
|
||||
@ -1636,6 +1710,7 @@ function spawn_spec_gun_at(x, y, gunt)
|
||||
}
|
||||
gun_p:spawn_at(x, y)
|
||||
end
|
||||
|
||||
__gfx__
|
||||
00000000000650000000000000000000bb0b50b59909209200cc0c00000000003b00000082000000e00e8002e00e800200333300002222000000000000000000
|
||||
00000000006765000000000000cccc00b50b3055920940220c0000c000bbbb0037000000a2000000e0e8880240e8480403bbbb30028888200000000000000000
|
||||
@ -1653,14 +1728,14 @@ __gfx__
|
||||
000000005666657576667650000000000b0000b000000000000000000000000000000000000dd0009092220200000000c111111d656667650000000000000000
|
||||
0000000056565066665656500000000000bbbb0000000000000000000000000000000000000000000090020000000000c111111d650650650000000000000000
|
||||
00000000565000566500065000000000b000000b000000000000000000000000000000000000000000a00a0000000000cddddddd650000650000000000000000
|
||||
000000000000000000000000000000000000000000a0008000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000090008000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000000000000000000000000000000000000000800a0000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000080090000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000a080000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000009080000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000000c00070006000700066007600000000000a0008000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0c000700ccd07cd06cd07cd06ccd7ccd000000000090008000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0d000d000d000d006cd06cd06ccd6ccd0000000000800a0000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000d000d000dd00dd0000000000080090000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000000c000c00060006000670066000000000000a080000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0c000c00c7d0cc7067d06cd067cd6ccd000000000009080000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
07000c000d0007007cd06c707ccd6c77000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000d0007000dd00d70000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000cccccccccccccccc77000000007700000000770000000077000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000c116611dc11ee11d70000000077000000007700000000770000000070000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000c1611c1dc11ee11d00000000770000000077000000007700000000770000000700000000000000000000000000000000
|
||||
|
Loading…
x
Reference in New Issue
Block a user