I’m having a problem getting text to display in a while loop. In the example below, the text in the while loop doesn’t display. If the repeat loop is uncommented, the text does display. What am I not understanding about while. Thanks.
-- Loops
-- Use this function to perform your initial setup
function setup()
Index2 = 1
Index3 = 1
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
fill(191, 186, 49, 255)
for Index = 1,10 do
text ( "For: " .. Index, WIDTH * .25, HEIGHT/20 * Index )
end
while Index2 <= 10 do
text ( "While: " .. Index2, WIDTH * .5, HEIGHT/20 * Index2 )
Index2 = Index2 + 1
end
--[[
repeat
text ( "Repeat: " .. Index3, WIDTH * .75, HEIGHT/20 * Index3 )
Index3 = Index3 + 1
until Index3 == 11
--]]
end