-- Code for bullets! import "CoreLibs/object" import "CoreLibs/graphics" import "CoreLibs/sprites" local gfx = playdate.graphics class("Bullet").extends(gfx.sprite) function Bullet:init(size, friendly) local img = gfx.image.new(size, size) gfx.pushContext(img) gfx.fillCircleInRect(0, 0, size, size) gfx.popContext() Bullet.super.init(self, img) self:setCollideRect(0, 0, self:getSize()) local friendly = friendly or true if friendly then self:setGroupMask(0x4) self:setCollidesWithGroupsMask(0x9) self.direction = 1 else self:setGroupMask(0x10) self:setCollidesWithGroupsMask(0x2) self.direction = -1 end end function Bullet:update() self:moveWithCollisions(self.x+self.direction, self.y) end