Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Can i have some help?

** So, i would like my code to have the clouds generated randomly on screen 4 :( but i messed it up and it went all wierd. here is my code:**

--[[ Screens:
1: Menu
2: Credits
3: Stats
4: Loading
--]]
function setup()
    displayMode(FULLSCREEN)

-- screens
    screen = 4
    cloudx = 1

    -- timer for the loading bar

   ltimer = 0
    loadingbackground =  color(0, 236, 255, 255) 
end

-- This function gets called once every frame (Yes, we know)
function draw()
    cloudx = cloudx + 1
    -- Start the loading timer
    ltimer = ltimer + 1 * DeltaTime


if ltimer > 5 then
    screen = 1
    end

    -- Draw Screens
 if screen == 4 then
        background(loadingbackground)
        for i = 1,100 do
            sprite("Platformer Art:Block Grass",i * 100,0,100)
        end

        for i = 1,100 do
            sprite("Platformer Art:Block Grass",i * 50,0,100)
        end
for i = 1,100 do
            sprite("Platformer Art:Cloud 1",i * cloudx,500,300)
        end



font("Futura-CondensedExtraBold")
fill(0, 0, 0, 255)
fontSize(120)
textWrapWidth(700000)
text("Crafty World", WIDTH/2, HEIGHT/1.5)

    end


end

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 7,523

    Try this. I created a cloud table to hold random position and sizes.

    --[[ Screens:
    1: Menu
    2: Credits
    3: Stats
    4: Loading
    --]]
    function setup()
        cloudTab={}
        for z=1,40 do
            table.insert(cloudTab,
                vec3(math.random(WIDTH+300),math.random(200,HEIGHT),math.random(30,120)))
        end
        displayMode(FULLSCREEN)
        -- screens
        screen = 4
        cloudx = 1
        -- timer for the loading bar
        ltimer = 0
        loadingbackground =  color(0, 236, 255, 255) 
    end
    
    -- This function gets called once every frame (Yes, we know)
    function draw()
        cloudx = cloudx + 1
        -- Start the loading timer
        ltimer = ltimer + 1 * DeltaTime
        if ltimer > 5 then
            screen = 1
        end
        -- Draw Screens
        if screen == 4 then
            background(loadingbackground)
            for i = 1,100 do
                sprite("Platformer Art:Block Grass",i * 100,0,100)
            end
    
            for i = 1,100 do
                sprite("Platformer Art:Block Grass",i * 50,0,100)
            end
            for a,b in pairs(cloudTab) do
                sprite("Platformer Art:Cloud 1",b.x,b.y,b.z)
            end
    
            font("Futura-CondensedExtraBold")
            fill(0, 0, 0, 255)
            fontSize(120)
            textWrapWidth(700000)
            text("Crafty World", WIDTH/2, HEIGHT/1.5)
        end
    end
    
  • Posts: 6

    wow! thankyou! :wink: im sorta a codea noob xD the best thing i know is how to do for i = 1,000 do xD thanks again :)

Sign In or Register to comment.