Well, I'm currently 18 years old and am in my third quarter of my game design degree. I plan on specializing in game programming/game engine programming.
I have not used math at all for about 6-8 months, so I am kind of rusty so bear with me. I want to "shoot" a sprite at the mouse and I cannot for the life of me tell if it is working or not because it is going so freakin' fast! So, how do I slow down this and is this equation even correct to shoot a sprite at the mouse? The sprite should not follow the mouse, but shoot past it.
Code: Select all
function draw() mouseY = love.mouse.getY() mouseX = love.mouse.getX() xDis = x - mouseX yDis = y - mouseY -- Subtract 90 because of odd default sprite angle starting at 0. rot = math.atan2(yDis, xDis) * (180 / math.pi) - 90 if shootBullet == true then love.graphics.draw(bullet, posX, posY, rot) posX = posX - (mouseX - math.cos(rot)) posY = posY - (mouseY - math.sin(rot)) end end
Keep up the good work! I plan on pumping out a few games with LOVE!