Permalink
Browse files

(hopefully) fixed crash issue with powerups

  • Loading branch information...
1 parent f506442 commit 805827c0fc6c136d4462243f15656f6ed749d526 @Textmode Textmode committed Aug 28, 2012
Showing with 13 additions and 15 deletions.
  1. +9 −4 entity.lua
  2. +1 −1 powerup.lua
  3. +3 −9 ship.lua
  4. +0 −1 space.lua
View
@@ -29,18 +29,23 @@ function _M.new(t)
e.name = t.name or string.format('entity#%d', count)
e.id = count
+
e.pos_x = t.pos_x or 0
e.pos_y = t.pos_y or 0
e.dir_x = t.dir_x or 0
e.dir_y = t.dir_y or 0
+ e.speed = t.speed or 0
- e.speed = t.speed or 0
- e.damage = t.damage or 0
- e.radius = t.radius or 0
-
-- Handles the texture, width, and height fields
_M.set_texture(e, t.texture or generic_icon)
+ e.state = t.state or 'alive'
+ e.shieldmax = t.shieldmax or 100
+ e.shield = t.shield or e.shieldmax
+ e.damage = t.damage or e.shieldmax *.3
+ e.radius = t.radius or e.height
+
+
count = count + 1
return setmetatable(e, _MT)
View
@@ -29,7 +29,7 @@ function _M.new(t)
p.effect = t.effect or 'heal10'
p.dir_x = -1
p.dir_y = 0
- p.speed = 50
+ p.speed = 64
_M.set_texture(p, icons[p.effect])
View
@@ -16,24 +16,18 @@ function ship.new(t)
local e = entity.new(t)
e.kind = 'ship'
-
e.name = t.name or string.format('ship#%d', e.id)
- e.shieldmax = t.shieldmax or 100
- e.shield = t.shield or e.shieldmax
- e.speed = t.speed or 100
- e.damage = t.damage or e.shieldmax *.3
- e.state = t.state or 'alive'
- e.radius = t.radius or e.height
+ e.speed = t.speed or 100
e.npc = t.npc == nil and true or t.npc
e.dir_timer = t.dir_timer or 0
-
e.entities = t.entities or {}
+ e.hit = false -- was hit by player?
+
e.shooting = false
e.shot_rate = t.shot_rate or 0.2 -- time between shots in seconds.
e.shot_timer = 0
- e.hit = false -- was hit by player?
return setmetatable(e, _MT)
end
View
@@ -190,7 +190,6 @@ function state:update(dt)
local enemies = self.enemies
for i=1,#enemies do
ship = enemies[i]
- assert(ship, "Woops, grabbed nothing.")
if ship then
ship:update(dt, level)
-- Ideally, the player would be a normal entity, for now we

0 comments on commit 805827c

Please sign in to comment.