Compare commits
	
		
			5 Commits
		
	
	
		
			fast_bulle
			...
			okay_slow_
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						67970a5164
	
				 | 
					
					
						|||
| 
						
						
							
						
						eaea42f993
	
				 | 
					
					
						|||
| 
						
						
							
						
						929f47fc78
	
				 | 
					
					
						|||
| 
						
						
							
						
						430a0a4b14
	
				 | 
					
					
						|||
| 
						
						
							
						
						e4062d3ccd
	
				 | 
					
					
						
							
								
								
									
										127
									
								
								vacuum_gambit.p8
									
									
									
									
									
								
							
							
						
						
									
										127
									
								
								vacuum_gambit.p8
									
									
									
									
									
								
							@@ -199,6 +199,7 @@ end
 | 
			
		||||
 | 
			
		||||
function _update60()
 | 
			
		||||
 mode:update()
 | 
			
		||||
 ustat = stat(1)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function ones(n)
 | 
			
		||||
@@ -257,30 +258,21 @@ function updategame()
 | 
			
		||||
   if(es:hitship(ps)) eship_collider:yoink(es)
 | 
			
		||||
  end
 | 
			
		||||
  ebullets:strip(function(eb)
 | 
			
		||||
   local disposition
 | 
			
		||||
   repeat
 | 
			
		||||
    disposition=eb:step()
 | 
			
		||||
    if collides(pbox, hurtbox(eb)) then
 | 
			
		||||
     ps:hitbullet(eb)
 | 
			
		||||
     if (eb:hitship(ps)) return true
 | 
			
		||||
    end
 | 
			
		||||
   until disposition
 | 
			
		||||
   return disposition == "dead"
 | 
			
		||||
   if (eb:move()) return true
 | 
			
		||||
   if (not collides(pbox, hurtbox(eb))) return
 | 
			
		||||
   ps:hitbullet(eb)
 | 
			
		||||
   return eb:hitship(ps)
 | 
			
		||||
  end)
 | 
			
		||||
 else
 | 
			
		||||
  ebullets:strip(function(eb) repeat until eb:step() end)
 | 
			
		||||
  ebullets:stripmove()
 | 
			
		||||
 end
 | 
			
		||||
 | 
			
		||||
 pbullets:strip(function(pb)
 | 
			
		||||
  local disposition
 | 
			
		||||
  repeat
 | 
			
		||||
   disposition=pb:step()
 | 
			
		||||
   for es in eship_collider:iterate_collisions(hurtbox(pb)) do
 | 
			
		||||
    if (es:hitbullet(pb)) eship_collider:yoink(es)
 | 
			
		||||
    if (pb:hitship(es)) return true
 | 
			
		||||
   end
 | 
			
		||||
  until disposition
 | 
			
		||||
  return disposition == "dead"
 | 
			
		||||
  if (pb:move()) return true
 | 
			
		||||
  for es in eship_collider:iterate_collisions(hurtbox(pb)) do
 | 
			
		||||
   if (es:hitbullet(pb)) eship_collider:yoink(es)
 | 
			
		||||
   if (pb:hitship(es)) return true
 | 
			
		||||
  end
 | 
			
		||||
 end)
 | 
			
		||||
 
 | 
			
		||||
 intangibles_fg:stripmove()
 | 
			
		||||
@@ -304,6 +296,8 @@ end
 | 
			
		||||
 | 
			
		||||
function _draw()
 | 
			
		||||
 mode:draw()
 | 
			
		||||
 local ds = stat(1)
 | 
			
		||||
 print(tostr(ustat).." + "..tostr(ds-ustat), 0, 122, 7)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function drawgame_top()
 | 
			
		||||
@@ -594,17 +588,22 @@ end
 | 
			
		||||
