Compare commits
	
		
			7 Commits
		
	
	
		
			do_rearm
			...
			gun_picker
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						26c3a5b91e
	
				 | 
					
					
						|||
| 
						
						
							
						
						44c70a028f
	
				 | 
					
					
						|||
| 
						
						
							
						
						a90caeba85
	
				 | 
					
					
						|||
| 
						
						
							
						
						cd5b79ef4a
	
				 | 
					
					
						|||
| 
						
						
							
						
						637eed1eb8
	
				 | 
					
					
						|||
| 
						
						
							
						
						55ab256539
	
				 | 
					
					
						|||
| 
						
						
							
						
						22d13121a9
	
				 | 
					
					
						
							
								
								
									
										384
									
								
								vacuum_gambit.p8
									
									
									
									
									
								
							
							
						
						
									
										384
									
								
								vacuum_gambit.p8
									
									
									
									
									
								
							@@ -363,8 +363,8 @@ function drawhud()
 | 
				
			|||||||
 line(127,1,127,127,5)
 | 
					 line(127,1,127,127,5)
 | 
				
			||||||
 line(113,127)
 | 
					 line(113,127)
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
 draw_gun_info("❎",1,116,3,primary_ship.main_gun)
 | 
					 draw_gun_info("❎",1,116,3,1)
 | 
				
			||||||
 draw_gun_info("🅾️",1,116,29,primary_ship.special_gun)
 | 
					 draw_gun_info("🅾️",1,116,29,2)
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
 inset(114,57,119,118)
 | 
					 inset(114,57,119,118)
 | 
				
			||||||
 rectfill(119,57,124,58,13)
 | 
					 rectfill(119,57,124,58,13)
 | 
				
			||||||
@@ -404,25 +404,26 @@ function drawhud()
 | 
				
			|||||||
 fillp(0)
 | 
					 fillp(0)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function draw_gun_info(lbl,fgc,x,y,gun)
 | 
					function draw_gun_info(lbl,fgc,x,y,gn)
 | 
				
			||||||
 dropshadow(lbl,x,y,fgc)
 | 
					 dropshadow(lbl,x,y,fgc)
 | 
				
			||||||
 inset(114,y+7,125,y+18)
 | 
					 inset(114,y+7,125,y+18)
 | 
				
			||||||
 inset(114,y+20,125,y+24)
 | 
					 inset(114,y+20,125,y+24)
 | 
				
			||||||
 if(gun) then
 | 
					 if (not primary_ship.special_guns) return
 | 
				
			||||||
  spr(gun.icon,116,y+9,1,1)
 | 
					 local gun = primary_ship.special_guns[gn]
 | 
				
			||||||
  --115 to 124 - ammo bar. round up
 | 
					 if (not gun) return
 | 
				
			||||||
  if gun.ammo == nil then
 | 
					 spr(gun.icon,116,y+9,1,1)
 | 
				
			||||||
   fillp(0xa5a5)
 | 
					 --115 to 124 - ammo bar. round up
 | 
				
			||||||
   rectfill(115,y+21,124,y+23,0xea)
 | 
					 if gun.ammo == nil then
 | 
				
			||||||
   fillp(0)
 | 
					  fillp(0xa5a5)
 | 
				
			||||||
  elseif gun.ammo > 0 then
 | 
					  rectfill(115,y+21,124,y+23,0xea)
 | 
				
			||||||
   rectfill(
 | 
					  fillp(0)
 | 
				
			||||||
     115,y+21,
 | 
					 elseif gun.ammo > 0 then
 | 
				
			||||||
     115+flr(9*gun.ammo/gun.maxammo),
 | 
					  rectfill(
 | 
				
			||||||
     y+23,10)
 | 
					    115,y+21,
 | 
				
			||||||
  else
 | 
					    115+flr(9*gun.ammo/gun.maxammo),
 | 
				
			||||||
   line(118, y+22, 121, y+22, 2)
 | 
					    y+23,10)
 | 
				
			||||||
  end
 | 
					 else
 | 
				
			||||||
 | 
					  line(118, y+22, 121, y+22, 2)
 | 
				
			||||||
 end
 | 
					 end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -554,11 +555,12 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
