Main.gd 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 = 20
  8. var maxlat = 26
  9. var minlon = 308
  10. var maxlon = 313
  11. var steplat = 1
  12. var steplon = 1
  13. var resolution = 512
  14. var radius = 1737.4#*1000
  15. var startPos = Vector3(20,308,radius)
  16. var curlat = 0
  17. var curlon = 0
  18. func _ready():
  19. Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
  20. curlat = minlat*steplat
  21. curlon = minlon*steplon
  22. get_node("Player").moveTo(startPos)
  23. func _input(event):
  24. if event.is_action_pressed("ui_cancel"):
  25. Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
  26. if event.is_action_pressed("click"):
  27. if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE:
  28. Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
  29. get_tree().set_input_as_handled()
  30. func _process(delta):
  31. if curlat < maxlat*steplat:
  32. if curlon < maxlon*steplon:
  33. call_deferred("add_chunk", curlon, curlat)
  34. curlon += steplon
  35. else:
  36. curlat +=steplat
  37. curlon = 0
  38. if curlat >= maxlat:
  39. print("loading complete")
  40. func add_chunk(curlon, curlat):
  41. var chunk = Chunk.instance()
  42. chunk.setParams(curlat,curlat+steplat,curlon,curlon+steplon,resolution,radius)
  43. #moontile.scale=Vector3(1000,1000,1000)
  44. $Chunks.add_child(chunk)
  45. .get_node("UI/3").text="lastLatLon="+str(curlat)+":"+str(curlon)
  46. # Called every frame. 'delta' is the elapsed time since the previous frame.
  47. #func _process(delta):
  48. # pass