mirror of
				https://github.com/flynx/Slang.git
				synced 2025-10-31 03:20:09 +00:00 
			
		
		
		
	some tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									4db1c6254a
								
							
						
					
					
						commit
						6a99c057f8
					
				| @ -204,6 +204,7 @@ var Snake = { | |||||||
| 		var x = point.x | 		var x = point.x | ||||||
| 		var y = point.y | 		var y = point.y | ||||||
| 		length = length || 1 | 		length = length || 1 | ||||||
|  | 
 | ||||||
| 		while(length > 0){ | 		while(length > 0){ | ||||||
| 			this._cells[x + y * this.field_size.width] | 			this._cells[x + y * this.field_size.width] | ||||||
| 				.style.backgroundColor = this.config.wall_color | 				.style.backgroundColor = this.config.wall_color | ||||||
| @ -218,9 +219,9 @@ var Snake = { | |||||||
| 				: 0 | 				: 0 | ||||||
| 			y = y < 0 ? this.field_size.height + y | 			y = y < 0 ? this.field_size.height + y | ||||||
| 				: y % this.field_size.height | 				: y % this.field_size.height | ||||||
| 
 |  | ||||||
| 			length -= 1 | 			length -= 1 | ||||||
| 		} | 		} | ||||||
|  | 
 | ||||||
| 		return this | 		return this | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| @ -271,11 +272,15 @@ var Snake = { | |||||||
| 
 | 
 | ||||||
| var HANDLER_SET = false | var HANDLER_SET = false | ||||||
| var KEY_CONFIG = { | var KEY_CONFIG = { | ||||||
|  | 	' ': ['pause'], | ||||||
| 	ArrowLeft: ['left'], | 	ArrowLeft: ['left'], | ||||||
| 	ArrowRight: ['right'],  | 	ArrowRight: ['right'],  | ||||||
| 	' ': ['pause'], | 	// IE compatibility... | ||||||
|  | 	Left: ['left'], | ||||||
|  | 	Right: ['right'], | ||||||
| } | } | ||||||
| function kbHandler(event){ | function kbHandler(event){ | ||||||
|  | 	console.log('KEY:', event.key) | ||||||
| 	var action = KEY_CONFIG[event.key] | 	var action = KEY_CONFIG[event.key] | ||||||
| 	action  | 	action  | ||||||
| 		&& action[0] in Snake  | 		&& action[0] in Snake  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user