Hallo,
ich bin neu hier und versuche erstmal alles richtig zu machen, wenn ich durch irgendwas gegen irgendwas verstoße oder so berichtigt mich bitte.
Also, ich lerne jetzt seit kurzer Zeit Informatik in der Schule und soll eine Ampelkreuzung mit verschiedenen Shapes programmieren, es ist auch kein Problem für mich eine Ampel per Timer automatisch schalten zu lassen, weiter bin ich allerdings nicht gekommen, da ich absolut keine ahnung habe was ich machen muss. Ich bin mir allerdings schon bewusst, dass es acht verschiedene Phasen gibt:
1. oben/unten Grün, links/rechts Rot
2. oben/unten Gelb, links/rechts Rot
3. oben/unten Rot, links/rechts Rot-Gelb
4. oben/unten Rot, links/rechts Gelb
5. oben/unten Rot, links/rechts Rot,
6. oben/unten Rot, links/rechts Grün,
7. oben/unten Rot, links/rechts Rot,
8. oben/unten Rot-Gelb, links/rechts Grün,
Das ist allerdings leider auch schon alles was ich weiß, es wäre super nett wenn ihr mir helfen könntet! Hier ist noch mein aktueller Quellcode:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;
type TForm1 = class(TForm) Shausdach8: TShape; Shausdach2: TShape; Shausdach6: TShape; Shausdach4: TShape; Shausdach7: TShape; Shausdach3: TShape; Shausdach5: TShape; SHausdach1: TShape; Slinkszurueck: TShape; Slinksvor: TShape; Sobenvor: TShape; Sobenzurueck: TShape; Srechtsvor: TShape; Srechtszurueck: TShape; Suntenzurueck: TShape; Suntenvor: TShape; STrennoben: TShape; STrennrechts: TShape; Strennlinks: TShape; Strennunten: TShape; SKreuzungMitte: TShape; SAmpeloben: TShape; SAmpelrechts: TShape; SAmpelunten: TShape; SAmpellinks: TShape; Srotoben: TShape; Sgelboben: TShape; Sgruenoben: TShape; Sgruenrechts: TShape; Sgelbechts: TShape; Srotrechts: TShape; Sgruenlinks: TShape; Sgelblinks: TShape; Srotlinks: TShape; Sgruenunten: TShape; Sgelbunten: TShape; Srotunten: TShape; Timer1: TTimer; SAmpelFussoben: TShape; SAmpelFussUnten: TShape; SRotFussoben: TShape; SGruenFussoben: TShape; SgruenFussunten: TShape; SrotFussunten: TShape; SUebergang: TShape; BFuss: TButton; procedure Timer1Timer(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Timer1Timer(Sender: TObject); begin IF (srotoben.Brush.color = clred) AND (sgelboben.Brush.color = clwhite) THEN sgelboben.brush.Color := clyellow ELSE IF (Srotoben.Brush.Color = clred) AND (sgelboben.Brush.Color = clyellow) THEN Begin Srotoben.brush.color := clwhite; Sgelboben.Brush.color := clwhite; Sgruenoben.Brush.color := clgreen; end ELSE IF Sgelboben.Brush.color = clyellow THEN Begin Srotoben.Brush.color := clred; Sgelboben.Brush.color := clwhite; Sgruenoben.brush.color := clwhite; End ELSE Begin IF Sgruenoben.Brush.color = clgreen THEN begin sgruenoben.Brush.color := clwhite; sgelboben.Brush.color := clyellow; end; end; end; end. |