Added bullet indexing to create shot patterns

This commit is contained in:
Henry Faber 2026-06-13 12:05:13 +01:00
parent bdbc3b015f
commit 1725b8b754
13 changed files with 91 additions and 27 deletions

3
scenes/game.gd Normal file
View file

@ -0,0 +1,3 @@
extends Node2D
@onready var screensize = get_viewport().content_scale_size

1
scenes/game.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://dkti4uwycpqrs

View file

@ -1,9 +1,11 @@
[gd_scene format=3 uid="uid://dqd8cxe7aj3b4"]
[ext_resource type="Script" uid="uid://dkti4uwycpqrs" path="res://scenes/game.gd" id="1_lnu2h"]
[ext_resource type="PackedScene" uid="uid://bj4fytc3sy482" path="res://scenes/world.tscn" id="1_uwrxv"]
[ext_resource type="Texture2D" uid="uid://egqbrm636m4h" path="res://graphics/title.png" id="2_yqjtg"]
[node name="Game" type="Node2D" unique_id=1673976895]
script = ExtResource("1_lnu2h")
[node name="World" parent="." unique_id=1317852169 instance=ExtResource("1_uwrxv")]

View file

@ -6,15 +6,23 @@ class_name Player extends Area2D
@onready var shoot_component: ShootComponent = %ShootComponent
@onready var weapon_component: WeaponComponent = %WeaponComponent
# Get the viewport size for positioning
@onready var screensize = get_viewport().content_scale_size
# Variables for Player shooting status
@export var can_shoot: bool = true
@export var is_shooting: bool = false
@export var muzzle_flash: bool = false
# Variables for Player position calculations for equidistant bullets
var previous_position: Vector2
var ship_displacement: float
var travel: float = 0
func _ready() -> void:
## Set initial start position
position = Vector2(screensize.x / 2, screensize.y - 45)
func _process(delta) -> void:
@ -28,6 +36,12 @@ func _process(delta) -> void:
if is_shooting == true:
shoot_component.shoot()
$%MuzzleFlash.show()
if is_shooting == false:
$%MuzzleFlash.hide()
# Read Movement Component
movement_component.input = input_component.move_dir

View file

@ -90,6 +90,9 @@ size = Vector2(6, 5.75)
[node name="Player" type="Area2D" unique_id=652131079]
script = ExtResource("1_ur7pv")
can_shoot = null
is_shooting = null
muzzle_flash = null
[node name="Ship" type="Sprite2D" parent="." unique_id=1155866924]
unique_name_in_owner = true

20
scenes/weapon_stock.gd Normal file
View file

@ -0,0 +1,20 @@
extends Area2D
@onready var bullet: PackedScene = load("res://scenes/weapon_stock.tscn")
@onready var shot_data: = load("res://resources/player_weapons/weapon_shot_stock.tres")
# Time offset when this bullet was fired (relative to other bullets)
var time_offset: float = 0.5
#func activate():
# Bullet does its damage/projectile work
func _process(delta):
#Calculation position along Y axis
position.y -= shot_data.speed * delta # Original Speed
#position.y -= 330 * delta # non-shot_data testing
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
queue_free()

View file

@ -0,0 +1 @@
uid://c5blhfopjpfny

View file

@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://ddpclu2vdy2ve"]
[ext_resource type="Script" uid="uid://d1rwqotmrag1r" path="res://Deprecated/stock_weapon.gd" id="1_u1d5o"]
[ext_resource type="Script" uid="uid://c5blhfopjpfny" path="res://scenes/weapon_stock.gd" id="1_u1d5o"]
[ext_resource type="Texture2D" uid="uid://ti1uy42vnnhw" path="res://graphics/shot.png" id="2_5bykt"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"]