function ship_m:move()
 | 
					function ship_m:move()
 | 
				
			||||||
 self:refresh_shield()
 | 
					 self:refresh_shield()
 | 
				
			||||||
 local dx, dy, shoot_spec, shoot_main = self:act()
 | 
					 local dx, dy, shoot_spec1, shoot_spec2 = self:act()
 | 
				
			||||||
 dx = self:constrain(self.x, self.xmomentum, self.xmin, self.xmax, dx)
 | 
					 dx = self:constrain(self.x, self.xmomentum, self.xmin, self.xmax, dx)
 | 
				
			||||||
 dy = self:constrain(self.y, self.ymomentum, self.ymin, self.ymax, dy)
 | 
					 dy = self:constrain(self.y, self.ymomentum, self.ymin, self.ymax, dy)
 | 
				
			||||||
 if (shoot_main) self:maybe_shoot(self.main_gun)
 | 
					 self:maybe_shoot(self.main_gun)
 | 
				
			||||||
 if (shoot_spec) self:maybe_shoot(self.special_gun)
 | 
					 if (shoot_spec1 and self.special_guns) self:maybe_shoot(self.special_guns[1])
 | 
				
			||||||
 | 
					 if (shoot_spec2 and self.special_guns) self:maybe_shoot(self.special_guns[2])
 | 
				
			||||||
 if (dx ~= 0 or dy ~= 0) spark(self.sparks, self.x + 4*self.size, self.y + 4*self.size, dx*2.5, dy*2.5, self.sparkodds)
 | 
					 if (dx ~= 0 or dy ~= 0) spark(self.sparks, self.x + 4*self.size, self.y + 4*self.size, dx*2.5, dy*2.5, self.sparkodds)
 | 
				
			||||||
 self.xmomentum = self:calc_velocity(self.xmomentum, dx)
 | 
					 self.xmomentum = self:calc_velocity(self.xmomentum, dx)
 | 
				
			||||||
 self.ymomentum = self:calc_velocity(self.ymomentum, dy)
 | 
					 self.ymomentum = self:calc_velocity(self.ymomentum, dy)
 | 
				
			||||||
