2014-10-18 14:58:04 +00:00
|
|
|
Class = require 'hump.class'
|
|
|
|
require 'entities/physicsentity'
|
|
|
|
require 'settings'
|
|
|
|
|
2014-10-18 19:15:30 +00:00
|
|
|
local VICKERS_SOUND = love.audio.newSource("resources/audio/vickers77.mp3", "static")
|
2014-10-19 02:14:12 +00:00
|
|
|
local explosionFrames = AnimationFrames("resources/graphics/miniexplosion-%04d.png", 4, 15, false)
|
2014-10-18 16:46:00 +00:00
|
|
|
|
2014-10-18 14:58:04 +00:00
|
|
|
Vickers77 = Class{
|
|
|
|
__includes = Rectangle,
|
|
|
|
|
2014-10-21 05:52:45 +00:00
|
|
|
MAX_LIFETIME = 60 * 2,
|
2014-10-18 14:58:04 +00:00
|
|
|
img = nil,
|
|
|
|
frame = 0,
|
|
|
|
|
|
|
|
init = function(self, x, y, level)
|
2014-10-19 00:07:09 +00:00
|
|
|
local xsize = 1 * PIXELS_PER_METER
|
|
|
|
local ysize = 0.4 * PIXELS_PER_METER
|
2014-10-18 14:58:04 +00:00
|
|
|
|
2014-10-19 01:35:07 +00:00
|
|
|
self.collisionCategory = 3
|
|
|
|
Rectangle.init(self, x, y, level, "dynamic", 0.2, xsize, ysize, 1, nil)
|
2014-10-18 14:58:04 +00:00
|
|
|
self.body:setBullet(true)
|
2014-10-19 01:35:07 +00:00
|
|
|
self.collisionCategory = 3
|
|
|
|
self.fixture:setCategory(self.collisionCategory)
|
2014-10-18 16:46:00 +00:00
|
|
|
|
|
|
|
VICKERS_SOUND:rewind()
|
|
|
|
VICKERS_SOUND:play()
|
2014-10-18 14:58:04 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
update = function(self, dt)
|
|
|
|
Rectangle.update(self, dt)
|
|
|
|
|
|
|
|
self.frame = self.frame + 1
|
|
|
|
|
|
|
|
if self.frame >= self.MAX_LIFETIME then
|
|
|
|
self:delete()
|
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
2014-10-20 19:15:21 +00:00
|
|
|
wasHitBy = function(self, by)
|
2014-10-19 01:49:22 +00:00
|
|
|
Animation(self.body:getX(), self.body:getY(), self.level, explosionFrames)
|
|
|
|
end;
|
|
|
|
|
2014-10-18 14:58:04 +00:00
|
|
|
draw = function(self)
|
|
|
|
Rectangle.draw(self)
|
|
|
|
end;
|
|
|
|
}
|
|
|
|
|