Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: theron on November 27, 2011

Title: Lame problem with simple loop
Post by: theron on November 27, 2011
Why loop in line 26 does not work, and the program did not draw another flower?
Code: [Select]
screenres 320,240
draw "bm 160,120"
draw "c50"
draw "U50,R10,D50,L10"
draw "TA45"
draw "U50,R10,D50,L10"
draw "TA90"
draw "U50,R10,D50,L10"
draw "TA135"
draw "U50,R10,D50,L10"
draw "TA180"
draw "U50,R10,D50,L10"
draw "ta225"
draw "U50,R10,D50,L10"
draw "ta270"
draw "U50,R10,D50,L10"
draw "ta315"
draw "U50,R10,D50,L10"
sleep 500
cls
draw "bm 160,120"
draw "ta0"
draw "c100"
draw "U50,R10,D50,L10"
dim x as integer
for x=0 to 315 step 45
draw"TA x"
draw "U50,R10,D50,L10"
next x
sleep
Title: Re: Lame problem with simple loop
Post by: Rbz on November 27, 2011
To work with draw command, you need to convert "x" variable into string.
Quote
TAn  =  Rotate n degrees (n ranges 0-359)

So change this line:
Code: [Select]
draw"TA x"to
Code: [Select]
draw"TA"+str(x)
Title: Re: Lame problem with simple loop
Post by: theron on November 27, 2011
Thanks for your help. I'll try your advice.
Title: Re: Lame problem with simple loop
Post by: theron on November 27, 2011
It works! Cool man!