Use eship_collider for ship collisions, too.
This commit is contained in:
		| @@ -238,14 +238,17 @@ function updategame() | ||||
|   lst:strip(call_move) | ||||
|  end | ||||
|  | ||||
| 	-- eship collider will be used | ||||
|  -- both for pship and pbullets. | ||||
|  local eship_collider = collider.new{from=eships} | ||||
|  | ||||
|  if not ps.dead then | ||||
|   ps:move() | ||||
|   local pbox = hurtbox(ps) | ||||
|   eships:strip(function(es) | ||||
|    if(not collides(pbox, hurtbox(es))) return | ||||
|   for es in all(eship_collider:get_collisions(pbox)) do | ||||
|    ps:hitship(es) | ||||
|    return es:hitship(ps) | ||||
|   end) | ||||
|    if(es:hitship(ps)) eship_collider:yoink(es) | ||||
|   end | ||||
|   ebullets:strip(function(eb) | ||||
|    -- loopify this when split moves implemented | ||||
|    eb:move() | ||||
| @@ -257,12 +260,8 @@ function updategame() | ||||
|   ebullets:strip(call_move) | ||||
|  end | ||||
|  | ||||
| 	-- many bullets and many enemy ships; | ||||
| 	-- use bucket collider for efficiency | ||||
|  local eship_collider = collider.new{from=eships} | ||||
|  | ||||
|  pbullets:strip(function(pb) | ||||
|   for es in all(eship_collider:get_collisions(pb)) do | ||||
|   for es in all(eship_collider:get_collisions(hurtbox(pb))) do | ||||
|    if (es:hitbullet(pb)) eship_collider:yoink(es) | ||||
|    if (pb:hitship(es)) return true | ||||
|   end | ||||
| @@ -1469,10 +1468,9 @@ function collider:yoink(item) | ||||
|  end | ||||
| end | ||||
|  | ||||
| function collider:get_collisions(item) | ||||
| function collider:get_collisions(box) | ||||
|  local found = { } | ||||
|  local seen = { } | ||||
|  local box = hurtbox(item) | ||||
|  local bucket_ids = collider_indexes(box) | ||||
|  for b_idx in all(bucket_ids) do | ||||
|   local bucket = self[b_idx] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user