Open
Description
When attempting to complete the WoofJS tutorial for Wordle, I ran into an issue with nesting repeat loops.
It appears that nesting repeat loops does not create the grid of squares needed for the application.
var offset_x = 0
var offset_y = 0
repeat(6, () => {
repeat(5, () => {
var rect = new Rectangle()
rect.x = -150
rect.y = 250
rect.width = 75
rect.height = 75
rect.x = -150 + (offset_x * 85)
rect.y = 250 - (offset_y * 85)
offset_x += 1
})
offset_x = 0
offset_y += 1
})
The code above produces a shape like the below
What is equally confusing is that using range().forEach loops works as expected.
var offset_x = 0
var offset_y = 0
range(0, 6).forEach(counter => {
range(0, 5).forEach(counter => {
var rect = new Rectangle()
rect.x = -150
rect.y = 250
rect.width = 75
rect.height = 75
rect.x = -150 + (offset_x * 85)
rect.y = 250 - (offset_y * 85)
offset_x += 1
})
offset_x = 0
offset_y += 1
})
The code above produces a proper 5x6 grid like the below
I've had a few pairs of eyes look over this situation, and the best I can gather is that the slowed down nature of the repeat loop is causing this issue somehow. If the range().forEach loops work as expected, then I can only assume so.
Metadata
Metadata
Assignees
Labels
No labels