day 5 ok
This commit is contained in:
		
							parent
							
								
									707f7ea0af
								
							
						
					
					
						commit
						636a828512
					
				
							
								
								
									
										20
									
								
								day5/main.ts
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								day5/main.ts
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -140,11 +140,11 @@ const seed = {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
const x = 100;
 | 
			
		||||
const speed = 30;
 | 
			
		||||
const speed = 10;
 | 
			
		||||
let frames = 1;
 | 
			
		||||
 | 
			
		||||
cls();
 | 
			
		||||
function TIC() {
 | 
			
		||||
  cls();
 | 
			
		||||
  ++frames;
 | 
			
		||||
  const offset = 15;
 | 
			
		||||
  const lineLen = 100;
 | 
			
		||||
| 
						 | 
				
			
			@ -155,20 +155,32 @@ function TIC() {
 | 
			
		|||
    ++seed.step;
 | 
			
		||||
    if (seed.step >= steps.length) {
 | 
			
		||||
      seed.step = 0;
 | 
			
		||||
      if (++seed.index > seeds.length) {
 | 
			
		||||
      if (++seed.index >= seeds.length) {
 | 
			
		||||
        seed.index = 0;
 | 
			
		||||
      }
 | 
			
		||||
      seed.value = seeds[seed.index];
 | 
			
		||||
      trace("new seed: " + seed.value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (let x=0;x<240;++x) {
 | 
			
		||||
      for (let y=0;y<136;++y) {
 | 
			
		||||
        const c = pix(x, y)
 | 
			
		||||
        if (c >= 12) {
 | 
			
		||||
          pix(x, y, c+1);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  rect(200, 0, 50, 136, 0)
 | 
			
		||||
 | 
			
		||||
  for (const [i, step] of steps.entries()) {
 | 
			
		||||
    print(step.name, 1, y, i + 2);
 | 
			
		||||
    line(100, y + 2, x + lineLen, y + 2, i + 2);
 | 
			
		||||
    y += offset;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  const yOffset = ((frames % speed) / speed) * 12;
 | 
			
		||||
  circ(seed.value + x, seed.step * offset + 2 + yOffset, 2, 12);
 | 
			
		||||
  print(seed.value, x + lineLen + 5, seed.step * offset + yOffset, 12);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										
											BIN
										
									
								
								gifs/day5.gif
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								gifs/day5.gif
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 101 KiB  | 
		Loading…
	
		Reference in New Issue
	
	Block a user