Desafío Física: Editado por litdevMicrosoft Community Contributor, Moderador
http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/7239821c-161c-4328-b29d-7c55e40b11b9
Escriba un programa para controlar un semáforo en un cruce donde los coches llegan de diferentes direcciones a diferentes velocidades. Si quieres un reto aún más luego añadir unas cruces de la red de carreteras y controlar todas las luces. Las luces se pueden detectar cuando una cola se está acumulando.
Un reto difícil para algunos de ustedes puede que deseen trabajar juntos en esto.
Programa Listing TRK448-1 Editado por NaochanON
- ‘ Challenge of the month April 2013 … Physics Challenge // Trafic …. by NaochanON
- ‘ TRK448-1
- Shapes_Init()
- GUI()
- shapecars()
- While “true”
- L_Cars_Moving()
- R_Cars_Moving()
- Up_Cars_Moving()
- Down_Cars_Moving()
- RemainTime()
- Program.Delay(50)
- endwhile
- Sub X_AvoidCollision
- For LL=(DN+2) To (DN+cars+1)
- If LL<>L Then
- If Math.abs(Shapes.GetLeft(SHP[LL][1]["obj"])-Shapes.GetLeft(SHP[L][1]["obj"]))<160*s Then ‘ next car
- Vx[LL]=Vx[L] ‘ same speed // avoid collision
- EndIf
- EndIf
- EndFor
- EndSub
- Sub Y_AvoidCollision
- For LL=(2*cars+2+DN) To (3*cars+1+DN)
- If LL<>L Then
- If Math.abs( Shapes.Gettop(SHP[LL][1]["obj"]) – Shapes.Gettop(SHP[L][1]["obj"]) )<140*s Then ‘ next car
- Vy[LL]=Vy[L] ‘ same speed // avoid collision
- EndIf
- EndIf
- EndFor
- EndSub
- Sub RNDXSpeed
- Vx[L]= Vx[L-1]+Math.GetRandomNumber(10)/10
- Vx[DN+2]=4.5
- EndSub
- Sub RNDYSpeed
- Vy[L]= Vy[L-1]+Math.GetRandomNumber(10)/10
- Vy[DN+2*cars+2]=3.5
- EndSub
- Sub L_Cars_Moving
- DN=0
- For L=2 To (cars+1)
- Xpos[L]=Shapes.GetLeft(SHP[L][1]["obj"])
- ‘——————————————— Restart ———————————————————————————————–
- If LRNotice=”OK” And -2000<Xpos[L] and Vx[L]<0.35 then ‘ if signal becomes “Blue”
- RNDXSpeed() ’ new speed
- EndIf
- ‘——————————————— Yellow Signal ——————————————————————————————-
- If LRNotice=”Notice” And RemTime<=24 and 625<Xpos[L] and Xpos[L]<675 then ‘// Notice Area
- Vx[L]=Vx[L]*0.5 ‘ speed down
- elseIf LRNotice=”Notice” And 550<Xpos[L] and Xpos[L]<625 then ’ Signal = “Yellow”
- Vx[L]=Vx[L]+0.75 ‘ speed down
- EndIf
- ‘——————————————— Red Signal ——————————————————————————————-
- If LRNotice=”NG” And 625<Xpos[L] and Xpos[L]<675 then ‘ Signal = “Red”
- Vx[L]=0 ‘ speed down
- EndIf
- ‘——————————————— car move // avoid collision ———————————————————————–
- For i=start To end
- Shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"])-Vx[L],Shapes.GetTop(SHP[L][i]["obj"]))
- EndFor
- X_AvoidCollision() ‘ speed control
- ‘———————————————– go over left next position ————————————————————————-
- If Xpos[L]<-(300+135*L) Then
- RNDX=1300 -Xpos[L]+ 135*L*2
- For i=start To end
- shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"])+Rndx,Shapes.GetTop(SHP[L][i]["obj"]))
- endfor
- RNDXSpeed()
- endif
- EndFor
- EndSub
- Sub R_Cars_Moving
- DN=cars
- For L=(cars+2) To (2*cars+1)
- Xpos[L]=Shapes.GetLeft(SHP[L][1]["obj"])
- ‘——————————————— Restart ———————————————————————————————–
- If LRNotice=”OK” And -2000<Xpos[L] and Vx[L]<0.35 then ‘ if signal becomes “Blue”
- RNDXSpeed() ‘ new speed
- EndIf
- ‘——————————————— Yellow Signal ——————————————————————————————-
- If LRNotice=”Notice” And RemTime<=24 and 370<Xpos[L] and Xpos[L]<400 then ‘ Notice area
- Vx[L]=Vx[L]*0.5 ’ speed down
- elseIf LRNotice=”Notice” And 345<Xpos[L] and Xpos[L]<420 then
- Vx[L]=Vx[L]+0.75 ‘ speed down
- EndIf
- ‘——————————————— Red Signal ——————————————————————————————-
- If LRNotice=”NG” And 365<Xpos[L] and Xpos[L]<390 then ‘ Signal = “Red”
- Vx[L]=0 ‘ speed down
- EndIf
- ‘——————————————— car move // avoid collision ———————————————————————–
- For i=start To end
- Shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"])+Vx[L],Shapes.GetTop(SHP[L][i]["obj"]))
- EndFor
- X_AvoidCollision() ‘ speed control
- ‘———————————————– go over left next position ————————————————————————-
- If 1000+135*L<Xpos[L] Then
- RNDX=-(Xpos[L]+ 135*L*2)
- For i=start To end
- shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"])+Rndx,Shapes.GetTop(SHP[L][i]["obj"]))
- endfor
- RNDXSpeed()
- endif
- EndFor
- EndSub
- Sub Up_Cars_Moving
- DN=0
- For L=(2*cars+2) To (3*cars+1)
- Ypos[L]=Shapes.Gettop(SHP[L][1]["obj"])
- ‘——————————————— Restart ———————————————————————————————–
- If UDNotice=”OK” And -2000<Ypos[L] and Vy[L]<0.35 then ‘ if signal becomes “Blue”
- RNDYSpeed() ‘ new speed
- EndIf
- ‘——————————————— Yellow Signal ——————————————————————————————-
- If UDNotice=”Notice” And RemTime<=3 and 425<Ypos[L] and Ypos[L]<450 then ‘ Notice Area
- Vy[L]=Vy[L]*0.75 ‘ speed down
- elseIf UDNotice=”Notice” And 350<Ypos[L] and Ypos[L]<440 then ‘ Signal = “Yellow”
- Vy[L]=Vy[L]+0.75 ‘ speed down
- EndIf
- ‘——————————————— Red Signal ——————————————————————————————-
- If UDNotice=”NG” And 425<Ypos[L] and Ypos[L]<450 then ‘ Signal = “Red”
- Vy[L]=0 ‘ speed down
- EndIf
- ‘——————————————— car move // avoid collision ———————————————————————–
- For i=1 To 8
- Shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"]),Shapes.GetTop(SHP[L][i]["obj"])-VY[L])
- EndFor
- Y_AvoidCollision() ‘ speed control
- ‘———————————————– go over left next position ————————————————————————-
- If Ypos[L]< -135*(L-2*cars) Then
- RNDY=600 -Ypos[L]+ 135*(L-2*cars)*2
- For i=start To end-1
- shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"]),Shapes.GetTop(SHP[L][i]["obj"])+RNDY)
- endfor
- RNDYSpeed()
- endif
- EndFor
- EndSub
- Sub Down_Cars_Moving
- DN=cars
- For L=(3*cars+2) To (4*cars+1)
- Ypos[L]=Shapes.Gettop(SHP[L][1]["obj"])
- ‘——————————————— Restart ———————————————————————————————–
- If UDNotice=”OK” And -2000<Ypos[L] and Vy[L]<0.35 then ‘ if signal becomes “Blue”
- RNDYSpeed() ‘ new speed
- EndIf
- ‘——————————————— Yellow Signal ——————————————————————————————-
- If UDNotice=”Notice” And RemTime<=3 and 180<Ypos[L] and Ypos[L]<205 then ‘ Notice Area
- Vy[L]=Vy[L]*0.75 ’ speed down
- elseIf UDNotice=”Notice” And 165<Ypos[L] and Ypos[L]<250 then ‘ Signal = “Yellow”
- Vy[L]=Vy[L]+0.75 ‘ speed down
- EndIf
- ‘——————————————— Red Signal ——————————————————————————————-
- If UDNotice=”NG” And 180<Ypos[L] and Ypos[L]<205 then ‘ Signal = “Red”
- Vy[L]=0 ’ speed down
- EndIf
- ‘——————————————— car move // avoid collision ———————————————————————–
- For i=1 To 8
- Shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"]),Shapes.GetTop(SHP[L][i]["obj"])+VY[L])
- EndFor
- Y_AvoidCollision() ‘ speed control
- ‘———————————————– go over left next position ————————————————————————-
- If Ypos[L]> 700+135*(L-3*cars-1) Then
- RNDY=-Ypos[L]- 135*(L-3*cars-1)*2
- For i=start To end-1
- shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"]),Shapes.GetTop(SHP[L][i]["obj"])+RNDY)
- endfor
- RNDYSpeed()
- endif
- EndFor
- EndSub
- Sub RemainTime
- CycleTime=40 ’ LR ; 40 sec UD ; 40 sec
- DT=(Clock.ElapsedMilliseconds-t0)/1000 ‘ Elapsed time ; sec
- RemTime=text.GetSubText(1000+math.round(CycleTime-DT),2,3) ‘ Remained time ( Count down)
- For k=21 To 24
- Shapes.SetText( SHP[1][K]["obj"],RemTime) ‘ show remained time
- EndFor
- If (CycleTime/2>DT and DT>=CycleTime/2-10) Then ‘ LR trafic ; Yellow signal blinking
- blink_LR_Yellow()
- elseIf (CycleTime>DT and DT>=CycleTime-10) Then ’ UD trafic ; Yellow signal blinking
- blink_UD_Yellow()
- elseIf CycleTime/2+1>DT and DT>=CycleTime/2 Then ‘ UD trafic ; Can Go ! Signals for UD :Blue
- UD_Trafic_Go()
- elseIf CycleTime+1>DT and DT>=CycleTime Then ’ LR trafic ; Can Go ! Signals for LR :Blue
- LR_Trafic_Go()
- t0= Clock.ElapsedMilliseconds ‘ CycleTime reset
- DT=0
- EndIf
- endsub
- Sub LR_Trafic_Go
- LRNotice=”OK”
- UDNotice=”NG”
- ON["R"]=”1=1;2=1;3=0;4=0″
- ON["Y"]=”1=0;2=0;3=0;4=0″
- ON["B"]=”1=0;2=0;3=1;4=1″
- LightON()
- endsub
- Sub blink_LR_Yellow
- LRNotice=”Notice”
- UDNotice=”NG”
- ON["R"]=”1=1;2=1;3=0;4=0″
- ON["Y"]=”1=0;2=0;3=1;4=1″ ‘ for LR
- ON["B"]=”1=0;2=0;3=0;4=0″
- LightON()
- Program.Delay(20)
- ON["Y"]=”1=0;2=0;3=0;4=0″ ‘
- LightON()
- EndSub
- Sub blink_UD_Yellow
- LRNotice=”NG”
- UDNotice=”Notice”
- ON["R"]=”1=0;2=0;3=1;4=1″
- ON["Y"]=”1=1;2=1;3=0;4=0″ ‘ for UD
- ON["B"]=”1=0;2=0;3=0;4=0″
- LightON()
- Program.Delay(20)
- ON["Y"]=”1=0;2=0;3=0;4=0″ ‘
- LightON()
- EndSub
- Sub UD_Trafic_Go
- LRNotice=”NG”
- UDNotice=”OK”
- ON["R"]=”1=0;2=0;3=1;4=1″
- ON["Y"]=”1=0;2=0;3=0;4=0″
- ON["B"]=”1=1;2=1;3=0;4=0″
- LightON()
- endsub
- Sub AllClear
- ON["R"]=”1=0;2=0;3=0;4=0″
- ON["Y"]=”1=0;2=0;3=0;4=0″
- ON["B"]=”1=0;2=0;3=0;4=0″
- LightON()
- endsub
- Sub LightON
- For k=1 To 4 ‘ 1,2 Left Upper & Right Lower 3 ,4 Right Upper & Left Lower
- shapes.SetOpacity(SHP[1][5*(K-1)+3]["obj"],10+90*ON["R"][K]) ‘ Red
- shapes.SetOpacity(SHP[1][5*(K-1)+4]["obj"],10+90*ON["Y"][K]) ‘ Yellow
- shapes.SetOpacity(SHP[1][5*(K-1)+5]["obj"],10+90*ON["B"][K]) ‘ Blue
- endfor
- EndSub
- Sub Shapes_Init
- X0 = 250 ‘ x offset
- Y0 = 150 ‘ y offset
- ‘———————————————————————————————————————-
- shp[1][1] = “func=rect;x=213;y=50;width=26;height=85;bc=#3B9440;pc=#3B9440;pw=2;” ‘ Left Upper
- shp[1][2] = “func=rect;x=224;y=135;width=8;height=16;bc=#000000;pc=#000000;pw=2;” ‘ Pole
- shp[1][3] = “func=ell;x=220;y=80;width=14;height=15;bc=#FF0000;pc=#FF0000;pw=2;” ‘ Red
- shp[1][4] = “func=ell;x=220;y=98;width=14;height=15;bc=#FFFF00;pc=#FFFF00;pw=2;” ‘ Yellow
- shp[1][5] = “func=ell;x=220;y=116;width=14;height=14;bc=#0000FF;pc=#0000FF;pw=2;” ‘ Blue
- ‘———————————————————————————————————————-
- shp[1][6] = “func=rect;x=364;y=269;width=26;height=85;bc=#3B9440;pc=#3B9440;pw=2;” ‘ Right Lower
- shp[1][7] = “func=rect;x=373;y=252;width=8;height=16;bc=#000000;pc=#000000;pw=2;”
- shp[1][8] = “func=ell;x=371;y=310;width=14;height=14;bc=#FF0000;pc=#FF0000;pw=2;” ‘ Red
- shp[1][9] = “func=ell;x=371;y=292;width=14;height=14;bc=#FFFF00;pc=#FFFF00;pw=2;” ‘ Yellow
- shp[1][10] = “func=ell;x=371;y=274;width=14;height=14;bc=#0000FF;pc=#0000FF;pw=2;” ‘ Blue
- ‘———————————————————————————————————————-
- shp[1][11] = “func=rect;x=378;y=116;width=85;height=20;bc=#3B9440;pc=#3B9440;pw=2;” ‘ Right Upper
- shp[1][12] = “func=rect;x=355;y=124;width=22;height=8;bc=#000000;pc=#000000;pw=2;”
- shp[1][13] = “func=ell;x=418;y=119;width=14;height=14;bc=#FF0000;pc=#FF0000;pw=2;” ‘ Red
- shp[1][14] = “func=ell;x=400;y=119;width=14;height=14;bc=#FFFF00;pc=#FFFF00;pw=2;” ‘ Yellow
- shp[1][15] = “func=ell;x=382;y=119;width=14;height=14;bc=#0000FF;pc=#0000FF;pw=2;” ‘ Blue
- ‘———————————————————————————————————————-
- shp[1][16] = “func=rect;x=145;y=259;width=85;height=24;bc=#3B9440;pc=#3B9440;pw=2;” ‘ Left Lower
- shp[1][17] = “func=rect;x=231;y=267;width=16;height=8;bc=#000000;pc=#000000;pw=2;”
- shp[1][18] = “func=ell;x=177;y=263;width=14;height=14;bc=#FF0000;pc=#FF0000;pw=2;” ‘ Red
- shp[1][19] = “func=ell;x=194;y=263;width=14;height=14;bc=#FFFF00;pc=#FFFF00;pw=2;” ‘ Yellow
- shp[1][20] = “func=ell;x=213;y=263;width=14;height=14;bc=#0000FF;pc=#0000FF;pw=2;” ‘ Blue
- ‘———————————————————————————————————————-
- shp[1][21] = “func=text;x=216;y=60;text=120;bc=#FF0000;fs=14;fn=Coulier New;” ‘ Remaining time #1 Left Upper
- shp[1][22] = “func=text;x=366;y=330;text=120;bc=#FF0000;fs=14;fn=Coulier New;” ‘ Remaining time #1 Right Lower
- shp[1][23] = “func=text;x=438;y=116;text=120;bc=#FF0000;fs=14;fn=Coulier New;” ‘ Remaining time #2 Right Upper
- shp[1][24] = “func=text;x=151;y=262;text=120;bc=#FF0000;fs=14;fn=Coulier New;” ‘ Remaining time #1 Left Lowerer
- EndSub
- Sub shapecars
- ‘————————————– Left oriented cars ——————————————————————————–
- s=0.55
- start=1
- End=9
- cars=5
- For L=2 To (cars+1)
- shp[L][1] = “func=rect;x=4;y=23;width=130;height=25;bc=#00F0CA;pc=#000000;pw=2;”
- shp[L][2] = “func=ell;x=20;y=33;width=23;height=23;bc=#9D756A;pc=#000000;pw=2;”
- shp[L][3] = “func=ell;x=95;y=32;width=23;height=23;bc=#9D756A;pc=#000000;pw=2;”
- shp[L][4] = “func=rect;x=48;y=2;width=54;height=23;bc=#E0F0CA;pc=#000000;pw=2;”
- shp[L][5] = “func=tri;x=41;y=5;x1=7;y1=0;x2=0;y2=17;x3=15;y3=17;bc=#E0F0CA;pc=#E0F0CA;pw=2;”
- shp[L][6] = “func=tri;x=91;y=5;x1=9;y1=0;x2=0;y2=17;x3=18;y3=17;bc=#E0F0CA;pc=#E0F0CA;pw=2;”
- shp[L][7] = “func=ell;x=0;y=26;width=11;height=12;bc=#FFFF00;pc=#FF0000;pw=2;”
- shp[L][8] = “func=ell;x=58;y=5;width=10;height=15;bc=#6A5ACD;pc=#6A5ACD;pw=4;”
- shp[L][9] = “func=text;x=80;y=5;text=”+(L-1)+”;bc=#FF0000;fs=22;fn=Coulier New;”
- Shapes_Add()
- For i=start To end
- shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"])+700+(L-2)*160,Shapes.GetTop(SHP[L][i]["obj"])+210)
- EndFor
- RNDXSpeed()
- EndFor
- ‘————————————– Right oriented cars ——————————————————————————–
- For L=(cars+2) To (2*cars+1)
- shp[L][1] = “func=rect;x=6;y=83;width=130;height=25;bc=#E000CA;pc=#000000;pw=2;”
- shp[L][2] = “func=ell;x=20;y=93;width=23;height=23;bc=#9D756A;pc=#000000;pw=2;”
- shp[L][3] = “func=ell;x=95;y=92;width=23;height=23;bc=#9D756A;pc=#000000;pw=2;”
- shp[L][4] = “func=rect;x=48;y=62;width=54;height=23;bc=#E0F0CA;pc=#000000;pw=2;”
- shp[L][5] = “func=tri;x=41;y=65;x1=7;y1=0;x2=0;y2=17;x3=15;y3=17;bc=#E0F0CA;pc=#E0F0CA;pw=2;”
- shp[L][6] = “func=tri;x=91;y=65;x1=9;y1=0;x2=0;y2=17;x3=18;y3=17;bc=#E0F0CA;pc=#E0F0CA;pw=2;”
- shp[L][7] = “func=ell;x=128;y=86;width=11;height=12;bc=#FFFF00;pc=#FF0000;pw=2;”
- shp[L][8] = “func=ell;x=85;y=61;width=10;height=15;bc=#6A5ACD;pc=#6A5ACD;pw=4;”
- shp[L][9] = “func=text;x=60;y=60;text=”+(L-cars-1)+”;bc=#FF0000;fs=22;fn=Coulier New;”
- Shapes_Add()
- For i=start To end
- shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"])-200-(L-cars-2)*160,Shapes.GetTop(SHP[L][i]["obj"])+125)
- EndFor
- RNDXSpeed()
- EndFor
- ‘—————————————Up oriented cars ——————————————————————————-
- end2=8
- For L=(2*cars+2) To (3*cars+1)
- shp[L][1] = “func=ell;x=2;y=0;width=34;height=93;bc=#DBD229;pc=#DBD229;pw=2;”
- shp[L][2] = “func=ell;x=2;y=7;width=11;height=7;bc=#FF0000;pc=#FF0000;pw=2;”
- shp[L][3] = “func=ell;x=25;y=7;width=11;height=7;bc=#FF0000;pc=#FF0000;pw=2;”
- shp[L][4] = “func=rect;x=31;y=19;width=6;height=14;bc=#000000;pc=#6A5ACD;pw=2;”
- shp[L][5] = “func=rect;x=1;y=19;width=6;height=14;bc=#000000;pc=#6A5ACD;pw=2;”
- shp[L][6] = “func=rect;x=0;y=60;width=6;height=14;bc=#000000;pc=#6A5ACD;pw=2;”
- shp[L][7] = “func=rect;x=31;y=60;width=6;height=14;bc=#000000;pc=#6A5ACD;pw=2;”
- shp[L][8] = “func=text;x=12;y=35;text=”+(L-2*cars-1)+”;bc=#FF0000;fs=22;fn=Coulier New;”
- Shapes_Add()
- For i=start To end2
- shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"])+260,Shapes.GetTop(SHP[L][i]["obj"])+500+(L-(2*cars+2))*160)
- EndFor
- RNDYSpeed()
- EndFor
- ‘—————————————Down oriented cars ——————————————————————————-
- For L=(3*cars+2) To (4*cars+1)
- shp[L][1] = “func=ell;x=2;y=0;width=34;height=93;bc=#E090CA;pc=#DBD229;pw=2;”
- shp[L][2] = “func=ell;x=2;y=77;width=11;height=7;bc=#FF0000;pc=#FF0000;pw=2;”
- shp[L][3] = “func=ell;x=25;y=77;width=11;height=7;bc=#FF0000;pc=#FF0000;pw=2;”
- shp[L][4] = “func=rect;x=31;y=19;width=6;height=14;bc=#000000;pc=#6A5ACD;pw=2;”
- shp[L][5] = “func=rect;x=1;y=19;width=6;height=14;bc=#000000;pc=#6A5ACD;pw=2;”
- shp[L][6] = “func=rect;x=0;y=60;width=6;height=14;bc=#000000;pc=#6A5ACD;pw=2;”
- shp[L][7] = “func=rect;x=31;y=60;width=6;height=14;bc=#000000;pc=#6A5ACD;pw=2;”
- shp[L][8] = “func=text;x=12;y=40;text=”+(L-3*cars-1)+”;bc=#FF0000;fs=22;fn=Coulier New;”
- Shapes_Add()
- For i=start To end2
- shapes.Move(SHP[L][i]["obj"],Shapes.GetLeft(SHP[L][i]["obj"])+320,Shapes.GetTop(SHP[L][i]["obj"])-130-( L – (3*cars+2) )*160)
- EndFor
- RNDYSpeed()
- EndFor
- ‘ ‘———————————————————————————————————————-
- GraphicsWindow.Show()
- t0= Clock.ElapsedMilliseconds ‘ start tim
- EndSub
- Sub GUI
- GraphicsWindow.Title=” Trafic Signals and Car action “
- GraphicsWindow.top=10
- GraphicsWindow.Left=20
- GraphicsWindow.Hide()
- GraphicsWindow.Width=1200
- GraphicsWindow.Height=700
- GraphicsWindow.BackgroundColor=”DarkGreen”
- GraphicsWindow.BrushColor=”Gray”
- GraphicsWindow.PenColor=”Gray”
- GraphicsWindow.FillEllipse(50,-50,1000,770)
- GraphicsWindow.BrushColor=”DarkGreen”
- GraphicsWindow.PenColor=”DarkGreen”
- GraphicsWindow.FillEllipse(100,-10,900,680)
- GraphicsWindow.BrushColor=”Gray”
- GraphicsWindow.PenColor=”Gray”
- GraphicsWindow.FillRectangle(-100,300,1400,100)
- GraphicsWindow.FillRectangle(500,-100,100,1000)
- GraphicsWindow.BrushColor=”White”
- GraphicsWindow.PenColor=”White”
- For i=1 To 20
- GraphicsWindow.FillRectangle(30+(i-1)*100,350-5,30,5)
- GraphicsWindow.FillRectangle(550,-30+(i-1)*80,5,30)
- endfor
- GraphicsWindow.FillRectangle(475,300,5,30)
- GraphicsWindow.FillRectangle(625,370,5,30)
- GraphicsWindow.FillRectangle(500,418,35,5)
- GraphicsWindow.FillRectangle(565,275,35,5)
- STPX=”1=475;2=625;3=500;4=565″ ‘ stop Line
- STPY=”1=300;2=370;3=418;4=275″
- ‘———————————————————————————————————————-
- s=1
- L=1
- start=1
- End=24
- Shapes_Add()
- AllClear()
- LR_Trafic_Go()
- EndSub
- Sub shapes_Add
- For i = start To End
- GraphicsWindow.PenWidth = SHP[L][i]["pw"]*s
- GraphicsWindow.PenColor = SHP[L][i]["pc"]
- GraphicsWindow.BrushColor = SHP[L][i]["bc"]
- If SHP[L][i]["func"] = “rect” Then
- SHP[L][i]["obj"] = Shapes.AddRectangle(SHP[L][i]["width"]*s, SHP[L][i]["height"]*s)
- ElseIf SHP[L][i]["func"] = “ell” Then
- SHP[L][i]["obj"] = Shapes.AddEllipse(SHP[L][i]["width"]*s, SHP[L][i]["height"]*s)
- ElseIf SHP[L][i]["func"] = “tri” Then
- SHP[L][i]["obj"] = Shapes.AddTriangle(SHP[L][i]["x1"]*s, SHP[L][i]["y1"]*s, SHP[L][i]["x2"]*s, SHP[L][i]["y2"]*s, SHP[L][i]["x3"]*s, SHP[L][i]["y3"]*s)
- ElseIf shp[L][i]["func"] = “text” Then
- fs = shp[L][i]["fs"]
- GraphicsWindow.FontSize = fs * s
- GraphicsWindow.FontName = shp[L][i]["fn"]
- shp[L][i]["obj"] = Shapes.AddText(shp[L][i]["text"])
- EndIf
EndFor
Endsub
No comments:
Post a Comment