Can you use a whileTrue: inside a block closure? I can't get it to work so I suspect not. Or I am doing something wrong.
map := #([1 1 1 1 1]
[1 0 0 0 1]
[1 0 1 0 1]
[1 0 0 0 1]
[1 1 1 1 1]).
posx := 1.
posy := 1.
t4 := CompositePart new.
rot := (Core.Double.Pi / 4).
perspective := Core.OrderedCollection new.
1 to: 60 do: [:i | perspective add: (rot + (i - 30) asRAD).
rot_i := perspective at: i.
x := posx.
y := posy.
gsin := (0.2 * (rot_i sin)).
gcos := (0.2 * (rot_i cos)).
t2 := true.
[t2 = true]
whileTrue: [
x := (x + gcos).
y := (y + gsin).
n := (n + 1).
mapCoord := map at: x rounded asInteger.
mapCoord := (mapCoord at: y rounded asInteger).
(mapCoord = 1)
ifTrue: [
h := 1/(0.2 * n).
t2 := false]].
t3 := (i @ h extent: 2 @ h ) asFiller.
t4 add: t3].
I would like to get everything inside the whileTrue block to repeat if mapCoord isn't equal to 1. But it doesnt, it just chugs along to the next iteration in the "do:" block. I suspect Im doing something wrong, but I can't figure it out.
This is what I see.
At every
do:iteration, bothxandyare initialized to1and then, inside thewhileTrue:, to something between0.8and1.2. Thus, the first assignment ofmapCoordevaluates to#[1 1 1 1 1]and the second to1because#[1 1 1 1 1] at: 1is1. Thus,t2becomesfalseand thewhileTrue:exits.More clearly