Post Reply 
Xmas Spirit?
12-24-2023, 03:38 PM
Post: #3
RE: Xmas Spirit?
Just my 2 cents.

Code:
CONST width=12, height=10;
LOCAL buffer:=MAKEMAT(0, height, width);

EXPORT Ctree()
BEGIN 
DIMGROB_P(G1,320,240,1);
DIMGROB_P(G2,320,240,1);
DIMGROB_P(G3,320,240,1);
DIMGROB_P(G4,320,240,RGB(255,0,0));
DIMGROB_P(G5,320,240,RGB(255,0,0));
DIMGROB_P(G6,320,240,RGB(255,0,0));
DIMGROB_P(G7,width,height,0);
LOCAL BAUBS:=0;
LOCAL BX:={};
LOCAL BY:={};
LOCAL X:=0;
LOCAL ox:=-18;  //  X-AXIS OFFSET OF TREE
LOCAL Y:=0;
LOCAL COL:=0;
LOCAL R:=0;
LOCAL G:=0;
LOCAL B:=0;
LOCAL A:=0;
LOCAL FR:=0;
LOCAL FG:=0;
LOCAL FB:=0;
LOCAL GO:=0;

HAngle:=0;
RECT_P(0);   //   BACKGROUND CLEAR
LINE_P(200,160,140,240,RGB(180,60,0));  //   FIREPLACE LINE L
LINE_P(290,160,320,210,RGB(180,60,0));  //  FIREPLACE LINE R
TRIANGLE_P(120+ox,50,95+ox,92,145+ox,92,RGB(0,255,0));     //  TREE TOP
TRIANGLE_P(120+ox,60,80+ox,130,160+ox,130,RGB(0,255,0));   //  TREE 2
TRIANGLE_P(120+ox,90,70+ox,170,170+ox,170,RGB(0,255,0));   //  TREE 3
TRIANGLE_P(120+ox,130,60+ox,200,180+ox,200,RGB(0,255,0));  //  TREE BOTTOM
RECT_P(110+ox,201,130+ox,225,RGB(150,40,10)); //  TREE TRUNK
RECT_P(200,80,290,160,RGB(255,0,0)); //   FIRE-CENTRE
REPEAT
X:=RANDINT(290,200);
Y:=RANDINT(200,120);
A:=X-245;
B:=Y-160;
IF SQRT(A^2+B^2)<34 AND Y<160 THEN
ARC_P(G5,X,Y,2,0,2*π,{0,0});         //  COALS
T:=T+1;
END;
UNTIL T=250;
BLIT_P(G4,G5,RGB(255,0,0));
BLIT_P(G5,RGB(255,0,0));
BLIT_P(G1,G0);
BLIT_P(G2,G0);

REPEAT
X:=RANDINT(50+ox,165+ox);
Y:=RANDINT(30,220);
GO:=1;

IF BAUBS>0 THEN
FOR T FROM 0 TO BAUBS DO
A:=X-BX(T);
B:=Y-BY(T);
IF SQRT(A^2+B^2)<14 THEN
GO:=0;
END;
END;
END;

IF BAUBS=0 THEN
GO:=1;
END;

IF GO=1 AND GETPIX_P(X,Y)=RGB(0,255,0) THEN
BAUBS:=BAUBS+1;
BX(BAUBS):=X;
BY(BAUBS):=Y;
ARC_P(BX(BAUBS),BY(BAUBS),5,0,2*π,{0,0});
//WAIT(0.3);
END;
UNTIL BAUBS=32;

BLIT(G1,G2);

REPEAT
RECT_P(G6,RGB(RANDINT(70,35),RANDINT(35,1),0));     //   FIRE-SHINE
BLIT_P(G6,G5,RGB(255,0,0));
FOR X FROM 0 to BAUBS-1 DO
R:=RANDINT(255,0);
G:=RANDINT(255,0);
B:=RANDINT(255,0);
FR:=RANDINT(255,200);
FG:=RANDINT(200,0);
FB:=RANDINT(20,0);
ARC_P(G1,BX(X),BY(X),5,0,2*π,{RGB(R,G,B),RGB(R,G,B)});
RECT_P(G1,200,80,290,160,RGB(FR,FG,FB));
END;
IF VERSION(2)>="D" THEN
  WAIT(0.08);
END;
BLIT_P(G1,G5,RGB(255,0,0));
BLIT_P(G6,G1,0);
FIRE();
BLIT_P(G6);

UNTIL ISKEYDOWN(4)=1;

END;

FIRE()
BEGIN
 LOCAL intensity;
 LOCAL x,y;
  FOR x FROM 1 TO width DO
   buffer(height, x) := RANDINT(0, 255);
  END;
  FOR y FROM 1 TO height-1 DO
   FOR x FROM 1 TO width DO
    intensity := (buffer(y+1, x) 
                  + buffer(y+1, IFTE(x==1, width, x-1))
                  + buffer(y+1, IFTE(x==width, 1, x+1))
                  + buffer(IFTE(y+2 > height, y+1, y+2), x)) / 4;
    intensity := MAX(0, intensity - RANDINT(0, 20));
    buffer(y, x) := intensity;
   END;
  END;  
  FOR y FROM 1 TO height DO
   FOR x FROM 1 TO width DO
    intensity := buffer(y, x);
    IF intensity > 180 THEN
     PIXON_P(G7,x, y, RGB(255, 255, intensity));
    ELSE
     IF intensity > 80 THEN
      PIXON_P(G7,x, y, RGB(255, intensity, 0));
     ELSE
      PIXON_P(G7,x, y, RGB(intensity, 0, 0));
     END;
    END;
   END;
  END;
 BLIT_P(G6,210,90,280,152,G7,1,1,width,height,0,223);    
END;

Merry Christmas
Piotr
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Xmas Spirit? - matalog - 12-22-2023, 09:26 PM
RE: Xmas Spirit? - DéFCoM - 12-23-2023, 06:37 AM
RE: Xmas Spirit? - komame - 12-24-2023 03:38 PM
RE: Xmas Spirit? - matalog - 12-24-2023, 10:28 PM
RE: Xmas Spirit? - komame - 12-25-2023, 07:51 AM
RE: Xmas Spirit? - matalog - 12-25-2023, 03:13 PM
RE: Xmas Spirit? - komame - 12-26-2023, 07:39 AM
RE: Xmas Spirit? (fire effect) - komame - 12-30-2023, 04:04 PM
RE: Xmas Spirit? - komame - 12-31-2023, 10:59 AM
RE: Xmas Spirit? - tjurij - 01-02-2024, 05:46 AM
RE: Xmas Spirit? - komame - 01-02-2024, 06:39 AM
RE: Xmas Spirit? - StephenG1CMZ - 01-03-2024, 12:16 AM



User(s) browsing this thread: 1 Guest(s)