小基础中的两个语句不能一起工作



对于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

我注意到的第一件事是你正在使用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

相关内容

  • 没有找到相关文章

最新更新