if Math.GetRandomNumber(2)=1 Then
Shapes.Move(shape,800,400)
Else
Shapes.Move(shape,700,400)
EndIf
Or:
rand=Math.GetRandomNumber(2)
Shapes.Move(shape,600+100*rand,400)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to make a program in small basic who has a shape . I want that shape randomly
move to "800,400" or "700,400 " . It means a shape move "800,400" or "700,400" randomly. help please !
if Math.GetRandomNumber(2)=1 Then
Shapes.Move(shape,800,400)
Else
Shapes.Move(shape,700,400)
EndIf
Or:
rand=Math.GetRandomNumber(2)
Shapes.Move(shape,600+100*rand,400)
Here's another way of doing it using a timer that is set at random timer.intervals.
GraphicsWindow.height=600
GraphicsWindow.width=1000
MyShape=Shapes.AddRectangle(100,100)
Timer.Tick=OnTimerTick
Timer.Interval=1000
Tick="False"
Shapes.Move(MyShape,800,400)
While "True"
If Tick = "True" and Shapes.GetLeft(MyShape)=800 then
Shapes.Move(MyShape,700,400)
Tick="False"
ElseIf Tick="True" and Shapes.GetLeft(MyShape)=700 then
Shapes.Move(MyShape,800,400)
Tick="False"
EndIf
Timer.Interval= Math.GetRandomNumber(1000)
Program.Delay(50)
EndWhile
Sub OnTimerTick
Tick="True"
EndSub
JR