From 226f5d150ce9d3c13442b21dcefe4777bbac1ba9 Mon Sep 17 00:00:00 2001 From: vaporvee Date: Sun, 13 Nov 2022 01:44:28 +0100 Subject: [PATCH] added debug tile placing on grid --- src/Player.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Player.cs b/src/Player.cs index b1a0429..166453c 100644 --- a/src/Player.cs +++ b/src/Player.cs @@ -36,12 +36,17 @@ public class Player : KinematicBody2D public override async void _Process(float delta) { - //player coordinates on foregroundgrid - var coordinates = GetNode("/root/Main/World/Foreground").WorldToMap(Position); + //debug the grid + var tilemap = GetNode("/root/Main/World/Foreground"); + Vector2 coordinates = tilemap.WorldToMap(Position); if (Input.IsKeyPressed((int)KeyList.F3)) { GD.Print(coordinates); } + if (Input.IsKeyPressed((int)KeyList.F2)) + { + tilemap.SetCell((int)coordinates.x, (int)coordinates.y, 1); + } } }