Rename var in a function (can you tell I do not want to add UI)
This commit is contained in:
		
							parent
							
								
									f8f9934833
								
							
						
					
					
						commit
						25629dd65e
					
				
							
								
								
									
										19
									
								
								walkers.js
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								walkers.js
									
									
									
									
									
								
							| @ -83,20 +83,21 @@ function update_walkers() { | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| function add_random_direction(pos) { | ||||
| // give this function a walker and it will update the walkerition by one tile
 | ||||
| function add_random_direction(walker) { | ||||
|   let rand = Math.floor(Math.random() * 4); | ||||
|   if (rand === 0) { | ||||
|     pos.row++; | ||||
|     pos.row = pos.row.mod(n_rows); | ||||
|     walker.row++; | ||||
|     walker.row = walker.row.mod(n_rows); | ||||
|   } else if (rand === 1) { | ||||
|     pos.row--; | ||||
|     pos.row = pos.row.mod(n_rows); | ||||
|     walker.row--; | ||||
|     walker.row = walker.row.mod(n_rows); | ||||
|   } else if (rand === 2) { | ||||
|     pos.col++; | ||||
|     pos.col = pos.col.mod(n_cols); | ||||
|     walker.col++; | ||||
|     walker.col = walker.col.mod(n_cols); | ||||
|   } else { | ||||
|     pos.col--; | ||||
|     pos.col = pos.col.mod(n_cols); | ||||
|     walker.col--; | ||||
|     walker.col = walker.col.mod(n_cols); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user