harraps

snowy days BF in javascript

Jan 13th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var bf_prog = "++++++++[>++++++++++++>++++<<-]>[>>+>+>+>+<<<<<-]++++[>>>++++++>+++>+++++<<<<<-]>>++++>->++>-.<.+.<.++.<<.>.---.>.>>.";
  2.  
  3. function snowText(string, w, h, proba){
  4.     var index = 0;
  5.     var res   = "";
  6.     for(var i=0; i<h; ++i){
  7.             for(var j=0; j<w; ++j){
  8.             if(Math.random() < proba){
  9.                 res += string.charAt(index);
  10.                 ++index;
  11.             }else{
  12.                 res += ' ';
  13.             }
  14.         }
  15.         res += '\n';
  16.     }
  17.     return res + string.substring(index, string.length);
  18. }
  19.  
  20. console.log(snowText(bf_prog, 100, 20, 0.03));
Advertisement
Add Comment
Please, Sign In to add comment