Adds android web support
							parent
							
								
									8695929012
								
							
						
					
					
						commit
						c35e3cbb20
					
				| 
						 | 
					@ -15,9 +15,9 @@ var buffered_direction : Vector2 = Vector2.ZERO
 | 
				
			||||||
var should_buffer_direction : bool = false
 | 
					var should_buffer_direction : bool = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var inputs : Dictionary[String, Vector2] = {"right": Vector2.RIGHT,
 | 
					var inputs : Dictionary[String, Vector2] = {"right": Vector2.RIGHT,
 | 
				
			||||||
 | 
																"down": Vector2.DOWN,
 | 
				
			||||||
											"left": Vector2.LEFT,
 | 
																"left": Vector2.LEFT,
 | 
				
			||||||
											"up": Vector2.UP,
 | 
																"up": Vector2.UP,}
 | 
				
			||||||
											"down": Vector2.DOWN}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
var possible_x : Array
 | 
					var possible_x : Array
 | 
				
			||||||
var possible_y : Array
 | 
					var possible_y : Array
 | 
				
			||||||
| 
						 | 
					@ -58,6 +58,10 @@ var commanding_head : SnakePart = null
 | 
				
			||||||
var skip_next_move_propagation : bool = false
 | 
					var skip_next_move_propagation : bool = false
 | 
				
			||||||
var queued_growth : int = 0
 | 
					var queued_growth : int = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var screen_touching : bool = false
 | 
				
			||||||
 | 
					var screen_start_pos : Vector2 = Vector2.ZERO
 | 
				
			||||||
 | 
					var screen_tracking_index : int = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signal on_movement(new_dir, prevent_move)
 | 
					signal on_movement(new_dir, prevent_move)
 | 
				
			||||||
signal on_death
 | 
					signal on_death
 | 
				
			||||||
signal on_ouroboros
 | 
					signal on_ouroboros
 | 
				
			||||||
| 
						 | 
					@ -406,12 +410,32 @@ func _unhandled_input(event: InputEvent) -> void:
 | 
				
			||||||
	# Change direction if we are the head
 | 
						# Change direction if we are the head
 | 
				
			||||||
	if event is InputEventKey and part_type == PartTypes.HEAD:
 | 
						if event is InputEventKey and part_type == PartTypes.HEAD:
 | 
				
			||||||
		for dir in inputs.keys():
 | 
							for dir in inputs.keys():
 | 
				
			||||||
			if event.is_action_pressed(dir) and current_direction != -inputs[dir]:
 | 
								if event.is_action_pressed(dir) and current_direction != -inputs[dir] and current_direction != inputs[dir]:
 | 
				
			||||||
				if should_buffer_direction:
 | 
									if should_buffer_direction:
 | 
				
			||||||
					buffered_direction = inputs[dir]
 | 
										buffered_direction = inputs[dir]
 | 
				
			||||||
				else:
 | 
									else:
 | 
				
			||||||
					current_direction = inputs[dir]
 | 
										current_direction = inputs[dir]
 | 
				
			||||||
					should_buffer_direction = true
 | 
										should_buffer_direction = true
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if event is InputEventScreenTouch and part_type == PartTypes.HEAD:# Start of drag
 | 
				
			||||||
 | 
							if event.is_pressed() and !screen_touching:
 | 
				
			||||||
 | 
								screen_start_pos = event.position
 | 
				
			||||||
 | 
								screen_tracking_index = event.index
 | 
				
			||||||
 | 
								screen_touching = true
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
							# End of drag
 | 
				
			||||||
 | 
							elif !event.is_pressed() and screen_touching and event.index == screen_tracking_index:
 | 
				
			||||||
 | 
								screen_touching = false
 | 
				
			||||||
 | 
								var drag_angle : float = (event.position - screen_start_pos).angle()
 | 
				
			||||||
 | 
								var idx_direction : int = roundi(drag_angle / (PI / 2))
 | 
				
			||||||
 | 
								var dir : String = inputs.keys()[idx_direction]
 | 
				
			||||||
 | 
								if current_direction != -inputs[dir] and current_direction != inputs[dir]:
 | 
				
			||||||
 | 
									if should_buffer_direction:
 | 
				
			||||||
 | 
										buffered_direction = inputs[dir]
 | 
				
			||||||
 | 
									else:
 | 
				
			||||||
 | 
										current_direction = inputs[dir]
 | 
				
			||||||
 | 
										should_buffer_direction = true
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# If we leave the arena
 | 
					# If we leave the arena
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue