Melee attackers for my top down code

displayMode(FULLSCREEN)

function setup()
    sx,sy=WIDTH/2,HEIGHT/2
    j,m={},{}
end

function draw()
    background(40, 40, 50)
    for a,b in pairs(j) do
        b:draw()
    end
    fill(255)
    for a,b in pairs(m) do
        ellipse(b.x,b.y,5)
        b.x=b.x+b.z
        b.y=b.y+b.w
        if b.x<0 or b.x>WIDTH or b.y<0 or b.y>HEIGHT then
            table.remove(m,a)
        end
    end
    sprite("Documents:ExampleCircle2",sx,sy,50)
end

function touched(t)
    if t.state==BEGAN then
        if t.x<WIDTH/2 then
            for a,b in pairs(j) do
                if b.type=="move" then
                    return  -- limit 1 move joystick
                end
            end
            table.insert(j,js(t.x,t.y,t.id,"move"))
        else
            table.insert(j,js(t.x,t.y,t.id,"shoot"))    -- allow multiple shoot
        end
    end
    for a,b in pairs(j) do
        b:touched(t)
    end
end

js=class()

function js:init(x,y,id,ty)
    self.id=id
    self.ox=x
    self.oy=y
    self.cx=x    
    self.cy=y
    self.dx=0
    self.dy=0
    self.type=ty
    self.c=20
end

function js:draw()
    stroke(255)
    strokeWidth(2)
    fill(255,255,255,100)
    ellipse(self.ox,self.oy,150)
    if self.type=="move" then
        sx=sx+(self.cx-self.ox)/10
        sy=sy+(self.cy-self.oy)/10
    end
    if self.type=="shoot" then
        v1=vec2(self.cx-self.ox,self.cy-self.oy)
        v1=v1:normalize()
        if math.abs(v1.x+v1.y)>0 then
            self.dx=v1.x*8
            self.dy=v1.y*8
            self.c=self.c+0.7
            if self.c>12 then
                table.insert(m,vec4(sx,sy,self.dx,self.dy)) 
                self.c=0
            end  
        end        
    end
end

function js:touched(t)
    for a,b in pairs(j) do
        if t.id==b.id then
            if t.state==MOVING then
                b.cx=t.x
                b.cy=t.y
            end
            if t.state==ENDED then
                table.remove(j,a)
            end
        end
    end    
end

I need help making melee attackers for this code?

The only soloution I would see is a button to the right.

I mean like, enemies

I don’t have any enemies in here yet, but you might want to check out the evolution of the Joystick project here:

This project should be ready to run now, downloading all images when you uncomment the indicated line in setup()

https://github.com/interactivenyc/CodeaJoystick/