# Shapes - Whats going on?

• ### Question

• GraphicsWindow.Height = 600
GraphicsWindow.Width = 800

For i = 1 To 25
Shapes.Move(i, Maths.GetRandomNumber(800), Maths.GetRandomNumber(600))
EndFor

This is not what I expected this code to do, I expected 25 rects what have I done wrong?

EDITED: Although looks cool :D. Also please don't mention my screen size :D.

Thanks,
Kirk.

Thursday, February 10, 2011 1:51 AM

• Yes, the value of the for loop does increase every loop. You write arrays in smallbasic using the Arrays class, or brackets:

For i = 1 To 25
value[i]=i'the the array index's value
EndFor
TextWindow.WriteLine(value) 'writes the value of the whole array
For i = 1 To Array.GetItemCount(value)
TextWindow.WriteLine(value[i]_
EndFor
~~AirWaves!!~~
• Marked as answer by Friday, February 11, 2011 12:44 AM
Thursday, February 10, 2011 4:56 AM

### All replies

• This is all crazy because you are setting the value of i to a shape. This will always be 0 in the for loop. Use this code:

GraphicsWindow.Height = 600
GraphicsWindow.Width = 800

For i = 1 To 25
Shapes.Move(r, Maths.GetRandomNumber(800), Maths.GetRandomNumber(600))
EndFor

~~AirWaves!!~~
Thursday, February 10, 2011 2:06 AM
• hmmm yeah I never thought about that, integar's can't be "handles" for shapes. What I am look at doing is have this for loop to create the shapes then I want to create another for loop to iterate (think thats the correct word) through the shapes and get for some kind of collision for another shape.

How can I iterate through the shapes created? If an array is needed could you show me a quick example of how arrays are written in Smallbasic as I have never used one.

EDITED: I would of throught the FOR loop would of ended though as i variable is still increasing right?

Thanks.

Thursday, February 10, 2011 2:12 AM
• Yes, the value of the for loop does increase every loop. You write arrays in smallbasic using the Arrays class, or brackets:

For i = 1 To 25
value[i]=i'the the array index's value
EndFor
TextWindow.WriteLine(value) 'writes the value of the whole array
For i = 1 To Array.GetItemCount(value)
TextWindow.WriteLine(value[i]_
EndFor
~~AirWaves!!~~
• Marked as answer by Friday, February 11, 2011 12:44 AM
Thursday, February 10, 2011 4:56 AM