From 21946a995e26ac0cdacb9cf03d7834f0eea24086 Mon Sep 17 00:00:00 2001 From: fredrikr79 Date: Sat, 4 Oct 2025 19:31:54 +0200 Subject: [PATCH] cursor gun card inject scene --- growth/CardInjects/CursorGunCardInject.tscn | 6 +++++ growth/CardInjects/cursor_gun_card_inject.gd | 25 +++++++++++++++++++ .../CardInjects/cursor_gun_card_inject.gd.uid | 1 + growth/player.tscn | 1 + 4 files changed, 33 insertions(+) create mode 100644 growth/CardInjects/CursorGunCardInject.tscn create mode 100644 growth/CardInjects/cursor_gun_card_inject.gd create mode 100644 growth/CardInjects/cursor_gun_card_inject.gd.uid diff --git a/growth/CardInjects/CursorGunCardInject.tscn b/growth/CardInjects/CursorGunCardInject.tscn new file mode 100644 index 0000000..303efce --- /dev/null +++ b/growth/CardInjects/CursorGunCardInject.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://bf1241le7dwfs"] + +[ext_resource type="Script" uid="uid://c0jwjfs64x5tm" path="res://CardInjects/cursor_gun_card_inject.gd" id="1_25dn0"] + +[node name="CursorGunCardInject" type="Node"] +script = ExtResource("1_25dn0") diff --git a/growth/CardInjects/cursor_gun_card_inject.gd b/growth/CardInjects/cursor_gun_card_inject.gd new file mode 100644 index 0000000..fc99a0a --- /dev/null +++ b/growth/CardInjects/cursor_gun_card_inject.gd @@ -0,0 +1,25 @@ +extends Node + +@export var CursorBullet: PackedScene +@export var max_ammo = 10 +var ammo = 10 + +func activate(world, activator): + var target: Vector2 = activator.get_target_pos() + var bullet = CursorBullet.instantiate() + world.add_child(bullet) + bullet.position = activator.position + bullet.look_at(target) + if activator.get_collision_layer_bit(1): # player object + bullet.set_collision_layer_bit(1, false) + bullet.set_collision_layer_bit(2, true) + elif activator.get_collision_layer_bit(2): # enemy object + bullet.set_collision_layer_bit(1, true) + bullet.set_collision_layer_bit(2, false) + else: + assert(false, "who are you, activator?") + ammo -= 1 + # TODO: handle ammo for player and virus + +func discard(world, activator): + pass diff --git a/growth/CardInjects/cursor_gun_card_inject.gd.uid b/growth/CardInjects/cursor_gun_card_inject.gd.uid new file mode 100644 index 0000000..f7159e9 --- /dev/null +++ b/growth/CardInjects/cursor_gun_card_inject.gd.uid @@ -0,0 +1 @@ +uid://c0jwjfs64x5tm diff --git a/growth/player.tscn b/growth/player.tscn index b775a34..9dea5ce 100644 --- a/growth/player.tscn +++ b/growth/player.tscn @@ -25,6 +25,7 @@ metadata/_edit_group_ = true sprite_frames = SubResource("SpriteFrames_i3pqv") [node name="Area2D" type="Area2D" parent="."] +collision_layer = 2 [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] shape = SubResource("RectangleShape2D_onrkg")