FUNCTION defPixel$()
     defPixel$ = "."
     IF INT(RND*2) = 1 THEN defPixel$ = "X"
 END FUNCTION

 SUB putString(s$, x%, y%)
  '   ⎺⎺⎺⎺⎺⎺⎺⎺⎺
  for c = 1 to len(s$)
	  sc$ = MID$(s$, c, 1)
    this$ = _GETCHR$(ASC(sc$))
    for yi = 0 to 7
      for xi = 0 to 7
        IF MID$(this$, (xi + yi*8) + 1, 1) = "X" THEN PSET (x% + xi + (c-1)*8, y% + yi)
      next xi
    next yi
  next c
  end sub

'🔸🔸🔸  Main Program

  SCREEN _NEWIMAGE(160, 112, 14)

  DO

      GOSUB 🎲CreateGraphicsChars
      GOSUB 🌱Init
      GOSUB ✅PrintTiles
      _delay 0.5

  LOOP

  END

'🔸🔸🔸 Subroutines

  🎲CreateGraphicsChars: 
        c$ = "" : d$ = ""
        FOR i = 1 TO 64
            p$ = defPixel$()
            c$ = c$ + p$
            d$ = p$ + d$
        NEXT i
        _LETCHR$(0, c$) : _LETCHR$(1, d$)
        c$ = "" : d$ = ""
        FOR i = 1 TO 64
            p$ = defPixel$()
            c$ = c$ + p$
            d$ = p$ + d$
        NEXT i
        _LETCHR$(2, c$) : _LETCHR$(3, d$)
    RETURN
    
  🌱Init:
        CLS: Couleur1 = INT(RND*64) + 1 : PRINT
        SetCouleur2:
            Couleur2 = INT(RND*65) : IF Couleur2 = Couleur1 THEN GOTO SetCouleur2
    RETURN

  ✅PrintTiles:
        ptrn% = INT(RND*3)
        SELECT CASE ptrn%
          CASE 0
            l1c0$ = CHR$(0) : l1c1$ = CHR$(0) : l1c2$ = CHR$(1)
            l2c0$ = CHR$(2) : l2c1$ = CHR$(2) : l2c2$ = CHR$(3)
          CASE 1
            l1c0$ = CHR$(0) : l1c1$ = CHR$(1) : l1c2$ = CHR$(0)
            l2c0$ = CHR$(2) : l2c1$ = CHR$(3) : l2c2$ = CHR$(2)
          CASE 2
            l1c0$ = CHR$(1) : l1c1$ = CHR$(0) : l1c2$ = CHR$(0)
            l2c0$ = CHR$(3) : l2c1$ = CHR$(2) : l2c2$ = CHR$(2)
        END SELECT
        FOR Z = 0 TO 104
        x% = 0 : y% = 8
        CLS
        FOR i = 1 TO 80
            COLOR Couleur1 : PutString( l1c0$, x%, y% )
            COLOR Couleur2 : PutString( l2c0$, x%, y% + Z )
            GOSUB ⏭NextCoordinates
            COLOR Couleur1 : PutString( l1c1$, x%, y% )
            COLOR Couleur2 : PutString( l2c1$, x%, y%+Z )
            GOSUB ⏭NextCoordinates
            COLOR Couleur1 : PutString( l1c2$, x%, y% )
            COLOR Couleur2 : PutString( l2c2$, x%, y%+Z )
            GOSUB ⏭NextCoordinates
        NEXT i
                    _delay 0.1
                    if z = 0 then _delay 0.5
        NEXT Z
    RETURN

  ⏭NextCoordinates:
        x% = x% + 8
        IF x% > 159 THEN x% = 0 : y% = y% + 8
    RETURN