SHARE
TWEET

GAMEBOX 1: SOURCE CODE main.gd

a guest Sep 16th, 2019 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends Node2D
  2.  
  3. var blacklist = []
  4.  
  5. func _ready():
  6.     pass
  7.  
  8. func _input(event):
  9.     if event is InputEventKey:
  10.         if event.is_pressed():
  11.             if not(event.scancode in blacklist):
  12.                 if event.scancode == KEY_SPACE:
  13.                     spawn_echofox_sfx()
  14.                 else:
  15.                     spawn_fox_sfx()
  16.                 blacklist.append(event.scancode)
  17.         else:
  18.             blacklist.erase(event.scancode)
  19.        
  20. func spawn_fox_sfx() -> void:
  21.     var fox = load("res://Prefabs/fox.tscn").instance()
  22.     add_child(fox)
  23.    
  24.     var shape = load("res://Prefabs/shape.tscn").instance()
  25.     shape.position = get_location_on_screen_boundary()
  26.     add_child(shape)
  27.        
  28. func spawn_echofox_sfx() -> void:
  29.     var fox = load("res://Prefabs/echofox.tscn").instance()
  30.     add_child(fox)
  31.  
  32. # FUCK YOU.
  33. func get_location_on_screen_boundary() -> Vector2:
  34.    
  35.     var location = Vector2(0, 0)
  36.     var locked_axis = "x" if (randi()%2 == 0) else "y"
  37.    
  38.     if locked_axis == "x":
  39.         location.x = 0 if (randi()%2 == 0) else get_viewport_rect().size.x
  40.         location.y = randf() * get_viewport_rect().size.y
  41.     if locked_axis == "y":
  42.         location.x = randf() * get_viewport_rect().size.x
  43.         location.y = 0 if (randi()%2 == 0) else get_viewport_rect().size.y
  44.        
  45.     return location
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top