clean up a bit

This commit is contained in:
zoe 2022-05-08 16:45:53 +02:00
parent 3c5bbd204e
commit 59ddadb46a
7 changed files with 39 additions and 19 deletions

View file

@ -11,7 +11,7 @@ config_version=4
[application]
config/name="routes"
run/main_scene="res://world/Main.tscn"
run/main_scene="res://world/World.tscn"
config/icon="res://icon.png"
[importer_defaults]

8
godot/world/Cam.tscn Normal file
View file

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://world/worldcam.gd" type="Script" id=1]
[node name="Worldcam" type="Camera2D"]
current = true
zoom = Vector2( 0.4, 0.4 )
script = ExtResource( 1 )

View file

@ -1,13 +1,10 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://world/worldcam.gd" type="Script" id=1]
[ext_resource path="res://world/Cam.tscn" type="PackedScene" id=1]
[ext_resource path="res://world/World.tscn" type="PackedScene" id=2]
[node name="Main" type="Node2D"]
[node name="Worldcam" type="Camera2D" parent="."]
current = true
zoom = Vector2( 0.4, 0.4 )
script = ExtResource( 1 )
[node name="Worldcam" parent="." instance=ExtResource( 1 )]
[node name="World" parent="." instance=ExtResource( 2 )]

View file

@ -4,30 +4,21 @@ onready var server = $StateServer
export var xsize = 256
export var ysize = 256
export var zsize = 16
var Tilemap = preload("res://world/Tilemap.tscn")
var tilemaps = []
export var zsize = 6
func _ready():
server.generate_world(xsize, ysize, zsize)
print(server.get_tile_at(0,0,0))
func respawn_tilemaps(amount: int):
tilemaps = []
for i in range(0, amount + 1):
var map = Tilemap.instance()
map.position.y -= i * map.cell_size.y
map.z_index = i
add_child(map)
tilemaps.push_back(map)
$Tilemaps.respawn_tilemaps(amount)
func get_tile_at(pos: Vector3) -> String:
return server.get_tile_at(int(pos.x), int(pos.y), int(pos.z))
func update_tiles(tile_positions: PoolVector3Array):
for tile in tile_positions:
tilemaps[tile.z].set_tile_graphics(Vector2(tile.x, tile.y),
$Tilemaps.tilemaps[tile.z].set_tile_graphics(Vector2(tile.x, tile.y),
get_tile_at(tile))
func _on_StateServer_request_init():

View file

@ -4,6 +4,7 @@
[ext_resource path="res://world/Tilemap.gd" type="Script" id=2]
[node name="Tilemap" type="TileMap"]
process_priority = 124
position = Vector2( -2, 0 )
mode = 1
tile_set = ExtResource( 1 )

16
godot/world/Tilemaps.gd Normal file
View file

@ -0,0 +1,16 @@
extends Node
var Tilemap = preload("res://world/Tilemap.tscn")
var tilemaps = []
func respawn_tilemaps(amount: int):
tilemaps = []
for i in range(0, amount + 1):
var map = Tilemap.instance()
map.position.y -= i * map.cell_size.y
map.z_index = i
add_child(map)
tilemaps.push_back(map)
func is_tile_in_view(pos: Vector2):
pass

View file

@ -1,12 +1,19 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://world/StateApi.gd" type="Script" id=1]
[ext_resource path="res://world/Cam.tscn" type="PackedScene" id=2]
[ext_resource path="res://native/StateServer.tscn" type="PackedScene" id=3]
[ext_resource path="res://world/Tilemaps.gd" type="Script" id=4]
[node name="World" type="Node"]
script = ExtResource( 1 )
[node name="Worldcam" parent="." instance=ExtResource( 2 )]
[node name="StateServer" parent="." instance=ExtResource( 3 )]
[node name="Tilemaps" type="Node" parent="."]
script = ExtResource( 4 )
[connection signal="changed_tiletypes" from="StateServer" to="." method="_on_StateServer_changed_tiletypes"]
[connection signal="request_init" from="StateServer" to="." method="_on_StateServer_request_init"]