Adds subtle grid to background
parent
ab7721f1fa
commit
5bb80495d1
File diff suppressed because one or more lines are too long
|
@ -33,6 +33,13 @@ func _ready() -> void:
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if !GridManager.current_allowed_spawns.is_empty() and not position in GridManager.current_allowed_spawns:
|
if !GridManager.current_allowed_spawns.is_empty() and not position in GridManager.current_allowed_spawns:
|
||||||
respawn()
|
respawn()
|
||||||
|
|
||||||
|
var obstacles : Array[Node] = get_tree().get_nodes_in_group("BlocksSpawn")
|
||||||
|
|
||||||
|
for obstacle in obstacles:
|
||||||
|
if obstacle is Area2D and not obstacle == self:
|
||||||
|
if position == obstacle.position:
|
||||||
|
respawn()
|
||||||
|
|
||||||
func respawn() -> void:
|
func respawn() -> void:
|
||||||
var possible_positions : Array[Vector2]
|
var possible_positions : Array[Vector2]
|
||||||
|
|
|
@ -54,7 +54,7 @@ var image_tail : CompressedTexture2D = preload("res://Sprites/snake_tail.png")
|
||||||
var next_part : SnakePart = null
|
var next_part : SnakePart = null
|
||||||
var commanding_head : SnakePart = null
|
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 = 999
|
||||||
|
|
||||||
signal on_movement(new_dir, prevent_move)
|
signal on_movement(new_dir, prevent_move)
|
||||||
signal on_death
|
signal on_death
|
||||||
|
@ -123,8 +123,8 @@ func generate_spawn_grid() -> Array[Vector2]:
|
||||||
var x_bounds : Vector2 = level.position.x * Vector2.ONE + Vector2(-TILE_SIZE, TILE_SIZE) * level.scale.x / 2
|
var x_bounds : Vector2 = level.position.x * Vector2.ONE + Vector2(-TILE_SIZE, TILE_SIZE) * level.scale.x / 2
|
||||||
var y_bounds : Vector2 = level.position.y * Vector2.ONE + Vector2(-TILE_SIZE, TILE_SIZE) * level.scale.y / 2
|
var y_bounds : Vector2 = level.position.y * Vector2.ONE + Vector2(-TILE_SIZE, TILE_SIZE) * level.scale.y / 2
|
||||||
|
|
||||||
var possible_x : Array = range(x_bounds.x, x_bounds.y, TILE_SIZE)
|
#var possible_x : Array = range(x_bounds.x, x_bounds.y, TILE_SIZE)
|
||||||
var possible_y : Array = range(y_bounds.x, y_bounds.y, TILE_SIZE)
|
#var possible_y : Array = range(y_bounds.x, y_bounds.y, TILE_SIZE)
|
||||||
|
|
||||||
# Flood fill all possibilities until we get an inside to use
|
# Flood fill all possibilities until we get an inside to use
|
||||||
for x in possible_x:
|
for x in possible_x:
|
||||||
|
@ -141,8 +141,8 @@ func generate_spawn_grid() -> Array[Vector2]:
|
||||||
func flood_fill(positions : Array[Vector2], new_position : Vector2, x_bounds : Vector2, y_bounds : Vector2) -> bool:
|
func flood_fill(positions : Array[Vector2], new_position : Vector2, x_bounds : Vector2, y_bounds : Vector2) -> bool:
|
||||||
var directions : Array[Vector2] = [Vector2.DOWN, Vector2.LEFT, Vector2.UP, Vector2.RIGHT]
|
var directions : Array[Vector2] = [Vector2.DOWN, Vector2.LEFT, Vector2.UP, Vector2.RIGHT]
|
||||||
|
|
||||||
var possible_x : Array = range(x_bounds.x, x_bounds.y, TILE_SIZE)
|
#var possible_x : Array = range(x_bounds.x, x_bounds.y, TILE_SIZE)
|
||||||
var possible_y : Array = range(y_bounds.x, y_bounds.y, TILE_SIZE)
|
#var possible_y : Array = range(y_bounds.x, y_bounds.y, TILE_SIZE)
|
||||||
|
|
||||||
var inside : bool = true
|
var inside : bool = true
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ func ouroboros() -> void:
|
||||||
on_ouroboros.emit()
|
on_ouroboros.emit()
|
||||||
|
|
||||||
# The head can spawn a new snake
|
# The head can spawn a new snake
|
||||||
if part_type == PartTypes.HEAD:
|
if part_type == PartTypes.HEAD and state == States.OUROBOROS:
|
||||||
GameManager.score += 1
|
GameManager.score += 1
|
||||||
remove_from_group("Head")
|
remove_from_group("Head")
|
||||||
get_tree().get_first_node_in_group("GameClockPause").start(1)
|
get_tree().get_first_node_in_group("GameClockPause").start(1)
|
||||||
|
@ -386,8 +386,8 @@ func spawn_new_snake() -> void:
|
||||||
var new_head = snake_part_obj.instantiate()
|
var new_head = snake_part_obj.instantiate()
|
||||||
new_head.position = chosen_position.snapped(Vector2.ONE * TILE_SIZE)
|
new_head.position = chosen_position.snapped(Vector2.ONE * TILE_SIZE)
|
||||||
new_head.colour_index = colour_index + 1
|
new_head.colour_index = colour_index + 1
|
||||||
get_parent().add_child(new_head)
|
|
||||||
new_head.on_ouroboros.connect(ouroboros)
|
new_head.on_ouroboros.connect(ouroboros)
|
||||||
|
get_parent().add_child(new_head)
|
||||||
|
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 218 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dr54j1cutgpf2"
|
||||||
|
path="res://.godot/imported/tile.png-484556c5e80e89276f13d51f43be63d4.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sprites/tile.png"
|
||||||
|
dest_files=["res://.godot/imported/tile.png-484556c5e80e89276f13d51f43be63d4.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
Binary file not shown.
After Width: | Height: | Size: 219 B |
Loading…
Reference in New Issue