@@ -681,6 +683,20 @@ gun_base = mknew{
 | 
				
			|||||||
 icon = 20
 | 
					 icon = 20
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- gun_base subtypes are
 | 
				
			||||||
 | 
					-- level-up options that,
 | 
				
			||||||
 | 
					-- as an action, assign
 | 
				
			||||||
 | 
					-- themselves to the player
 | 
				
			||||||
 | 
					function gun_base:action()
 | 
				
			||||||
 | 
					 local item = self.new()
 | 
				
			||||||
 | 
					 item.ammo = item.maxammo
 | 
				
			||||||
 | 
					 if not primary_ship.special_guns then
 | 
				
			||||||
 | 
					  primary_ship.special_guns = {item}
 | 
				
			||||||
 | 
					 else
 | 
				
			||||||
 | 
					  add(primary_ship.special_guns, item)
 | 
				
			||||||
 | 
					 end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function bullet_base:hitship(_)
 | 
					function bullet_base:hitship(_)
 | 
				
			||||||
 self:die()
 | 
					 self:die()
 | 
				
			||||||
 return true
 | 
					 return true
 | 
				
			||||||
@@ -763,13 +779,13 @@ zap_p = mknew(zap_e.new{
 | 
				
			|||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
zap_gun_e = mknew(gun_base.new{
 | 
					zap_gun_e = mknew(gun_base.new{
 | 
				
			||||||
 cooldown = 0x0.000a, -- frames between shots
 | 
					 cooldown = 0x0.0020, -- frames between shots
 | 
				
			||||||
 ammo = nil, -- unlimited ammo - main gun
 | 
					 | 
				
			||||||
 actually_shoot = spawn_one(zap_e),
 | 
					 actually_shoot = spawn_one(zap_e),
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
zap_gun_p = mknew(zap_gun_e.new{
 | 
					zap_gun_p = mknew(zap_gun_e.new{
 | 
				
			||||||
 actually_shoot = spawn_one(zap_p),
 | 
					 actually_shoot = spawn_one(zap_p),
 | 
				
			||||||
 | 
					 hdr = "mAIN gUN",
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
blast = mknew(bullet_base.new{
 | 
					blast = mknew(bullet_base.new{
 | 
				
			||||||
@@ -788,17 +804,22 @@ blast = mknew(bullet_base.new{
 | 
				
			|||||||
 
 | 
					 
 | 
				
			||||||
 damage = 4,
 | 
					 damage = 4,
 | 
				
			||||||
 dx = 0,  -- px/frame
 | 
					 dx = 0,  -- px/frame
 | 
				
			||||||
 dy = -2,
 | 
					 dy = -1,
 | 
				
			||||||
 awaitcancel = false,
 | 
					 awaitcancel = false,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 -- disable damage for 2 frames
 | 
					 -- disable damage for 4 frames
 | 
				
			||||||
 -- when hitting something
 | 
					 -- when hitting something
 | 
				
			||||||
 | 
					 -- todo: rewrite all ship hit
 | 
				
			||||||
 | 
					 --   logic so i can avoid
 | 
				
			||||||
 | 
					 --   repeating hits to the
 | 
				
			||||||
 | 
					 --   same ship instead of
 | 
				
			||||||
 | 
					 --   using a cooldown
 | 
				
			||||||
 hitship = function(self, _)
 | 
					 hitship = function(self, _)
 | 
				
			||||||
  if self.damage > 0 and not self.awaitcancel then
 | 
					  if self.damage > 0 and not self.awaitcancel then
 | 
				
			||||||
   self.awaitcancel = true
 | 
					   self.awaitcancel = true
 | 
				
			||||||
   once_next_frame(function()
 | 
					   once_next_frame(function()
 | 
				
			||||||
    new_events:push_back{
 | 
					    new_events:push_back{
 | 
				
			||||||
     wait = 2,
 | 
					     wait = 4,
 | 
				
			||||||
     obj = self,
 | 
					     obj = self,
 | 
				
			||||||
     saved_dmg = self.damage,
 | 
					     saved_dmg = self.damage,
 | 
				
			||||||
     move = function(self)
 | 
					     move = function(self)
 | 
				
			||||||
@@ -819,10 +840,20 @@ blast = mknew(bullet_base.new{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
blast_gun = mknew(gun_base.new{
 | 
					blast_gun = mknew(gun_base.new{
 | 
				
			||||||
 icon = 13,
 | 
					 icon = 13,
 | 
				
			||||||
 cooldown = 0x0.0020, -- frames between shots
 | 
					 cooldown = 0x0.0078, -- 120 frames between shots
 | 
				
			||||||
 ammo = 5,
 | 
					 ammo = 5,
 | 
				
			||||||
 maxammo = 5,
 | 
					 maxammo = 5,
 | 
				
			||||||
 actually_shoot = spawn_one(blast),
 | 
					 actually_shoot = spawn_one(blast),
 | 
				
			||||||
 | 
					 hdr = "bLASTER",
 | 
				
			||||||
 | 
					 body= [[plasma orb
 | 
				
			||||||
 | 
					cuts through
 | 
				
			||||||
 | 
					enemies.
 | 
				
			||||||
 | 
					slow.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ammo: 5
 | 
				
			||||||
 | 
					rate: 1/2sec
 | 
				
			||||||
 | 
					 dmg: 4
 | 
				
			||||||
 | 
					]],
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protron_e = mknew(bullet_base.new{
 | 
					protron_e = mknew(bullet_base.new{
 | 
				
			||||||
@@ -854,7 +885,7 @@ protron_p = mknew(protron_e.new{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
protron_gun_e = mknew(gun_base.new{
 | 
					protron_gun_e = mknew(gun_base.new{
 | 
				
			||||||
 icon = 25,
 | 
					 icon = 25,
 | 
				
			||||||
 cooldown = 0x0.000f, -- frames between shots
 | 
					 cooldown = 0x0.0040, -- frames between shots
 | 
				
			||||||
 ammo = nil,
 | 
					 ammo = nil,
 | 
				
			||||||
 maxammo = nil,
 | 
					 maxammo = nil,
 | 
				
			||||||
 munition = protron_e
 | 
					 munition = protron_e
 | 
				
			||||||
@@ -883,6 +914,17 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
protron_gun_p = mknew(protron_gun_e.new{
 | 
					protron_gun_p = mknew(protron_gun_e.new{
 | 
				
			||||||
 munition = protron_p,
 | 
					 munition = protron_p,
 | 
				
			||||||
 | 
					 maxammo = 20,
 | 
				
			||||||
 | 
					 cooldown = 0x0.0018,
 | 
				
			||||||
 | 
					 hdr = "pROTRON",
 | 
				
			||||||
 | 
					 body = [[spray shots
 | 
				
			||||||
 | 
					in a dense
 | 
				
			||||||
 | 
					arc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ammo: 20
 | 
				
			||||||
 | 
					rate: 2/sec
 | 
				
			||||||
 | 
					 dmg: 1
 | 
				
			||||||
 | 
					]],
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
vulcan_e = mknew(bullet_base.new{
 | 
					vulcan_e = mknew(bullet_base.new{
 | 
				
			||||||
@@ -915,7 +957,7 @@ vulcan_p = mknew(vulcan_e.new{
 | 
				
			|||||||
vulcan_gun_e = mknew(gun_base.new{
 | 
					vulcan_gun_e = mknew(gun_base.new{
 | 
				
			||||||
 icon = 37,
 | 
					 icon = 37,
 | 
				
			||||||
 enemy = false,
 | 
					 enemy = false,
 | 
				
			||||||
 cooldown = 0x0.0002, -- frames between shots
 | 
					 cooldown = 0x0.0003, -- frames between shots
 | 
				
			||||||
 ammo = nil,
 | 
					 ammo = nil,
 | 
				
			||||||
 maxammo = nil,
 | 
					 maxammo = nil,
 | 
				
			||||||
 munition=vulcan_e,
 | 
					 munition=vulcan_e,
 | 
				
			||||||
@@ -934,6 +976,16 @@ vulcan_gun_e = mknew(gun_base.new{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
vulcan_gun_p = mknew(vulcan_gun_e.new{
 | 
					vulcan_gun_p = mknew(vulcan_gun_e.new{
 | 
				
			||||||
 munition=vulcan_p,
 | 
					 munition=vulcan_p,
 | 
				
			||||||
 | 
					 maxammo = 100,
 | 
				
			||||||
 | 
					 hdr = "vULCAN",
 | 
				
			||||||
 | 
					 body = [[rapid fire
 | 
				
			||||||
 | 
					in a v
 | 
				
			||||||
 | 
					shape.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ammo: 100
 | 
				
			||||||
 | 
					rate: 20/sec
 | 
				
			||||||
 | 
					 dmg: 0.5
 | 
				
			||||||
 | 
					]],
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-->8
 | 
					-->8
 | 
				
			||||||
@@ -970,7 +1022,7 @@ player = mknew(ship_m.new{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 -- gun
 | 
					 -- gun
 | 
				
			||||||
 main_gun = nil, -- assign at spawn time
 | 
					 main_gun = nil, -- assign at spawn time
 | 
				
			||||||
 special_gun = nil,
 | 
					 special_guns = nil,
 | 
				
			||||||
 fire_off_x = 4,  -- offset where bullets come from
 | 
					 fire_off_x = 4,  -- offset where bullets come from
 | 
				
			||||||
 fire_off_y = 0,
 | 
					 fire_off_y = 0,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1113,6 +1165,7 @@ chasey = mknew(ship_m.new{
 | 
				
			|||||||
 end
 | 
					 end
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- todo: use constraints
 | 
				
			||||||
function chasey:act()
 | 
					function chasey:act()
 | 
				
			||||||
 self.xmin = max(primary_ship.x-8, 0)
 | 
					 self.xmin = max(primary_ship.x-8, 0)
 | 
				
			||||||
 self.xmax = min(primary_ship.x + 8, 112 - 8*self.size)
 | 
					 self.xmax = min(primary_ship.x + 8, 112 - 8*self.size)
 | 
				
			||||||
@@ -1345,32 +1398,9 @@ function spawn_blocking_spewy()
 | 
				
			|||||||
 end
 | 
					 end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function spawn_bonus_frownie()
 | 
					function spawn_vulcan_chasey()
 | 
				
			||||||
 local f = spawn_frownie()
 | 
					 | 
				
			||||||
 f.sprite = 7
 | 
					 | 
				
			||||||
 f.die = function(self)
 | 
					 | 
				
			||||||
  spawn_repair_at(self.x+4, self.y+4)
 | 
					 | 
				
			||||||
  frownie.die(self)
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
end 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function spawn_bonus_vulcan_chasey()
 | 
					 | 
				
			||||||
 local c = spawn_chasey()
 | 
					 local c = spawn_chasey()
 | 
				
			||||||
 c.main_gun=vulcan_gun_e.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_p)
 | 
					 | 
				
			||||||
  chasey.die(self)
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
 c.sprite=4
 | 
					 | 
				
			||||||
 return c
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function spawn_bonus_shield_chasey()
 | 
					 | 
				
			||||||
 local c = spawn_chasey()
 | 
					 | 
				
			||||||
 c.die = function(self)
 | 
					 | 
				
			||||||
  spawn_shield_upgrade_at(self.x-1, self.y-1)
 | 
					 | 
				
			||||||
  chasey.die(self)
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
 c.sprite=4
 | 
					 c.sprite=4
 | 
				
			||||||
 return c
 | 
					 return c
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@@ -1419,7 +1449,6 @@ function spawn_rnd(typ, blocking, goodie,altspr)
 | 
				
			|||||||
   freeze -= self.ice
 | 
					   freeze -= self.ice
 | 
				
			||||||
   self.ice=0
 | 
					   self.ice=0
 | 
				
			||||||
   typ.die(self)
 | 
					   typ.die(self)
 | 
				
			||||||
   spawn_goodie(goodie, self.x, self.y, self.size)
 | 
					 | 
				
			||||||
  end,
 | 
					  end,
 | 
				
			||||||
 }
 | 
					 }
 | 
				
			||||||
 if (altspr) s.spr = altspr
 | 
					 if (altspr) s.spr = altspr
 | 
				
			||||||
@@ -1427,14 +1456,6 @@ function spawn_rnd(typ, blocking, goodie,altspr)
 | 
				
			|||||||
 return s
 | 
					 return s
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- TODO: spawn_goodie compatible versions of gun drops
 | 
					 | 
				
			||||||
-- TODO: goodie table
 | 
					 | 
				
			||||||
function spawn_goodie(goodie_name, x, y, sz)
 | 
					 | 
				
			||||||
 if (not goodie_name or #goodie_name == 0) return
 | 
					 | 
				
			||||||
 local sh = sz and sz/2 or 0
 | 
					 | 
				
			||||||
 _ENV[goodie_name].new{}:spawn_at(x+sh,y+sh)
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function multi(times, interval, fnm, ...)
 | 
					function multi(times, interval, fnm, ...)
 | 
				
			||||||
 local f,irm,vargs = _ENV[fnm],interval,pack(...)
 | 
					 local f,irm,vargs = _ENV[fnm],interval,pack(...)
 | 
				
			||||||
 assert(type(f) == "function", fnm.." not a function")
 | 
					 assert(type(f) == "function", fnm.." not a function")
 | 
				
			||||||
@@ -1457,31 +1478,29 @@ end
 | 
				
			|||||||
-- where offset,eol is a special case.
 | 
					-- where offset,eol is a special case.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
example_level_csv=[[1,spawn_frownie
 | 
					example_level_csv=[[1,spawn_frownie
 | 
				
			||||||
60,spawn_bonus_vulcan_chasey
 | 
					60,spawn_vulcan_chasey
 | 
				
			||||||
61,spawn_blocky
 | 
					61,spawn_blocky
 | 
				
			||||||
85,spawn_spewy
 | 
					85,spawn_spewy
 | 
				
			||||||
100,spawn_spewy
 | 
					 | 
				
			||||||
115,spawn_spewy
 | 
					115,spawn_spewy
 | 
				
			||||||
130,spawn_bonus_frownie
 | 
					130,spawn_frownie
 | 
				
			||||||
145,spawn_spewy
 | 
					145,spawn_frownie
 | 
				
			||||||
200,spawn_bonus_shield_chasey
 | 
					180,spawn_spewy
 | 
				
			||||||
 | 
					230,spawn_chasey
 | 
				
			||||||
250,spawn_blocking_blocky
 | 
					250,spawn_blocking_blocky
 | 
				
			||||||
285,spawn_spec_gun_at,35,-11,blast_gun
 | 
					 | 
				
			||||||
310,spawn_blocking_blocky
 | 
					310,spawn_blocking_blocky
 | 
				
			||||||
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_p
 | 
					 | 
				
			||||||
401,spawn_frownie
 | 
					401,spawn_frownie
 | 
				
			||||||
420,spawn_blocking_frownie
 | 
					420,spawn_blocking_frownie
 | 
				
			||||||
430,spawn_bonus_vulcan_chasey
 | 
					430,spawn_vulcan_chasey
 | 
				
			||||||
450,spawn_frownie
 | 
					450,spawn_frownie
 | 
				
			||||||
465,spawn_bonus_frownie
 | 
					465,spawn_frownie
 | 
				
			||||||
480,spawn_chasey
 | 
					480,spawn_chasey
 | 
				
			||||||
500,multi,20,12,spawn_blocking_blocky
 | 
					500,multi,20,12,spawn_blocking_blocky
 | 
				
			||||||
501,spawn_bonus_frownie
 | 
					501,spawn_frownie
 | 
				
			||||||
620,spawn_blocking_blocky
 | 
					620,spawn_blocking_blocky
 | 
				
			||||||
630,spawn_bonus_shield_chasey
 | 
					630,spawn_vulcan_chasey
 | 
				
			||||||
720,spawn_blocking_boss_chasey
 | 
					720,spawn_blocking_boss_chasey
 | 
				
			||||||
721,eol]]
 | 
					721,eol]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1624,137 +1643,73 @@ function spawn_xp_at(x, y, off, amt)
 | 
				
			|||||||
 }:spawn_at(mid(x, 0, 124),mid(y,-4,125))
 | 
					 }:spawn_at(mid(x, 0, 124),mid(y,-4,125))
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
powerup = mknew(bullet_base.new{
 | 
					-->8
 | 
				
			||||||
 -- animated sprite array: "sprites"
 | 
					-- upgrade options
 | 
				
			||||||
 -- to draw under or over anim,
 | 
					 | 
				
			||||||
 -- override draw, draw the
 | 
					 | 
				
			||||||
 -- under-part, call into
 | 
					 | 
				
			||||||
 -- powerup.draw(self), then
 | 
					 | 
				
			||||||
 -- draw the over-part
 | 
					 | 
				
			||||||
 width = 1,
 | 
					 | 
				
			||||||
 height = 1,
 | 
					 | 
				
			||||||
 -- note: make hurtboxes larger
 | 
					 | 
				
			||||||
 -- than sprite by 2px per side
 | 
					 | 
				
			||||||
 -- since ship hitbox is tiny
 | 
					 | 
				
			||||||
 -- but powerups should feel
 | 
					 | 
				
			||||||
 -- easy to pick up
 | 
					 | 
				
			||||||
 dx = 0,
 | 
					 | 
				
			||||||
 dy = 0.75,
 | 
					 | 
				
			||||||
 category = enemy_blt_cat, -- collides with player ship
 | 
					 | 
				
			||||||
 damage = 0,
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 anim_speed = 2,
 | 
					 | 
				
			||||||
 loop_pause = 30 -- affected by animspeed
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- sprite indexes for "sheen" animation
 | 
					-- all these return
 | 
				
			||||||
sheen8x8 = split"2,54,55,56,57,58,59,60,61"
 | 
					-- a [2] of rearm_t:
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					-- icon: sprite id
 | 
				
			||||||
 | 
					-- hdr: title text
 | 
				
			||||||
 | 
					-- body: text
 | 
				
			||||||
 | 
					-- action: callback
 | 
				
			||||||
 | 
					--    (method)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function powerup:draw()
 | 
					spec_gunt = {
 | 
				
			||||||
 spr(self.sprites[max(1,
 | 
					 protron_gun_p,
 | 
				
			||||||
       ((lframe<<16)\self.anim_speed)
 | 
					 vulcan_gun_p,
 | 
				
			||||||
       %(#self.sprites+self.loop_pause)
 | 
					 blast_gun,
 | 
				
			||||||
       -self.loop_pause
 | 
					 | 
				
			||||||
       +1)],
 | 
					 | 
				
			||||||
     self.x, self.y,
 | 
					 | 
				
			||||||
     self.width, self.height) 
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
repair = mknew(powerup.new{
 | 
					 | 
				
			||||||
 hurt = {
 | 
					 | 
				
			||||||
  x_off = -2,
 | 
					 | 
				
			||||||
  y_off = -2,
 | 
					 | 
				
			||||||
  width = 12,
 | 
					 | 
				
			||||||
  height = 12
 | 
					 | 
				
			||||||
 },
 | 
					 | 
				
			||||||
 x_off = 4,
 | 
					 | 
				
			||||||
 y_off = 0,
 | 
					 | 
				
			||||||
 sprites = sheen8x8,
 | 
					 | 
				
			||||||
 icon = 53,
 | 
					 | 
				
			||||||
 hitship = function(self, ship)
 | 
					 | 
				
			||||||
  if (ship ~= primary_ship) return false
 | 
					 | 
				
			||||||
  primary_ship.hp = min(primary_ship.maxhp, primary_ship.hp + 1)
 | 
					 | 
				
			||||||
  return true
 | 
					 | 
				
			||||||
 end,
 | 
					 | 
				
			||||||
 draw = function(self)
 | 
					 | 
				
			||||||
  spr(self.icon, self.x, self.y, self.width, self.height)
 | 
					 | 
				
			||||||
  powerup.draw(self)
 | 
					 | 
				
			||||||
 end  
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function spawn_repair_at(x, y)
 | 
					 | 
				
			||||||
 repair.new():spawn_at(x, y)
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
shield_upgrade = mknew(repair.new{
 | 
					 | 
				
			||||||
 icon=52
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function shield_upgrade:hitship(ship)
 | 
					 | 
				
			||||||
 if (ship ~= primary_ship) return false
 | 
					 | 
				
			||||||
 primary_ship.maxshield += 1
 | 
					 | 
				
			||||||
 return true
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function spawn_shield_upgrade_at(x, y)
 | 
					 | 
				
			||||||
 shield_upgrade.new():spawn_at(x,y)
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
gun_swap = mknew(powerup.new{
 | 
					 | 
				
			||||||
 hurt = {
 | 
					 | 
				
			||||||
  x_off = -2,
 | 
					 | 
				
			||||||
  y_off = -2,
 | 
					 | 
				
			||||||
  width = 16,
 | 
					 | 
				
			||||||
  height = 16
 | 
					 | 
				
			||||||
 },
 | 
					 | 
				
			||||||
 -- gun = gun_type.new{}
 | 
					 | 
				
			||||||
 x_off = 6,
 | 
					 | 
				
			||||||
 y_off = 0,
 | 
					 | 
				
			||||||
 width = 2,
 | 
					 | 
				
			||||||
 height = 2,
 | 
					 | 
				
			||||||
 sprites = {64, 66, 68, 70, 72, 74, 76, 78},
 | 
					 | 
				
			||||||
 hitship = function(self, ship)
 | 
					 | 
				
			||||||
  if (ship ~= primary_ship) return false
 | 
					 | 
				
			||||||
  ship.main_gun = self.gun
 | 
					 | 
				
			||||||
  return true
 | 
					 | 
				
			||||||
 end,
 | 
					 | 
				
			||||||
 draw = function(self)
 | 
					 | 
				
			||||||
  powerup.draw(self)
 | 
					 | 
				
			||||||
  spr(self.gun.icon, self.x+2, self.y+2, 1, 1)
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function spawn_main_gun_at(x, y, gunt)
 | 
					 | 
				
			||||||
 if (type(gunt)=="string") gunt=_ENV[gunt]
 | 
					 | 
				
			||||||
 local gun_p = gun_swap.new{
 | 
					 | 
				
			||||||
  gun = gunt.new()
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
 gun_p:spawn_at(x, y)
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
spec_gun_pl = {
 | 
					 | 
				
			||||||
 [1] = 2,
 | 
					 | 
				
			||||||
 [14] = 6,
 | 
					 | 
				
			||||||
 [2] = 14
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function spawn_spec_gun_at(x, y, gunt)
 | 
					-- picks n random items from
 | 
				
			||||||
 if (type(gunt)=="string") gunt=_ENV[gunt]
 | 
					-- tbl; permutes tbl, selected
 | 
				
			||||||
 local gun_p = gun_swap.new{
 | 
					-- items at end
 | 
				
			||||||
  gun = gunt.new(),
 | 
					function pick(tbl, n)
 | 
				
			||||||
  hitship = function(self, ship)
 | 
					 local ret, top={}, #tbl
 | 
				
			||||||
   if (ship ~= primary_ship) return false
 | 
					 for x=top,top-n,-1 do
 | 
				
			||||||
   ship.special_gun = self.gun
 | 
					  local idx = 1+rnd(x)\1
 | 
				
			||||||
  return true
 | 
					  add(ret, tbl[idx])
 | 
				
			||||||
  end,
 | 
					  tbl[idx]=tbl[x]
 | 
				
			||||||
  draw = function(self)
 | 
					  tbl[x]=ret[#ret]
 | 
				
			||||||
   pal(spec_gun_pl)
 | 
					 end
 | 
				
			||||||
   powerup.draw(self)
 | 
					 return ret
 | 
				
			||||||
   pal()
 | 
					end
 | 
				
			||||||
   spr(self.gun.icon, self.x+2, self.y+2, 1, 1)
 | 
					
 | 
				
			||||||
  end
 | 
					-- add a new gun
 | 
				
			||||||
 }
 | 
					function spec_gun_opts()
 | 
				
			||||||
 gun_p:spawn_at(x, y)
 | 
					 return pick(spec_gunt, 2)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- major upgrades
 | 
				
			||||||
 | 
					function big_opts()
 | 
				
			||||||
 | 
					 return {{
 | 
				
			||||||
 | 
					  icon=1,
 | 
				
			||||||
 | 
					  hdr="placeholder",
 | 
				
			||||||
 | 
					  body="placeholder",
 | 
				
			||||||
 | 
					  action = function() end,
 | 
				
			||||||
 | 
					 },
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					  icon=1,
 | 
				
			||||||
 | 
					  hdr="placeholder",
 | 
				
			||||||
 | 
					  body="placeholder",
 | 
				
			||||||
 | 
					  action = function() end,
 | 
				
			||||||
 | 
					 }}
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- ordinary upgrades
 | 
				
			||||||
 | 
					function small_opts()
 | 
				
			||||||
 | 
					 return {{
 | 
				
			||||||
 | 
					  icon=1,
 | 
				
			||||||
 | 
					  hdr="placeholder",
 | 
				
			||||||
 | 
					  body="placeholder",
 | 
				
			||||||
 | 
					  action = function() end,
 | 
				
			||||||
 | 
					 },
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					  icon=1,
 | 
				
			||||||
 | 
					  hdr="placeholder",
 | 
				
			||||||
 | 
					  body="placeholder",
 | 
				
			||||||
 | 
					  action = function() end,
 | 
				
			||||||
 | 
					 }}
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-->8
 | 
					-->8
 | 
				
			||||||
@@ -1811,7 +1766,7 @@ end
 | 
				
			|||||||
function rearm_mode:draw_option(id)
 | 
					function rearm_mode:draw_option(id)
 | 
				
			||||||
 local rec = self.options[id]
 | 
					 local rec = self.options[id]
 | 
				
			||||||
 self:glow_box(0,0,55,100,self:frame_col(self.sel == id),1)
 | 
					 self:glow_box(0,0,55,100,self:frame_col(self.sel == id),1)
 | 
				
			||||||
 spr(rec.s,5, 5)
 | 
					 spr(rec.icon,5, 5)
 | 
				
			||||||
 print(rec.hdr, 13, 8, 7)
 | 
					 print(rec.hdr, 13, 8, 7)
 | 
				
			||||||
 print(rec.body, 5, 15, 6)
 | 
					 print(rec.body, 5, 15, 6)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@@ -1828,17 +1783,14 @@ function rearm_mode:shuffle()
 | 
				
			|||||||
 -- these will be placeholders
 | 
					 -- these will be placeholders
 | 
				
			||||||
 -- until the upgrade deck
 | 
					 -- until the upgrade deck
 | 
				
			||||||
 -- is a thing that exists
 | 
					 -- is a thing that exists
 | 
				
			||||||
 self.options = {{
 | 
					 local lev = primary_ship.level + 1
 | 
				
			||||||
  s=1,
 | 
					 if lev == 4 or lev == 12 then
 | 
				
			||||||
  hdr=" hull",
 | 
					  self.options = spec_gun_opts()
 | 
				
			||||||
  body = "\n    +1\n   max\n  health",
 | 
					 elseif lev % 4 == 0 then
 | 
				
			||||||
  action = function() end,
 | 
					  self.options = big_opts()
 | 
				
			||||||
 },{
 | 
					 else
 | 
				
			||||||
  s=37,
 | 
					  self.options = small_opts()
 | 
				
			||||||
  hdr=" vulc",
 | 
					 end
 | 
				
			||||||
  body = "\nplaceholder",
 | 
					 | 
				
			||||||
  action = function() end,
 | 
					 | 
				
			||||||
 }}
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function rearm_mode:draw()
 | 
					function rearm_mode:draw()
 | 
				
			||||||
@@ -1894,7 +1846,11 @@ function rearm_mode:update()
 | 
				
			|||||||
   -- todo: sound: rearm
 | 
					   -- todo: sound: rearm
 | 
				
			||||||
   primary_ship.shield = primary_ship.maxshield
 | 
					   primary_ship.shield = primary_ship.maxshield
 | 
				
			||||||
   -- todo: rewrite for three guns
 | 
					   -- todo: rewrite for three guns
 | 
				
			||||||
   if (primary_ship.special_gun) primary_ship.special_gun.ammo = primary_ship.special_gun.max_ammo
 | 
					   local specs = primary_ship.special_guns
 | 
				
			||||||
 | 
					   if specs then
 | 
				
			||||||
 | 
					    specs[1].ammo = specs[1].maxammo
 | 
				
			||||||
 | 
					    if (specs[2]) specs[2].ammo = specs[2].maxammo
 | 
				
			||||||
 | 
					   end
 | 
				
			||||||
   primary_ship.hp = min(primary_ship.maxhp, primary_ship.hp + primary_ship.maxhp/2)
 | 
					   primary_ship.hp = min(primary_ship.maxhp, primary_ship.hp + primary_ship.maxhp/2)
 | 
				
			||||||
   primary_ship.xp -= primary_ship.xptarget / 2
 | 
					   primary_ship.xp -= primary_ship.xptarget / 2
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user