Main.gd 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. extends Spatial
  2. # Declare member variables here. Examples:
  3. # var a = 2
  4. # var b = "text"
  5. #var tileGenScene = preload("res://TileGenerator.tscn")
  6. var Chunk = preload("res://chunk.tscn")
  7. var minlat = 0
  8. var maxlat = 10
  9. var minlon = 0
  10. var maxlon = 10
  11. var steplat = 1
  12. var steplon = 1
  13. var resolution = 256
  14. var radius = 1737.4
  15. var curlat = 0
  16. var curlon = 0
  17. func _ready():
  18. Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
  19. curlat = minlat*steplat
  20. curlon = minlon*steplon
  21. func _input(event):
  22. if event.is_action_pressed("ui_cancel"):
  23. Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
  24. if event.is_action_pressed("click"):
  25. if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE:
  26. Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
  27. get_tree().set_input_as_handled()
  28. func _process(delta):
  29. if curlat < maxlat*steplat:
  30. if curlon < maxlon*steplon:
  31. var chunk = Chunk.instance()
  32. chunk.setParams(curlat,curlat+steplat,curlon,curlon+steplon,resolution,radius)
  33. #moontile.scale=Vector3(1000,1000,1000)
  34. $Tiles.add_child(chunk)
  35. .get_node("UI/3").text="lastLatLon="+str(curlat)+":"+str(curlon)
  36. curlon += steplon
  37. else:
  38. curlat +=steplat
  39. curlon = 0
  40. if curlat >= maxlat:
  41. print("loading complete")
  42. # Called every frame. 'delta' is the elapsed time since the previous frame.
  43. #func _process(delta):
  44. # pass