Line Syntax?

I have been trying to figure out why it does’nt draw a line where the “object” is located. I dont fully understand everything here like the vectors and pushing and poping so if someone could explain, that would be awesome.
Thanks in advance.

function setup()
    linex1 = 30
    liney1 = 30
    linex2 = 100
    liney2 = 30
    object = physics.body(EDGE,vec2(linex1,liney1),vec2(linex2,liney2))
    fw = physics.body(EDGE,vec2(0,0),vec2(WIDTH,0))
    rw = physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT))
    lw = physics.body(EDGE,vec2(0,HEIGHT),vec2(WIDTH,HEIGHT))
    lw = physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT))
    ball_d = 50
    p_ball = physics.body(CIRCLE,ball_d)
    p_ball.x = (math.random(200,600))
    p_ball.y = (math.random(200,600))
    p_ball.gravityScale = 1
    p_ball.restitution = .8
    p_ball.friction = 1
    p_ball.linearVelocity = vec2(math.random(400),math.random(400))
    p_ball.linearVelocity=vec2(math.random(400),math.random(400))
end

    function draw()
    background(0, 0, 0, 255)
    line( linex1, liney1, linex2, liney2 )
    pushStyle()
    fill(255, 17, 0, 255)
    ellipse(p_ball.x,p_ball.y,ball_d)
    popStyle()
    
    end

add strokeWidth(5) to see the line. Is that what your looking for?

Yeah, it doesn’t have any stroke width, and since lines are just strokes, it doesn’t draw anything.

Also, pushing and popping styles and matrices are pretty simple. Image there’s a virtual stack of styles and matrices that you’ve used. Then, say, you want to draw a line a different color than what it’s currently set to. There, you can call pushStyle() to make a copy of your current style configuration, put it on the top of the virtual stack, and then you can modify the color by calling stroke(). When you’re done, maybe you wanted to use the previous color for line strokes. Since you took a copy of the style configuration before you modified it, you can call popStyle() to take the configuration at the top off the virtual stack off and use it again.

Makes more sense now

I dont know what sytles or matrices are.

Alse, how come the ball wont touch the line or edge of the screen? It will come close, but never reach it.

Try using

p_ball = physics.body(CIRCLE, ball_d / 2)

And styles are basically the color you have fill set to, stroke, tint, and line widths. Matrices are used for 3-D, like the current transform (3-D offset) and the scale of 3-D models.

That did the trick. Do you know how to turn a velocity to 0? Aka make it stop moving.

I think you need to read about a lot of things. I have a bunch of tutorials here

http://coolcodea.wordpress.com/

And Reefwing also has a lot, if you look on the wiki for the link. All of these should help you understand the basics of Codea

:(. Thank you

don’t be put off by all the things you don’t know. I knew nothing a few months ago. It just takes a little time. :)>-

Agreed

That old lady anlagoy really helps with tables

thanks!