chunk class was missing set_tileset() ...
This commit is contained in:
parent
abbaa6f450
commit
fccef57210
7 changed files with 39 additions and 50 deletions
|
@ -7,18 +7,18 @@ var y:int = -1
|
|||
# Called when the node enters the scene tree for the first time.
|
||||
func _init(xpos:int, ypos:int):
|
||||
self.x = xpos
|
||||
self.y = ypos
|
||||
|
||||
func _draw():
|
||||
draw_circle(Vector2(x,y), 25.0, Color(0,0,0))
|
||||
self.y = ypos
|
||||
self.name = "Chunk [%d,%d]" % [x, y]
|
||||
self.set_tileset(Globals.TILESET_TERRAIN)
|
||||
self.position = Vector2i(
|
||||
x*Globals.CHUNK_SIZE*Globals.TILE_SIZE_X,
|
||||
y*Globals.CHUNK_SIZE*Globals.TILE_SIZE_Y
|
||||
)
|
||||
|
||||
func generate_chunk() -> void:
|
||||
for row in Globals.CHUNK_SIZE:
|
||||
for col in Globals.CHUNK_SIZE:
|
||||
var tile_data: Array = Globals.map_tile_data[row+y*Globals.CHUNK_SIZE][col+x*Globals.CHUNK_SIZE]
|
||||
#var msg = "%s %s %s"
|
||||
#print(msg % [tile_data, row, col])
|
||||
|
||||
var tile_data: Array = Globals.map_tile_data[row+y*Globals.CHUNK_SIZE][col+x*Globals.CHUNK_SIZE]
|
||||
# layer | tile coords at tilemap | tilemap id | coords of the tile at tileset | alternative tile
|
||||
self.set_cell(
|
||||
Globals.LAYER_TERRAIN,
|
||||
|
|
|
@ -6,4 +6,5 @@
|
|||
[node name="Chunk" type="TileMap"]
|
||||
tile_set = ExtResource("1_x70ay")
|
||||
format = 2
|
||||
layer_0/tile_data = PackedInt32Array(0, 0, 65536, -1, 0, 65536)
|
||||
script = ExtResource("1_lawsj")
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://nfayf78xiuap"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://nfayf78xiuap"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Main.gd" id="1_ysxum"]
|
||||
[ext_resource type="Script" path="res://scripts/ChunkHandler.gd" id="2_2e0t1"]
|
||||
[ext_resource type="Script" path="res://scripts/Control.gd" id="3_1t1c8"]
|
||||
[ext_resource type="Texture2D" uid="uid://cxn2fno1j7vf5" path="res://icon.svg" id="3_c64oi"]
|
||||
[ext_resource type="PackedScene" uid="uid://2we3txfr812u" path="res://scenes/Camera_zoom_2d.tscn" id="4_rx82t"]
|
||||
[ext_resource type="Script" path="res://scripts/EntityPlacer.gd" id="5_8jju5"]
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
script = ExtResource("1_ysxum")
|
||||
|
||||
[node name="ChunkHandler" type="Node2D" parent="."]
|
||||
script = ExtResource("2_2e0t1")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="ChunkHandler"]
|
||||
position = Vector2(952, 536)
|
||||
texture = ExtResource("3_c64oi")
|
||||
|
||||
[node name="EntityPlacer" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue