0 Members and 2 Guests are viewing this topic.
[A](Y,X
Hmm, you could use a matrix (it uses indices the same as pixel coords or homescreen coordinates, so "Y" then "X").This way, the program doesn't start to slow down as more snow flakes are added. Basically, just create an 8*16 matrix (it will be huge, being the size of a 128 element list). Then you can just check if a snow flake is already in a spot as if you were reading homescreen coordinates:Code: [Select][A](Y,XThis might speed things up a bit (not sure).
If 1=[A](1,1:Output(1,1+B,"MIf 1=[A](1,2:Output(1,2+B,"MIf 1=[A](1,3:Output(1,3+B,"MIf 1=[A](1,4:Output(1,4+B,"MIf 1=[A](1,5:Output(1,5+B,"MIf 1=[A](2,1:Output(2,1+B,"MIf 1=[A](2,2:Output(2,2+B,"MIf 1=[A](2,3:Output(2,3+B,"MIf 1=[A](2,4:Output(2,4+B,"MIf 1=[A](2,5:Output(2,5+B,"MIf 1=[A](3,1:Output(3,1+B,"MIf 1=[A](3,2:Output(3,2+B,"MIf 1=[A](3,3:Output(3,3+B,"MIf 1=[A](3,4:Output(3,4+B,"MIf 1=[A](3,5:Output(3,5+B,"M
Matr>list([A],8,L2 ;get the last rowFor(A,7,1,-1Matr>list([A],A,L1L1*(L1 and not(L2→L3 ;This checks if anything in L1 can move down into L2 ;"not(L2" leaves a 0 where there is already a flake, else 1 if empty ;Then "L1 and not(L2" leaves a 1 if there is a snowflake above an empty spaceL1-Ans→L1 ;remove the snowflakes that can move down from L1While max(L3max(L3→B ;location of the snowflake furthest to the right0→L3(Ans ;remove the snowflake from L3, the list of moveable flakes0→[A](B,A ;remove it from the matrixOutput(A,B," ;Erase itmin(16,max(1,B+1-2int(2rand ;randomly move left/rightIf L2(Ans ;check if the space is occupiedBAns→[A](Ans,A+1 ;write the snowflake to the new coordinateOutput(A+1,Ans,"*EndL1→L2 ;now This row becomes the new lower rowEnd
Mine draws the flakes when they are newly added at the top of the screen, then it searches the matrix for snowflakes that can move down. It erases those ones and draws their new position.Also, DJ_O, you didn't need the "1=" part of those If statements.* Xeda112358 runsThe way I test for flakes that can move is I store the matrix rotated so that column 1 is the first row of snow flakes. Then each snow flake is represented by the column number it is in (so if it is homescreen column 6, it has a 6 in the matrix). My code is then:Code: [Select]Matr>list([A],8,L2 ;get the last rowFor(A,7,1,-1Matr>list([A],A,L1L1*(L1 and not(L2→L3 ;This checks if anything in L1 can move down into L2 ;"not(L2" leaves a 0 where there is already a flake, else 1 if empty ;Then "L1 and not(L2" leaves a 1 if there is a snowflake above an empty spaceL1-Ans→L1 ;remove the snowflakes that can move down from L1While max(L3max(L3→B ;location of the snowflake furthest to the right0→L3(Ans ;remove the snowflake from L3, the list of moveable flakes0→[A](B,A ;remove it from the matrixOutput(A,B," ;Erase itmin(16,max(1,B+1-2int(2rand ;randomly move left/rightIf L2(Ans ;check if the space is occupiedBAns→[A](Ans,A+1 ;write the snowflake to the new coordinateOutput(A+1,Ans,"*EndL1→L2 ;now This row becomes the new lower rowEnd
{16,8->dim([A]DelVar EE[A]→[A]ClrHome2→SRepeat E>=128 or getKey=45For(B,1,SRepeat not([A](Ans,1randInt(1,16EndAns→[A](Ans,1Output(1,Ans,"*E+1→EIf E=128S→BEndMatr>list([A],8,L2For(A,7,1,-1Matr>list([A],A,L1L1*(L1 and not(L2→L3L1-Ans→L1While max(L3max(L3→B0→L3(Ans0→[A](B,AOutput(A,B," min(16,max(1,B+1-2int(2randIf L2(AnsBAns→[A](Ans,A+1Ans→L2(AnsOutput(A+1,Ans,"*EndL1→L2EndEnd