用mcgs怎么编程红绿灯循环的脚本程序

用mcgs怎么编程红绿灯循环的脚本程序,第1张

先把时间设定好,路上的车所行的距离,时念梁陆间跟你灯的时间匹配。渣好下面这个是四辆车过红绿灯的程序

if $Second<30 then

时间=$Second

ELSE

时间=$Second-30

ENDIF

if X<1200 then

x=x+50

else

x=0

endif

if 时间>=15 and 时间<=29 and X=500 THEN

X=X-50

ENDIF

if X1>-1200 then

x1=x1-25

else

x1=0

endif

if 时间仔顷>=15 and 时间<=29 and X1=-550 THEN

X1=X1+25

ENDIF

if Y<800 then

Y=Y+15

else

Y=0

endif

IF 时间<14 and 时间>=0 and Y=150 THEN

Y=Y-15

ENDIF

if Y1>-800 then

Y1=Y1-20

else

Y1=0

endif

IF 时间<14 and 时间>=0 and Y1=-260 THEN

Y1=Y1+20

ENDIF

Dim s As Integer

Dim n As Integer

'单击余森“红灯”按钮

Private Sub Command1_Click()

Shape6.Visible = True : Shape7.Visible = False : Shape8.Visible = False

End Sub

'单击“黄灯”按弊毁氏钮

Private Sub Command2_Click()

Shape6.Visible = False : Shape7.Visible = True : Shape8.Visible = False

End Sub

'单击“绿灯”按钮

Private Sub Command3_Click()

Shape6.Visible = False : Shape7.Visible = False : Shape8.Visible = True

End Sub

'单击“自动租散”按钮

Private Sub Command4_Click()

Timer1.Enabled = True

Command1.Enabled = False

Command2.Enabled = False

Command3.Enabled = False

n = 0 : s = 0

End Sub

'单击“手动”按钮

Private Sub Command5_Click()

Timer1.Enabled = False

Label1.Caption = ""

Shape6.Visible = False

Shape7.Visible = False

Shape8.Visible = False

Command1.Enabled = True

Command2.Enabled = True

Command3.Enabled = True

End Sub

'时钟控件启动

Private Sub Timer1_Timer()

Select Case n

Case 0

Shape6.Visible = True

Shape7.Visible = False

Shape8.Visible = False

Label1.Caption = 3 - s

s = s + 1

If s >3 Then

n = 1

s = 0

End If

Case 1

Shape6.Visible = False

Shape7.Visible = True

Shape8.Visible = False

n = 2

Case 2

Shape6.Visible = False

Shape7.Visible = False

Shape8.Visible = True

Label1.Caption = 3 - s

s = s + 1

If s >3 Then

n = 0 : s = 0

End If

End Select

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12563611.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存