Hi I am new to quite new to programming and wanted to make a little metroidvainia with the Tutorial from squidGod(https://www.youtube.com/watch?v=7GbUxjE9rRM&t=3124s) as an foundation.
But.. when I tried to add shooting mechanics I wasn`t able to invert the
circular bullets, so they could show up on the Black screen.
Could anyone please tell me what I did wrong and give me an solution?
Thanks in advance.
Here is the code:
local pd <const> = playdate
local gfx <const> = pd.graphics
class('Bullet').extends(gfx.sprite)
function Bullet:init(x, y, speed)
local original_draw_mode = gfx.getImageDrawMode()
gfx.setImageDrawMode( playdate.graphics.kDrawModeNXOR )
local bulletSize = 4
local bulletImage = gfx.image.new(bulletSize * 2, bulletSize * 2)
gfx.pushContext(bulletImage)
gfx.fillCircleAtPoint(bulletSize, bulletSize, bulletSize)
--gfx.drawCircleAtPoint(bulletSize, bulletSize, bulletSize)
gfx.popContext()
self:setImage(bulletImage)
self:setZIndex(Z_INDEXES.Projectile)
self:setTag(TAGS.Projectile)
self:setCollideRect(0, 0, self:getSize())
self.speed = speed
self:moveTo(x, y)
self:add()
gfx.setImageDrawMode( original_draw_mode )
end
function Bullet:update()
self.removeOnCollision = true
self:moveWithCollisions(self.x + self.speed, self.y)
end