Main.gd 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 = 1
  9. var minlon = 0
  10. var maxlon = 1
  11. var steplat = 1
  12. var steplon = 1
  13. var resolution = 512
  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. call_deferred("add_chunk", curlon, curlat)
  32. curlon += steplon
  33. else:
  34. curlat +=steplat
  35. curlon = 0
  36. if curlat >= maxlat:
  37. print("loading complete")
  38. func add_chunk(curlon, curlat):
  39. var chunk = Chunk.instance()
  40. chunk.setParams(curlat,curlat+steplat,curlon,curlon+steplon,resolution,radius)
  41. #moontile.scale=Vector3(1000,1000,1000)
  42. $Tiles.add_child(chunk)
  43. .get_node("UI/3").text="lastLatLon="+str(curlat)+":"+str(curlon)
  44. # Called every frame. 'delta' is the elapsed time since the previous frame.
  45. #func _process(delta):
  46. # pass