0

IT の課題では、小さな基本を使用して家を作成する必要があり、より高いレベルに到達するには、窓の色を変更するように指示されます。私はこれをしました。移動する雲も追加して、より高いレベルを達成しようとしましたが、2 つの異なるステートメントが連携していません。

私のコードは以下の通りです:

'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
4

1 に答える 1

1

私が最初に気付いたのはShapes.GetLeft、アニメーション形状の位置を取得するために使用していることです。アニメーション化された形状は、移動中であっても常に位置としてエンドポイントを返すため、これは機能しません。

2番目のことはこれです:

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
于 2014-12-18T17:47:28.900 に答える