From d9350f3f6de233610843c02f6f20674bdcc219c6 Mon Sep 17 00:00:00 2001 From: Joseph Manley Date: Sun, 3 Nov 2019 20:31:05 -0500 Subject: [PATCH] Fix collision generation issues --- Nodes/Game.tscn | 1 + Nodes/Pickup.gd | 8 ++++++++ Nodes/Pickup.tscn | 10 ++++++---- Scripts/BaddieManager.gd | 6 +++++- 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 Nodes/Pickup.gd diff --git a/Nodes/Game.tscn b/Nodes/Game.tscn index f8326ff..315601c 100644 --- a/Nodes/Game.tscn +++ b/Nodes/Game.tscn @@ -51,6 +51,7 @@ func _process(delta): script = ExtResource( 1 ) [node name="LoadingScreen" type="CanvasLayer" parent="."] +editor/display_folded = true script = SubResource( 1 ) [node name="ColorRect" type="ColorRect" parent="LoadingScreen"] diff --git a/Nodes/Pickup.gd b/Nodes/Pickup.gd new file mode 100644 index 0000000..cabcd3e --- /dev/null +++ b/Nodes/Pickup.gd @@ -0,0 +1,8 @@ +extends Node2D + +var tileMap +func _ready(): + var tileMap = get_node("/root/World/TileMap") + var tilePos = tileMap.world_to_map(position) + if(tileMap.get_cell(tilePos.x, tilePos.y) != 0): + queue_free() \ No newline at end of file diff --git a/Nodes/Pickup.tscn b/Nodes/Pickup.tscn index 59c5015..e22e2f5 100644 --- a/Nodes/Pickup.tscn +++ b/Nodes/Pickup.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] -[ext_resource path="res://Art/pickup1.png" type="Texture" id=1] -[ext_resource path="res://Art/pickup2.png" type="Texture" id=2] +[ext_resource path="res://Nodes/Pickup.gd" type="Script" id=1] +[ext_resource path="res://Art/pickup1.png" type="Texture" id=2] +[ext_resource path="res://Art/pickup2.png" type="Texture" id=3] [sub_resource type="GDScript" id=1] script/source = "extends Area2D @@ -19,13 +20,14 @@ extents = Vector2( 6, 6 ) [sub_resource type="SpriteFrames" id=3] animations = [ { -"frames": [ ExtResource( 1 ), ExtResource( 2 ) ], +"frames": [ ExtResource( 2 ), ExtResource( 3 ) ], "loop": true, "name": "default", "speed": 10.0 } ] [node name="Pickup" type="Node2D"] +script = ExtResource( 1 ) [node name="Area2D" type="Area2D" parent="."] gravity = 0.0 diff --git a/Scripts/BaddieManager.gd b/Scripts/BaddieManager.gd index 173fe31..6952f94 100644 --- a/Scripts/BaddieManager.gd +++ b/Scripts/BaddieManager.gd @@ -3,8 +3,12 @@ extends Node2D export var HP = 8 export var color = "ffff00" +var tileMap func _ready(): - pass + var tileMap = get_node("/root/World/TileMap") + var tilePos = tileMap.world_to_map(position) + if(tileMap.get_cell(tilePos.x, tilePos.y) != 0): + queue_free() func take_damage(dmg): playAudio("Bomb_Drop.wav")