Looking for starter's tips.

Hello my name is Kai! I am young programmer just starting out. My friend has learned a lot just off this forum and the wiki by trying new code, which I too am doing. I have made a few programs before and was to get more advanced. Below I will post my current project, wich instead of running off of points to have a collisions engine. Thank you for reading this and please post some tips for me in the comments section. :smiley:

--# Main
function setup()
    --This is were I select speed and y values, but because I am a stupid I need to make multiple Y ans Speed values.
    y = 100
    y1 = 100
    y2 = 100
    y3 = 100
    y4 = 100
    y5 = 100
    y5 = 100

    sped = 1
    sped1 = 2
    sped2 = 3
    sped3 = 4
    sped4 = 5

function draw()
    --This function here is for dev purposes, to keep track of all y values.
    print (y,y1,y2,y3,y4,y5)
    --Here I re-state the Y values and add speed to them so they can move.
    y = y+sped
    y1 = y1+sped1
    y2 = y2+sped2
    y3 = y3+sped3
    y4 = y4+sped4

    --Here I make the circles that bounce!
    --Down here is where things get tricky, I needed to make an "If Then" statement for each ball to ensure it won't leave the screen.
    if y >= 700 then sped = -sped end
    if y < 50 then sped = -sped end
    if y1 >= 700 then sped1 = -sped1 end
    if y1 < 50 then sped1 = -sped1 end
    if y2 == 700 then sped2 = -sped2 end
    if y2 < 50 then sped2 = -sped2 end  
    if y3 == 700 then sped3 = -sped3 end
    if y3 < 50 then sped3 = -sped3 end  
    if y4 == 700 then sped4 = -sped4 end
    if y4 < 50 then sped4 = -sped4 end  
    fill(255, 7, 0, 255)

Sorry I don’t know why this won’t post correctly.

@Kai - See what you can do with tables

function setup()
    posX={100,300,500,700,900}  --x positions of the 5 balls
    posY={100,100,100,100,100} --y positions
    speed={1,2,3,4,5}   --speeds

function draw()
    for i=1,#posY do  --loop through all the balls
        if posY[i]>700 or posY[i]<50 then speed[i]=-speed[i] end

I’ve written some ebooks here that may help


read the Lua book to learn about tables and loops (Lua is the language behind Codea).

Keep going, you’ve started well! =D>

@Ignatz Ok thank you. I have looked at tables in the past but I have yet to under stand them is you can begin messaging me to help me learn please,do

@Kai Please don’t post the same program to different discussions asking for the same help. That’s the quickest way not to get any help. @Ignatz, see the discussion


@Kai - I agree. DON’T post the same thing twice.

I have wasted my time and I am not happy. :-w

Ok sorry guys @dave1707 and @Ignatz