function ship_m:move()
 | 
			
		||||
 self:refresh_shield()
 | 
			
		||||
 local dx, dy, shoot_spec1, shoot_spec2 = self:act()
 | 
			
		||||
 dx = self:constrain(self.x, self.xmomentum, self.xmin, self.xmax, dx)
 | 
			
		||||
 dy = self:constrain(self.y, self.ymomentum, self.ymin, self.ymax, dy)
 | 
			
		||||
 local sg, xm, ym = self.special_guns, self.xmomentum, self.ymomentum
 | 
			
		||||
 dx = self:constrain(self.x, xm, self.xmin, self.xmax, dx)
 | 
			
		||||
 dy = self:constrain(self.y, ym, self.ymin, self.ymax, dy)
 | 
			
		||||
 self:maybe_shoot(self.main_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 sg then
 | 
			
		||||
  if (shoot_spec1) self:maybe_shoot(sg[1])
 | 
			
		||||
  if (shoot_spec2) self:maybe_shoot(sg[2])
 | 
			
		||||
 end
 | 
			
		||||
 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.ymomentum = self:calc_velocity(self.ymomentum, dy)
 | 
			
		||||
 xm = self:calc_velocity(xm, dx)
 | 
			
		||||
 ym = self:calc_velocity(ym, dy)
 | 
			
		||||
 | 
			
		||||
 self.x += self.xmomentum
 | 
			
		||||
 self.y += self.ymomentum
 | 
			
		||||
 self.x += xm
 | 
			
		||||
 self.y += ym
 | 
			
		||||
 self.xmomentum = xm
 | 
			
		||||
 self.ymomentum = ym
 | 
			
		||||
 | 
			
		||||
 return false
 | 
			
		||||
end
 | 
			
		||||
@@ -700,10 +699,7 @@ end
 | 
			
		||||
--   default: die, return true.
 | 
			
		||||
--   returns whether to delete
 | 
			
		||||
--   the bullet
 | 
			
		||||
bullet_base = mknew{
 | 
			
		||||
 steps=1,
 | 
			
		||||
 current_step=0
 | 
			
		||||
}
 | 
			
		||||
bullet_base = mknew{}
 | 
			
		||||
 | 
			
		||||
gun_base = mknew{ 
 | 
			
		||||
 shoot_ready = -32768,
 | 
			
		||||
@@ -829,29 +825,18 @@ function bullet_base:hitship(_)
 | 
			
		||||
 return true
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function bullet_base:step()
 | 
			
		||||
 self.current_step=(self.current_step+1)%self.steps
 | 
			
		||||
 self.x += self.dx
 | 
			
		||||
 self.y += self.dy
 | 
			
		||||
 if (self.f) self.f -= 1
 | 
			
		||||
 if ((self.y > 130) or (self.y < -self.height*8) or (self.f and self.f < 0) or (self.x > 128) or (self.x < -self.width*8)) return "dead"
 | 
			
		||||
 if (self.current_step == 0) return "stop"
 | 
			
		||||
function bullet_base:move()
 | 
			
		||||
 local x,y,f = self.x + self.dx, self.y+self.dy,self.f
 | 
			
		||||
 self.x,self.y=x,y
 | 
			
		||||
 if f then
 | 
			
		||||
  self.f = f-1
 | 
			
		||||
  if (f <= 0) return true
 | 
			
		||||
 end
 | 
			
		||||
 return (y> 130) or (y < -(self.height<<3)) or (x > 128) or (x < -(self.width<<3))
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
warmpal = {
 | 
			
		||||
 [0]=0,1,2,1,2,1,5,10,2,4,9,3,13,5,8,9
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function bullet_base:draw()
 | 
			
		||||
 local s,bx,by,dx,dy,w,h,st = self.sprite,self.x,self.y,self.dx,self.dy,self.width,self.height,self.steps
 | 
			
		||||
 if st > 1 then
 | 
			
		||||
  pal(warmpal)
 | 
			
		||||
   for n=st-1,1,-1 do
 | 
			
		||||
    spr(s, bx-n*dx, by-n*dy, w, h)
 | 
			
		||||
   end
 | 
			
		||||
  pal()
 | 
			
		||||
 end
 | 
			
		||||
 spr(s, bx, by, w, h)
 | 
			
		||||
 spr(self.sprite, self.x, self.y, self.width, self.height)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function bullet_base:spawn_at(x, y)
 | 
			
		||||
@@ -889,25 +874,20 @@ function gun_base:actually_shoot(x, y)
 | 
			
		||||
 self.shot_idx = idx
 | 
			
		||||
 shots = shots[idx]
 | 
			
		||||
 for s in all(shots) do
 | 
			
		||||
  local a,xo,v = unpack(s)
 | 
			
		||||
  v = v or veloc
 | 
			
		||||
  xo = xo or 0
 | 
			
		||||
  local a,xo,v = s[1]+aim, s[2] or 0, s[3] or veloc
 | 
			
		||||
  -- reverse x-offset for negative base angle
 | 
			
		||||
  if (aim < 0) xo = -xo
 | 
			
		||||
  a += aim
 | 
			
		||||
  -- todo: switch munition
 | 
			
		||||
  --  depending on angle
 | 
			
		||||
  --  (allows for non-round
 | 
			
		||||
  --   sprites and hitboxes on
 | 
			
		||||
  --   shots from guns with
 | 
			
		||||
  --   widely varying angles)
 | 
			
		||||
  local m = munition.new{}
 | 
			
		||||
  -- todo: automatically make
 | 
			
		||||
  -- high velocity shots do
 | 
			
		||||
  -- multiple collision checks
 | 
			
		||||
  m.dy = sin(a) * veloc
 | 
			
		||||
  m.dx = cos(a) * veloc
 | 
			
		||||
  m:spawn_at(x+(xo or 0), y)
 | 
			
		||||
  local m = munition.new{
 | 
			
		||||
   dx=cos(a)*v,
 | 
			
		||||
   dy=sin(a)*v
 | 
			
		||||
  }
 | 
			
		||||
  m:spawn_at(x+xo, y)
 | 
			
		||||
 end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -919,16 +899,15 @@ zap_p = mknew(bullet_base.new{
 | 
			
		||||
 --shape
 | 
			
		||||
 sprite = 8, --index of ammo sprite
 | 
			
		||||
 width = 0.25, --in 8x8 blocks
 | 
			
		||||
 height = 0.25,
 | 
			
		||||
 height = 1,
 | 
			
		||||
 hurt = { -- hurtbox - where this ship can be hit
 | 
			
		||||
  x_off = 0, -- upper left corner
 | 
			
		||||
  y_off = 0, -- relative to sprite
 | 
			
		||||
  width = 2,
 | 
			
		||||
  height = 2,
 | 
			
		||||
  height = 8,
 | 
			
		||||
 },
 | 
			
		||||
 x_off = 1, -- how to position by ship
 | 
			
		||||
 y_off = 0,
 | 
			
		||||
 steps=4,
 | 
			
		||||
 damage = 1,
 | 
			
		||||
 | 
			
		||||
 hitship = const_fxn(true),
 | 
			
		||||
@@ -939,7 +918,7 @@ zap_p = mknew(bullet_base.new{
 | 
			
		||||
zap_gun_p = mknew(gun_base.new{
 | 
			
		||||
 icon = 19,
 | 
			
		||||
 cooldown = 0x0.0020, -- frames between shots
 | 
			
		||||
 veloc = 2,
 | 
			
		||||
 veloc = 7,
 | 
			
		||||
 aim = 0.25,
 | 
			
		||||
 munition = zap_p,
 | 
			
		||||
 hdr = "mAIN gUN",
 | 
			
		||||
@@ -2032,14 +2011,14 @@ function rearm_mode:update()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
__gfx__
 | 
			
		||||
00000000000650000000000000000000bb0b50b59909209200cc0c00000000007b00000082000000e00e8002e00e800200333300002222000000000000000000
 | 
			
		||||
00000000006765000000000000cccc00b50b3055920940220c0000c000bbbb00bb000000a2000000e0e8880240e8480403bbbb30028888200000000000000000
 | 
			
		||||
00700700006d6500000000000cddddd00b33335009444420c00c000c0b33333000000000a8000000e88e2882e48e24823bbaabb3288aa8820000000000000000
 | 
			
		||||
00077000067c665000000000cdd10cd10b3dd350094dd42000c0000cb3350b3500000000a8000000e88e2882484e24423ba77ab328a77a820000000000000000
 | 
			
		||||
00077000067d665000000000cd10cdd100b3350000944200c0000000b350b33500000000a8000000e88e2882e84e28823ba77ab328a77a820000000000000000
 | 
			
		||||
0070070065666765000000000ddddd100b33355009444220c000000c0333335000000000a800000008888820048488203bbaabb3288aa8820000000000000000
 | 
			
		||||
000000006506506500000000001111000b0b5050090920200c0000c00055550000000000a2000000008882000048420003bbbb30028888200000000000000000
 | 
			
		||||
00000000650000650000000000000000000b50000009200000c0cc00000000000000000082000000000820000008200000333300002222000000000000000000
 | 
			
		||||
00000000000650000000000000000000bb0b50b59909209200cc0c00000000003b00000082000000e00e8002e00e800200333300002222000000000000000000
 | 
			
		||||
00000000006765000000000000cccc00b50b3055920940220c0000c000bbbb0037000000a2000000e0e8880240e8480403bbbb30028888200000000000000000
 | 
			
		||||
00700700006d6500000000000cddddd00b33335009444420c00c000c0b333330b7000000a8000000e88e2882e48e24823bbaabb3288aa8820000000000000000
 | 
			
		||||
00077000067c665000000000cdd10cd10b3dd350094dd42000c0000cb3350b35b7000000a8000000e88e2882484e24423ba77ab328a77a820000000000000000
 | 
			
		||||
00077000067d665000000000cd10cdd100b3350000944200c0000000b350b335b7000000a8000000e88e2882e84e28823ba77ab328a77a820000000000000000
 | 
			
		||||
0070070065666765000000000ddddd100b33355009444220c000000c03333350b7000000a800000008888820048488203bbaabb3288aa8820000000000000000
 | 
			
		||||
000000006506506500000000001111000b0b5050090920200c0000c000555500b7000000a2000000008882000048420003bbbb30028888200000000000000000
 | 
			
		||||
00000000650000650000000000000000000b50000009200000c0cc0000000000b700000082000000000820000008200000333300002222000000000000000000
 | 
			
		||||
0000000000065000000650000003b0000070070080000000700000000bb0000008800000000000000009200000000000cccccccd000650000000000000000000
 | 
			
		||||
000000000067500000076500000370000005500080000000b0000000b76300008a920000000000009009200200000000c111111d006765000000000000000000
 | 
			
		||||
00000000006d6500006d6500000b7000700660079000000030000000b663000089920000000550009994444200000000c111111d006d65000000000000000000
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user