can bullets have puppet strings?
This commit is contained in:
parent
5f732e1e6f
commit
6809a3733a
9 changed files with 55 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
class_name Bullet extends Node2D
|
class_name BulletOld extends Node2D
|
||||||
|
|
||||||
@export var is_player_bullet = false
|
@export var is_player_bullet = false
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
extends Bullet
|
extends BulletOld
|
||||||
|
|
||||||
var speed = Vector2.ZERO
|
var speed = Vector2.ZERO
|
||||||
var bullet_speed = 2
|
var bullet_speed = 2
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://bgoqv662xuf1r"]
|
[gd_scene load_steps=4 format=3 uid="uid://bgoqv662xuf1r"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b84vrx30l3hei" path="res://objects/player/bullet.gd" id="1_4hrp6"]
|
[ext_resource type="Script" path="res://objects/player/bullet.gd" id="1_4hrp6"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cm68ysi8ojc88" path="res://bullet.png" id="2_du4f6"]
|
[ext_resource type="Texture2D" uid="uid://cm68ysi8ojc88" path="res://bullet.png" id="2_du4f6"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_du4f6"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_du4f6"]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
@export var Bullet: PackedScene
|
@export var bullet_scene: PackedScene
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
|
|
@ -14,10 +14,10 @@ func _input(event: InputEvent) -> void:
|
||||||
func _on_timer_timeout() -> void:
|
func _on_timer_timeout() -> void:
|
||||||
$AudioStreamPlayer.play()
|
$AudioStreamPlayer.play()
|
||||||
print("yeth")
|
print("yeth")
|
||||||
var bullet = Bullet.instantiate()
|
var bullet = bullet_scene.instantiate()
|
||||||
get_owner().get_owner().add_child(bullet)
|
get_owner().get_owner().add_child(bullet)
|
||||||
bullet.global_position = $Marker2D.global_position
|
bullet.global_position = $Marker2D.global_position
|
||||||
|
|
||||||
var bullet2 = Bullet.instantiate()
|
var bullet2 = bullet_scene.instantiate()
|
||||||
get_owner().get_owner().add_child(bullet2)
|
get_owner().get_owner().add_child(bullet2)
|
||||||
bullet2.global_position = $Marker2D2.global_position
|
bullet2.global_position = $Marker2D2.global_position
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
[node name="PlayerBulletEmitter" type="Node2D"]
|
[node name="PlayerBulletEmitter" type="Node2D"]
|
||||||
script = ExtResource("1_51eej")
|
script = ExtResource("1_51eej")
|
||||||
Bullet = ExtResource("2_xytg0")
|
bullet_scene = ExtResource("2_xytg0")
|
||||||
|
|
||||||
[node name="Marker2D" type="Marker2D" parent="."]
|
[node name="Marker2D" type="Marker2D" parent="."]
|
||||||
position = Vector2(-7, -5)
|
position = Vector2(-7, -5)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://dxsp66qpvm65b"]
|
[gd_scene load_steps=5 format=3 uid="uid://dxsp66qpvm65b"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://c50bfqprpitev" path="res://icon.svg" id="1_g7g4h"]
|
[ext_resource type="Texture2D" uid="uid://c50bfqprpitev" path="res://icon.svg" id="1_g7g4h"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c714s5d7d5765" path="res://objects/player/player.tscn" id="2_j8ivh"]
|
[ext_resource type="PackedScene" uid="uid://c714s5d7d5765" path="res://objects/player/player.tscn" id="2_j8ivh"]
|
||||||
|
[ext_resource type="Script" uid="uid://ntpaank0h0a0" path="res://systems/bullets/bullet.gd" id="3_hlyn7"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://xe124f1kgf3x" path="res://graphics/bullets/normal_bullet/bullet_2.png" id="4_hlyn7"]
|
||||||
|
|
||||||
[node name="TestScene" type="Node"]
|
[node name="TestScene" type="Node"]
|
||||||
|
|
||||||
|
|
@ -11,3 +13,10 @@ texture = ExtResource("1_g7g4h")
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("2_j8ivh")]
|
[node name="Player" parent="." instance=ExtResource("2_j8ivh")]
|
||||||
position = Vector2(100, 99)
|
position = Vector2(100, 99)
|
||||||
|
|
||||||
|
[node name="Bullet" type="Area2D" parent="."]
|
||||||
|
position = Vector2(169, 130)
|
||||||
|
script = ExtResource("3_hlyn7")
|
||||||
|
texture = ExtResource("4_hlyn7")
|
||||||
|
hitbox_size = Vector2i(6, 6)
|
||||||
|
metadata/_custom_type_script = "uid://ntpaank0h0a0"
|
||||||
|
|
|
||||||
37
systems/bullets/bullet.gd
Normal file
37
systems/bullets/bullet.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
@tool
|
||||||
|
class_name Bullet
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
|
||||||
|
static var _hitbox_shapes: Dictionary[Vector2i, RectangleShape2D] = {}
|
||||||
|
|
||||||
|
|
||||||
|
@export var texture: Texture2D:
|
||||||
|
set(value):
|
||||||
|
texture = value
|
||||||
|
queue_redraw()
|
||||||
|
|
||||||
|
@export var hitbox_size: Vector2i:
|
||||||
|
set(value):
|
||||||
|
hitbox_size = value
|
||||||
|
if not _hitbox_shapes.has(hitbox_size):
|
||||||
|
var new_shape = RectangleShape2D.new()
|
||||||
|
new_shape.size = hitbox_size
|
||||||
|
_hitbox_shapes[hitbox_size] = new_shape
|
||||||
|
_hitbox.shape = _hitbox_shapes[hitbox_size]
|
||||||
|
|
||||||
|
|
||||||
|
var _hitbox: CollisionShape2D = CollisionShape2D.new()
|
||||||
|
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
_hitbox.debug_color.a = 0.0
|
||||||
|
add_child(_hitbox)
|
||||||
|
|
||||||
|
|
||||||
|
func _draw() -> void:
|
||||||
|
draw_texture(texture, -texture.get_size() * 0.5)
|
||||||
|
|
||||||
|
|
||||||
|
func _get_configuration_warnings() -> PackedStringArray:
|
||||||
|
return []
|
||||||
1
systems/bullets/bullet.gd.uid
Normal file
1
systems/bullets/bullet.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://ntpaank0h0a0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue