I’ve just downloading Codea, and don’t know anything about vectors, can anyone help, i have to make the bullet to fly directly on target
function setup()
displayMode(FULLSCREEN)
t = Target()
bullet = Bullet()
end
function draw()
background(40, 40, 50)
strokeWidth(5)
bullet.draw()
-- bullet.mov()
t.draw()
if dx < a then
dx = dx + 1
end
if dy< b then
dy = dy + 1
end
if dx > a then
dx = dx - 1
end
if dy > b then
dy = dy - 1
end
end
Bullet = class()
function Bullet:init(x)
dx = 0
dy = 0
end
function Bullet:draw()
ellipse(dx,dy, 15,15)
fill(255,0,0)
end
Target = class()
function Target:init(x)
a = WIDTH/2
b = HEIGHT/2
end
function Target:draw()
smooth()
noStroke()
ellipse(a,b, 50,50)
fill(255,255,255)
a = CurrentTouch.x
b = CurrentTouch.y
end