对于IT中的任务,我们必须使用小型基础创建房屋,以获得更高级别,我们被告知使窗户的颜色改变颜色。我做到了这一点;我也试图通过添加移动云来达到更高的水平,这两个不同的陈述并没有合作。
我的代码如下:
'background
GraphicsWindow.Title= "My House Assessment"
GraphicsWindow.Height= "600"
GraphicsWindow.Width= "1000"
GraphicsWindow.BackgroundColor="#198cFF"
'grass
GraphicsWindow.PenColor= "#2bf90b"
GraphicsWindow.BrushColor= "#2bf90b"
GraphicsWindow.PenColor= "#0000000"
GraphicsWindow.DrawRectangle(0,400,1000,500)
GraphicsWindow.FillRectangle(0,400,1000,500)
'path
GraphicsWindow.BrushColor= "#34000d
GraphicsWindow.PenColor= "#34000d"
GraphicsWindow.DrawTriangle(700,600,300,300,0,1000)
GraphicsWindow.FillTriangle(700,600,300,300,0,1000)
'top floor
GraphicsWindow.BrushColor="#173cf0"
GraphicsWindow.DrawRectangle(100,100,750,200)
GraphicsWindow.FillRectangle(100,100,750,200)
'ground floor
GraphicsWindow.BrushColor="#ffffcc"
GraphicsWindow.DrawRectangle(100,300,750,200)
GraphicsWindow.FillRectangle(100,300,750,200)
'roof
GraphicsWindow.BrushColor="#808080"
GraphicsWindow.DrawTriangle(100,100,425,10,850,100)
GraphicsWindow.FillTriangle(100,100,425,10,850,100)
'door
GraphicsWindow.BrushColor="#000000"
GraphicsWindow.PenColor="#000000"
GraphicsWindow.DrawRectangle(400,350,100,150)
GraphicsWindow.FillRectangle(400,350,100,150)
''number on door
GraphicsWindow.BrushColor="#FFFFFF"
GraphicsWindow.DrawText(450,400,"45")
'doorknob
GraphicsWindow.BrushColor="#FFFFFF"
GraphicsWindow.DrawEllipse(475,420,10,10)
GraphicsWindow.FillEllipse(475,420,10,10)
'windows on floor one
For i= 1 To 5000000
GraphicsWindow.BrushColor= GraphicsWindow.GetRandomColor()
GraphicsWindow.DrawEllipse (200,120,150,150)
GraphicsWindow.FillEllipse(200,120,150,150)
GraphicsWindow.DrawEllipse (600,120,150,150)
GraphicsWindow.FillEllipse(600,120,150,150)
timer.Interval=1000
EndFor
'clouds
Sball = Shapes.AddEllipse(100, 100)
Sball2 = Shapes.AddEllipse(100,100)
Sball3 = Shapes.AddEllipse(100,100)
start:
Shapes.Move(Sball,400,50)
Shapes.Move(Sball2,450,50)
Shapes.Move(Sball3,500,50)
x = 200
Shapes.Animate(Sball,800,50,x)
Shapes.Animate(Sball2,850,50,x)
Shapes.Animate(Sball3,900,50,x)
Program.Delay(500)
If (Shapes.GetLeft(Sball) = x) Then
Shapes.Animate(Sball, 0, 340, 500)
EndIf
If (Shapes.GetLeft(Sball2) = x)Then
Shapes.Animate(Sball, 0, 340, 500)
EndIf
Shapes.Move(Sball,800,50)
Shapes.Move(Sball2,850,50)
Shapes.Move(Sball3,900,50)
x = 200
Shapes.Animate(Sball,400,50,x)
Shapes.Animate(Sball2,450,50,x)
Shapes.Animate(Sball3,500,50,x)
Program.Delay(500)
If (Shapes.GetLeft(Sball) = x) Then
Shapes.Animate(Sball, 0, 340, 500)
EndIf
If (Shapes.GetLeft(Sball2) = x)Then
Shapes.Animate(Sball, 0, 340, 500)
EndIf
If (Shapes.GetLeft(Sball3) = x)Then
Shapes.Animate(Sball, 0, 340, 500)
EndIf
Goto start
答案 0 :(得分:1)
我注意到的第一件事是你使用Shapes.GetLeft
来获取动画形状的位置。这不起作用,因为动画形状将始终将端点作为其位置返回,即使它们正在移动。
第二件事是:
For i= 1 To 5000000
GraphicsWindow.BrushColor= GraphicsWindow.GetRandomColor()
GraphicsWindow.DrawEllipse (200,120,150,150)
GraphicsWindow.FillEllipse(200,120,150,150)
GraphicsWindow.DrawEllipse (600,120,150,150)
GraphicsWindow.FillEllipse(600,120,150,150)
timer.Interval=1000
EndFor
这不起作用,因为timer.Interval=1000
不是延迟。它设置调用计时器事件之间的间隔(你不是在这里使用它)。你想要的是Program.Delay(1000)
。
此外,For
声明不是要走的路。使用一段时间:D。一旦你进入for循环,程序就不能通过它直到它完成。所以这就是为什么程序的其余部分都无法正常工作。
试试这个程序:
GraphicsWindow.BrushColor="#000000"
GraphicsWindow.PenColor="#000000"
GraphicsWindow.DrawRectangle(400,350,100,150)
GraphicsWindow.FillRectangle(400,350,100,150)
''number on door
GraphicsWindow.BrushColor="#FFFFFF"
GraphicsWindow.DrawText(450,400,"45")
'doorknob
GraphicsWindow.BrushColor="#FFFFFF"
GraphicsWindow.DrawEllipse(475,420,10,10)
GraphicsWindow.FillEllipse(475,420,10,10)
Cloud1 = Shapes.AddEllipse(30,30)
Cloud2 = Shapes.AddEllipse(30,30)
Cloud3 = Shapes.AddEllipse(30,30)
xpos = 100
'windows on floor one
While 1 = 1 'This will repeat while the statement is true (1 always = 1)
GraphicsWindow.BrushColor= GraphicsWindow.GetRandomColor()
GraphicsWindow.DrawEllipse (200,120,150,150)
GraphicsWindow.FillEllipse(200,120,150,150)
GraphicsWindow.DrawEllipse (600,120,150,150)
GraphicsWindow.FillEllipse(600,120,150,150)
'Clouds
xpos = - xpos
Shapes.Animate(Cloud1,xpos+300,100,1000)
Shapes.Animate(Cloud2,-xpos+300,150,1000)
Shapes.Animate(Cloud3,xpos+400,100,1000)
Program.Delay(1000)
EndWhile