Resolved

Bug resolved

@Invad3rZIM I didn’t try to debug your code, but here’s a stripped down version of something that I had. Maybe this will help with moving the 2 pucks. Hopefully i didn’t take too much out. If this doesn’t help, let me know and I’ll debug your code when I have some time.


displayMode(FULLSCREEN)

function setup()
    dx1,dy1,dx2,dy2=0,0,0,0
    physics.continuous=true
    
    e1=physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT))
    e2=physics.body(EDGE,vec2(0,HEIGHT),vec2(WIDTH,HEIGHT))
    e3=physics.body(EDGE,vec2(WIDTH,HEIGHT),vec2(WIDTH,0))
    e4=physics.body(EDGE,vec2(WIDTH,0),vec2(0,0))
    
    b=physics.body(CIRCLE,20)    
    b.x=WIDTH/2
    b.y=HEIGHT/2
    b.gravityScale=0
    b.friction=0
    b.restitution=1
    
    p1=physics.body(CIRCLE,40)
    p1.x=50
    p1.y=HEIGHT/2
    p1.gravityScale=0
    
    p2=physics.body(CIRCLE,40)
    p2.x=WIDTH-50
    p2.y=HEIGHT/2
    p2.gravityScale=0
end

function draw()
    background(40, 40, 50)
    
    fill(255)
    ellipse(b.x,b.y,40)
    
    noFill()
    stroke(255)
    strokeWidth(6)
    ellipse(p1.x,p1.y,80)
    ellipse(p2.x,p2.y,80)
    
    strokeWidth(2)
    line(0,0,0,HEIGHT)
    line(0,HEIGHT,WIDTH,HEIGHT)
    line(WIDTH,HEIGHT,WIDTH,0)
    line(WIDTH,0,0,0)
    line(WIDTH/2,0,WIDTH/2,HEIGHT)
    
    p1.linearVelocity=vec2(dx1,dy1)
    p2.linearVelocity=vec2(dx2,dy2)
end

function touched(t)
    if t.state==BEGAN then
        if t.x<WIDTH/2 then
            p1id=t.id
        else
            p2id=t.id
        end
    end
    if t.state==MOVING then
        if p1id==t.id then
            if t.x<WIDTH/2-40 then
                dx1=(t.x-p1.x)*20
                dy1=(t.y-p1.y)*20
            else
                dx1,dy1=0,0
            end
        end
        if p2id==t.id then
            if t.x>WIDTH/2+40 then
                dx2=(t.x-p2.x)*20
                dy2=(t.y-p2.y)*20
            else
                dx2,dy2=0,0
            end
        end
    end
    if t.state==ENDED then
        if p1id==t.id then
            p1id,dx1,dy1=0,0,0
        end
        if p2id==t.id then
            p2id,dx2,dy2=0,0,0
        end
    end
end

I just rewrote the code, cut all my touch functions and started over in that half if the project. It works now ^.^

Also where do I go when I have a bug? Is that the bug forums or code sharing or questions? And when it’s resolved is there any way to delete my post? I just changed the title here but what should I do normally

@Invad3rZIM That’s one way to learn, debugging your own code when you have a problem It’s always a good feeling when you get it figured out.

@Invad3rZIM Probably the best way is to just add (RESOLVED) to the end of the discussion name and leave everything else as is. That way the discussion still makes sense when someone else looks at it.

Alright will do ^.^ can you take look at my physics chain question please? It’s a conceptual thing I’m curious about and not really sure where to start aha

@invad3rZIM you can always ask help to debug your code. But i dont think you should change the title and remove the code once it is fixed. Because the thread is then no use for anyone :-S

Alright my mistake jmv…I just feel like I’m spamming when I have 6 topics I made in the last 3 days…trying not to spam but I’m not quite sure what I should do when they’re independent
, unrelated questions from eachother…but I won’t change it next time I’ll just annex (RESOLVED)

@Invad3rZIM It really doesn’t matter how many questions you ask or how many discussions you create, just as long as you keep everything in the proper discussion. Don’t start several discussion just to ask questions that can be kept in an existing discussion.

Alright. Understood :slight_smile: