mirror of
				https://github.com/flynx/Slang.git
				synced 2025-10-31 19:40:10 +00:00 
			
		
		
		
	seems to be done...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									03ebf5f301
								
							
						
					
					
						commit
						81032e48d0
					
				| @ -19,7 +19,10 @@ | |||||||
| // XXX automate clearing of handlers... | // XXX automate clearing of handlers... | ||||||
| function makeEvent(handler_attr){ | function makeEvent(handler_attr){ | ||||||
| 	return function(func){ | 	return function(func){ | ||||||
| 		if(func instanceof Function){ | 		if(func === null){ | ||||||
|  | 			delete this[handler_attr] | ||||||
|  | 
 | ||||||
|  | 		} else if(func instanceof Function){ | ||||||
| 			var handlers = this[handler_attr] = this[handler_attr] || [] | 			var handlers = this[handler_attr] = this[handler_attr] || [] | ||||||
| 			handlers.push(func) | 			handlers.push(func) | ||||||
| 
 | 
 | ||||||
| @ -250,16 +253,8 @@ var Snake = { | |||||||
| 		} | 		} | ||||||
| 		this.players = {} | 		this.players = {} | ||||||
| 		return this | 		return this | ||||||
| 	}, | 			.appleEaten(null) | ||||||
| 	clear: function(){ | 			.snakeKilled(null) | ||||||
| 		// this resets the cell object attrs... |  | ||||||
| 		this.setup() |  | ||||||
| 		// reset the actual cells... |  | ||||||
| 		//this._cells.forEach(function(c){ c.style.backgroundColor = '' })  |  | ||||||
| 		this.players = {} |  | ||||||
| 		delete this.__appleEatenHandlers |  | ||||||
| 		delete this.__killHandlers |  | ||||||
| 		return this |  | ||||||
| 	}, | 	}, | ||||||
| 	start: function(t){ | 	start: function(t){ | ||||||
| 		this.__timer = this.__timer  | 		this.__timer = this.__timer  | ||||||
| @ -320,7 +315,14 @@ function kbHandler(event){ | |||||||
| 		&& Snake[action[0]].apply(Snake, action.slice(1)) | 		&& Snake[action[0]].apply(Snake, action.slice(1)) | ||||||
| } | } | ||||||
| function tapHandler(event){ | function tapHandler(event){ | ||||||
| 	(event.clientX || event.changedTouches[0].pageX) <= (document.body.clientWidth / 2) ?  | 	// top of screen... | ||||||
|  | 	(event.clientY || event.changedTouches[0].pageY) <= (document.body.clientHeight / 8) ?  | ||||||
|  | 		setup() | ||||||
|  | 	// bottom of screen... | ||||||
|  | 	: (event.clientY || event.changedTouches[0].pageY) >= (document.body.clientHeight / 5)*4 ?  | ||||||
|  | 		Snake.pause() | ||||||
|  | 	// left/right of screen... | ||||||
|  | 	: (event.clientX || event.changedTouches[0].pageX) <= (document.body.clientWidth / 2) ?  | ||||||
| 		Snake.left()  | 		Snake.left()  | ||||||
| 		: Snake.right() } | 		: Snake.right() } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user