Author Topic: Particles  (Read 2715 times)

0 Members and 1 Guest are viewing this topic.

Offline Handmixer

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +0/-0
    • View Profile
Particles
« on: December 12, 2013, 01:41:53 pm »
I made this simple star routine.
The stars are stored in a List (L0), but is there any other way?


Code: [Select]
EXPORT Stars()
BEGIN
 LOCAL XX,YY,ANG,VEL;
 DIMGROB_P(G1,320,240);
 L0:={};

 REPEAT
  XX:=RANDOM(1,319);
  YY:=RANDOM(1,239);
  FOR I FROM 1 TO 400 STEP 4 DO
   L0(I):=XX;
   L0(I+1):=YY;
   VEL:=RANDOM(0.5,5.0);
   ANG:=π*RANDOM(0.0,2.0);
   L0(I+2):=VEL*COS(ANG);
   L0(I+3):=VEL*SIN(ANG);
  END;

   RECT_P(G1,#000000);

  FOR J FROM 1 TO 50 DO
//   RECT_P(G1,#000000);
   FOR I FROM 1 TO 400 STEP 4 DO
    PIXON_P(G1,L0(I),L0(I+1),#FFFFFF);
    PIXON_P(G1,L0(I)+1,L0(I+1),#FFFFFF);
    PIXON_P(G1,L0(I),L0(I+1)+1,#FFFFFF);
    PIXON_P(G1,L0(I)+1,L0(I+1)+1,#FFFFFF);
   END;
   BLIT_P(G0,G1);
   FOR I FROM 1 TO 400 STEP 4 DO
    L0(I):=L0(I)+L0(I+2);
    L0(I+1):=L0(I+1)+L0(I+3);
    L0(I+3):=L0(I+3)+0.15;
   END;
  END;
 
 UNTIL ISKEYDOWN(14);
END;

Offline Hooloovoo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 225
  • Rating: +22/-0
    • View Profile
Re: Particles
« Reply #1 on: December 12, 2013, 02:28:03 pm »
You can make a local variable which is a list, and lists can contain any type of variable. You could make a list which contains a bunch of 3-element lists, or you could have a 400x3 matrix. you can index a list in a list by using LISTNAME(index1,index2). You can also use the MAKEMAT(value,rows,columns) command to make a list (yes, it works on lists) or matrix rows x columns.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale." -tr1p1ea
Spoiler For some of the calcs I own:



(actually I have quite a few more than this, but I don't feel like making bars for them all.)