From 551bbb8d36aa640bcc0ce54d02fa97f934c96944 Mon Sep 17 00:00:00 2001 From: cmod31 Date: Mon, 14 Nov 2022 17:29:07 +0100 Subject: [PATCH] now only places tiles on empty tiles --- src/Player.cs | 6 +++++- tilesets/foreground_test.tres | 33 +++------------------------------ 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/src/Player.cs b/src/Player.cs index f0e694e..6262f8b 100644 --- a/src/Player.cs +++ b/src/Player.cs @@ -22,6 +22,7 @@ public class Player : KinematicBody2D public override void _Process(float delta) { //debug the grid + int currentCellID = 1; var tilemap = GetNode("/root/Main/World/Foreground"); Vector2 coordinates = tilemap.WorldToMap(Position); if (Input.IsKeyPressed((int)KeyList.F3)) @@ -34,7 +35,10 @@ public class Player : KinematicBody2D } if (Input.IsKeyPressed((int)KeyList.F2)) { - tilemap.SetCell((int)coordinates.x, (int)coordinates.y, 1); + if(tilemap.GetCell((int)coordinates.x, (int)coordinates.y) == -1) + { + tilemap.SetCell((int)coordinates.x, (int)coordinates.y, currentCellID); //place offset coordinates += offset = build coordinates + } } } } diff --git a/tilesets/foreground_test.tres b/tilesets/foreground_test.tres index edfbebf..a4c3a30 100644 --- a/tilesets/foreground_test.tres +++ b/tilesets/foreground_test.tres @@ -1,4 +1,4 @@ -[gd_resource type="TileSet" load_steps=10 format=2] +[gd_resource type="TileSet" load_steps=7 format=2] [ext_resource path="res://assets/textures/cupcake.png" type="Texture" id=1] [ext_resource path="res://assets/textures/debugitem_one64.png" type="Texture" id=2] @@ -11,14 +11,6 @@ outlines = [ PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) ] [sub_resource type="OccluderPolygon2D" id=2] polygon = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) -[sub_resource type="ConvexPolygonShape2D" id=8] - -[sub_resource type="ConvexPolygonShape2D" id=9] -points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) - -[sub_resource type="ConvexPolygonShape2D" id=10] -points = PoolVector2Array( 64, 64, 0, 64, 0, 0, 64, 0 ) - [sub_resource type="NavigationPolygon" id=6] vertices = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) polygons = [ PoolIntArray( 0, 1, 2, 3 ) ] @@ -40,28 +32,9 @@ polygon = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) 0/navigation = SubResource( 1 ) 0/shape_offset = Vector2( 0, 0 ) 0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) -0/shape = SubResource( 8 ) 0/shape_one_way = false -0/shape_one_way_margin = 1.0 -0/shapes = [ { -"autotile_coord": Vector2( 0, 0 ), -"one_way": false, -"one_way_margin": 1.0, -"shape": SubResource( 8 ), -"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) -}, { -"autotile_coord": Vector2( 0, 0 ), -"one_way": false, -"one_way_margin": 1.0, -"shape": SubResource( 9 ), -"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) -}, { -"autotile_coord": Vector2( 0, 0 ), -"one_way": false, -"one_way_margin": 1.0, -"shape": SubResource( 10 ), -"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) -} ] +0/shape_one_way_margin = 0.0 +0/shapes = [ ] 0/z_index = 0 1/name = "debugitem_one64.png 1" 1/texture = ExtResource( 2 )