Help me make Fireworks. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help me make Fireworks.

NostraNostra Posts: 1Member
Hello.
So I want to make a program and in it I want fireworks.
Just need some periods randomly spawning somewhere is good too, can anyone help me?

Something like: [code]Program Matrix;
Uses Crt;
Var
col,lin,ql,cont,aux:integer;
letra:char;
Begin
clrscr;
Repeat
Col:=1+Random(79);
lin:=1+Random(23);
ql:=random(10);
for cont:=lin to lin+ql do
Begin
if cont<24 then
Begin
letra:=chr(Random(255));
for aux:=1 to 2 do
Begin
if aux= 1 then
textcolor(2);
gotoxy(col,cont);
write (letra);
delay(25);
end;
end;
end;
until keypressed;
End.
[/code]

But obviously '.' instead of random characters.

Comments

  • _Atex__Atex_ Posts: 163Member
    : So I want to make a program and in it I want fireworks.
    : Just need some periods randomly spawning somewhere is good too, can
    : anyone help me?

    This was the screen saver for one of my larger textmode programs I wrote long time ago, not sure if this is what you looking for but it might give you an idea or two. Cut it out into a standalone code:[code][color=Blue]{ **** Compiler BP/TP 7 **** }

    const ssc:array[0..10] of byte=($fa,$fa,$fa,$07,$2a,$0f,$0f,$0f,$2a,$07,$20);{ characters in sequence }
    ssa:array[0..10] of byte=($04,$04,$0c,$0c,$0e,$0e,$0f,$0e,$0c,$04,$07);{ attributes in sequence }
    ssd:array[0..10] of byte=($8f,$04,$04,$04,$04,$04,$05,$04,$04,$04,$01);{ stay alive countdowns * 16.6 ms }
    mns=50; { maximum number of stars }

    var kb_bh:byte absolute 0:$41a; { keyboard buffer head mem. location }
    kb_bt:byte absolute 0:$41c; { keyboard buffer tail mem. location }

    type star=record x,y,s,t:byte;end;


    { Fast write a character at (x,y) with the given atttribute (0 based coords.)}
    procedure outchar(x,y,ch,attr:byte);
    begin memw[$b800:y shl 7 + y shl 5 + x shl 1]:=attr shl 8 + ch;end;

    procedure gen_star(var s:star);
    begin
    s.x:=random(80); { coords. }
    s.y:=random(25);if s.y=0 then inc(s.y); { <-- avoid 1st row }
    s.s:=0; { sequence }
    s.t:=ssd[s.s]; { time left }
    end;



    var i,cn:byte;
    s:array[1..mns] of star;

    begin
    randomize; { init random no. generator }
    asm mov ax,3;int 10h;end; { set videomode text co80x25 }
    write('Press any key to quit');

    cn:=1;
    gen_star(s[cn]);
    outchar(s[cn].x,s[cn].y,ssc[s[cn].s],ssa[s[cn].s]);
    repeat { main loop }

    for i:=1 to cn do begin { for each star... }
    if s[i].t>0 then dec(s[i].t) { decrease countdown timer }
    else if s[i].s<10 then begin { time up ? sequence not finished ? }
    inc(s[i].s); { increase sequence pointer }
    s[i].t:=ssd[s[i].s]; { set countdown timer }
    outchar(s[i].x,s[i].y,ssc[s[i].s],ssa[s[i].s]); { display }
    end else begin
    gen_star(s[i]); { sequence finished = generate new star }
    outchar(s[i].x,s[i].y,ssc[s[i].s],ssa[s[i].s]); { display }
    end;
    end;{for i}

    if (((random(256) mod 32)=0) and (cn<mns)) then begin { less than max. allowed stars ? + 1 in 32 chance }
    inc(cn); { increase no of stars }
    gen_star(s[cn]); { generate new star }
    outchar(s[cn].x,s[cn].y,ssc[s[cn].s],ssa[s[cn].s]); { display }
    end;

    while port[$03da] and 8<>0 do; { ~16.6 ms delay on a 60Hz LCD monitor }
    while port[$03da] and 8= 0 do;

    until kb_bh<>kb_bt; { keypressed; }
    kb_bh:=kb_bt; { readkey; }
    end.
    [/color][/code]
Sign In or Register to comment.