Place the chacracter in the level at startup time
Randomly select a position in the largest contiguous region of the generated level in which to place the character at startup time.
This commit is contained in:
		
							parent
							
								
									9ebdc6fbb4
								
							
						
					
					
						commit
						c06edf3cc6
					
				
					 9 changed files with 171 additions and 34 deletions
				
			
		|  | @ -92,7 +92,7 @@ generate params dims gen | |||
|   $ flip runRandT gen | ||||
|   $ generate' params dims | ||||
| 
 | ||||
| generate' :: RandomGen g => Params -> Dimensions -> CellM g s (Cells s) | ||||
| generate' :: RandomGen g => Params -> Dimensions -> CellM g s (MCells s) | ||||
| generate' params dims = do | ||||
|   cells <- randInitialize dims $ params ^. aliveStartChance | ||||
|   let steps' = params ^. steps | ||||
|  | @ -100,7 +100,7 @@ generate' params dims = do | |||
|    $ for_ [0 .. pred steps'] . const $ stepAutomata cells dims params | ||||
|   pure cells | ||||
| 
 | ||||
| stepAutomata :: forall s g. Cells s -> Dimensions -> Params -> CellM g s () | ||||
| stepAutomata :: forall s g. MCells s -> Dimensions -> Params -> CellM g s () | ||||
| stepAutomata cells dims params = do | ||||
|   origCells <- lift $ cloneMArray @_ @(STUArray s) cells | ||||
|   for_ (range ((0, 0), (dims ^. width, dims ^. height))) $ \pos -> do | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue