Написать программу дождь- в верхней части экрана появляются случайным образом 50 точек и они движутся сверху вниз. Когда точка достигнет низа она должна появится сверху и опять падать — Pascal(Паскаль)

program draw1;
 
uses graph, crt;
 
const
    DOT_COUNT = 50;
type
    TDot = packed record
        X  :Integer;
        Y  :Integer;
    end;
 
var d, m, i :Integer;
    Dots    :array[0..DOT_COUNT-1] of TDot;
 
begin
    d := detect;
    InitGraph(d,m,'');
    if GraphResult<>grOK then begin
        WriteLn('Graphics error: ', GraphErrorMsg(GraphResult));
        ReadLn;
        Halt(1);
    end;
    SetBkColor(0);
    ClearDevice;
    SetColor(15);
 
    Randomize;
    for i := 0 to DOT_COUNT-1 do begin
        Dots[i].X := Random(GetMaxX);
        Dots[i].Y := -Random(GetMaxY);
    end;
    repeat
        for i := 0 to DOT_COUNT do begin
            PutPixel(Dots[i].X, Dots[i].Y, 0);
            inc(Dots[i].Y);
            if Dots[i].Y >= GetMaxY then begin
                Dots[i].Y := 0;
                Dots[i].X := Random(GetMaxX);
            end;
            PutPixel(Dots[i].X, Dots[i].Y, 15);
        end;
        delay(100);
    until KeyPressed;
 
    CloseGraph;
end.

Leave a Comment

3 + 4 =