Need help for spaceship movement

touch = touchingAtPos()
        if touch then
            if touch.x < (hero.position.x - 10) then
                hero.position.x = hero.position.x - 3
            elseif touch.x > (hero.position.x + 10) then
                hero.position.x = hero.position.x + 3
            if touch.y < (hero.position.y - 10) then
                hero.position.y = hero.position.y - 3
            elseif touch.y > (hero.position.y - 10) then
                hero.position.y = hero.position.y + 3

```


What else do I put on to make it work

Here is some code previously posted by @Xavier. Maybe this will give you some ideas. Just touch the screen anywhere.


function setup()
 speed = 5
 bullet = vec2(WIDTH, HEIGHT)
 target = vec2(0, 0)
 bulletImage = readImage("Tyrian Remastered:Button Glow")
 targetImage = readImage("Tyrian Remastered:Eye Mecha")
end

function draw()
 background(0)
 target.x = CurrentTouch.x
 target.y = CurrentTouch.y

 local dir = math.atan2(target.y - bullet.y, target.x - bullet.x)
 bullet.x = bullet.x + math.cos(dir)*speed
 bullet.y = bullet.y + math.sin(dir)*speed

 sprite(bulletImage, bullet.x, bullet.y)
 sprite(targetImage, target.x, target.y)
end

Thanks

Wait where do I put this

I’m a newb

.@Mnjk78lg - have a look at this tutorial (http://codeatuts.blogspot.com.au/2012/07/interlude-9-control-object-movement.html) it should show you how this can be implemented.