Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Node2D
- var blacklist = []
- func _ready():
- pass
- func _input(event):
- if event is InputEventKey:
- if event.is_pressed():
- if not(event.scancode in blacklist):
- if event.scancode == KEY_SPACE:
- spawn_echofox_sfx()
- else:
- spawn_fox_sfx()
- blacklist.append(event.scancode)
- else:
- blacklist.erase(event.scancode)
- func spawn_fox_sfx() -> void:
- var fox = load("res://Prefabs/fox.tscn").instance()
- add_child(fox)
- var shape = load("res://Prefabs/shape.tscn").instance()
- shape.position = get_location_on_screen_boundary()
- add_child(shape)
- func spawn_echofox_sfx() -> void:
- var fox = load("res://Prefabs/echofox.tscn").instance()
- add_child(fox)
- # FUCK YOU.
- func get_location_on_screen_boundary() -> Vector2:
- var location = Vector2(0, 0)
- var locked_axis = "x" if (randi()%2 == 0) else "y"
- if locked_axis == "x":
- location.x = 0 if (randi()%2 == 0) else get_viewport_rect().size.x
- location.y = randf() * get_viewport_rect().size.y
- if locked_axis == "y":
- location.x = randf() * get_viewport_rect().size.x
- location.y = 0 if (randi()%2 == 0) else get_viewport_rect().size.y
- return location
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement