Fix fire effect in wren
This commit is contained in:
		
							parent
							
								
									4b09e54b64
								
							
						
					
					
						commit
						45efb366f3
					
				
					 1 changed files with 21 additions and 12 deletions
				
			
		|  | @ -9,9 +9,11 @@ class Game is TIC{ | ||||||
| 
 | 
 | ||||||
| 	construct new(){ | 	construct new(){ | ||||||
| 		_t=0 | 		_t=0 | ||||||
|  | 		_width = 240 | ||||||
|  | 		_height = 136 | ||||||
| 		// Init to black | 		// Init to black | ||||||
| 		_base = List.filled(240 * 136, 0) | 		_base = List.filled(_width * _height, 0) | ||||||
| 		for (last_line in (240 * 135)...(240 * 136)) { | 		for (last_line in (_width * (_height-1))...(_width * _height)) { | ||||||
| 		  _base[last_line] = 15 | 		  _base[last_line] = 15 | ||||||
| 		} | 		} | ||||||
| 	 _random = Random.new(12345)  | 	 _random = Random.new(12345)  | ||||||
|  | @ -19,26 +21,33 @@ class Game is TIC{ | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	dofire() { | 	dofire() { | ||||||
| 		for (x in 0...240) { | 		for (x in 0..._width) { | ||||||
| 			for (y in 135..1) { | 			for (y in 0...(_height-1)) { | ||||||
| 				spreadfire(x, y) | 				spreadfire(x, y) | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	spreadfire(x, y) { | 	spreadfire(x, y) { | ||||||
| 		var rand = _random.int(2) | 		var rand = _random.int(4) // [0, 3] | ||||||
| 		var delta = rand | 		var delta = rand & 1 | ||||||
| 		var index = x + y * 240 | 		var side = -rand+1 // [-2, 1] | ||||||
| 		_base[index - 240] = _base[index] - delta | 		if (x+side < 0) { | ||||||
| 		if (_base[index - 240] < 0) { | 			side=0 | ||||||
| 			_base[index - 240] = 0 | 		} | ||||||
|  | 		if (x+side >= _width) { | ||||||
|  | 			side = 0 | ||||||
|  | 		} | ||||||
|  | 		var index = x + (y*240) | ||||||
|  | 		_base[index+side] = _base[index + _width] - delta | ||||||
|  | 		if (_base[index+side] < 0) { | ||||||
|  | 			_base[index+side] = 0 | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	TIC(){ | 	TIC(){ | ||||||
| 		for (y in 0...136) { | 		for (y in 0..._height) { | ||||||
| 			for (x in 0...240) { | 			for (x in 0..._width) { | ||||||
| 				TIC.pix(x, y, _base[x + y * 240]) | 				TIC.pix(x, y, _base[x + y * 240]) | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue