Compare commits
No commits in common. "5d2efe9983a64a6fca79d2fd7fc7d4b2f0916202" and "8d89271074b65bbd2758db19d6fa57cb4fa70fb3" have entirely different histories.
5d2efe9983
...
8d89271074
17 changed files with 11 additions and 339 deletions
|
|
@ -1,12 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="PlayerShot" format=3 uid="uid://c4c7anpgfq2po"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ccdohs4gduee5" path="res://scripts/player_shot.gd" id="1_reevt"]
|
||||
[ext_resource type="Texture2D" uid="uid://ti1uy42vnnhw" path="res://graphics/shot.png" id="2_xsuf1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_reevt")
|
||||
shot_name = "Stock"
|
||||
speed = -350
|
||||
cooldown = 0.0
|
||||
projectile_spacing = 10.0
|
||||
metadata/_custom_type_script = "uid://ccdohs4gduee5"
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
[gd_resource type="Resource" script_class="PlayerShot" format=3 uid="uid://cels8t3hqjtsu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ccdohs4gduee5" path="res://scripts/player_shot.gd" id="1_t07sl"]
|
||||
[ext_resource type="Texture2D" uid="uid://ti1uy42vnnhw" path="res://graphics/shot.png" id="2_xc6g1"]
|
||||
[ext_resource type="Script" uid="uid://ccdohs4gduee5" path="res://scripts/player_shot.gd" id="1_dpne1"]
|
||||
[ext_resource type="Texture2D" uid="uid://ti1uy42vnnhw" path="res://graphics/shot.png" id="2_fu23f"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_t07sl")
|
||||
script = ExtResource("1_dpne1")
|
||||
shot_name = "Stock"
|
||||
damage = 3
|
||||
speed = -350
|
||||
projectiles = 3
|
||||
projectiles = 1
|
||||
cooldown = 0.0
|
||||
projectile_spacing = 10.0
|
||||
metadata/_custom_type_script = "uid://ccdohs4gduee5"
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
[gd_scene format=3 uid="uid://6wq3ynesnsha"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dulfr27gg4evl" path="res://scripts/player_revision.gd" id="1_3ef36"]
|
||||
[ext_resource type="PackedScene" uid="uid://ddpclu2vdy2ve" path="res://scenes/stock_weapon.tscn" id="2_l5qtw"]
|
||||
[ext_resource type="Texture2D" uid="uid://cq4we1m1yv22s" path="res://graphics/ship.png" id="3_63g5k"]
|
||||
[ext_resource type="Script" uid="uid://dss0dbwr71y6m" path="res://scripts/input_component.gd" id="4_14jeh"]
|
||||
[ext_resource type="Texture2D" uid="uid://b0iavxi8vaxtj" path="res://graphics/ship_thrusters.png" id="4_tg2o1"]
|
||||
[ext_resource type="Texture2D" uid="uid://crmbupr3qg0j" path="res://graphics/muzzle_flash.png" id="5_ohfsq"]
|
||||
[ext_resource type="Script" uid="uid://c0rikbakpcags" path="res://scripts/movement_component.gd" id="6_l5qtw"]
|
||||
[ext_resource type="Script" uid="uid://bgd1hwindc2ui" path="res://scripts/shoot_component.gd" id="7_63g5k"]
|
||||
[ext_resource type="Script" uid="uid://ylmao2ndp22y" path="res://scripts/weapon_component.gd" id="8_ohfsq"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
|
||||
atlas = ExtResource("4_tg2o1")
|
||||
region = Rect2(28, 0, 14, 6)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fjrip"]
|
||||
atlas = ExtResource("4_tg2o1")
|
||||
region = Rect2(42, 0, 14, 6)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_smehm"]
|
||||
atlas = ExtResource("4_tg2o1")
|
||||
region = Rect2(1, 0, 14, 6)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ur7pv"]
|
||||
atlas = ExtResource("4_tg2o1")
|
||||
region = Rect2(15, 0, 14, 6)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_y4r1p"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tuyoq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fjrip")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"banked",
|
||||
"speed": 15.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_smehm")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ur7pv")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"fwd",
|
||||
"speed": 15.0
|
||||
}]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qlg0r"]
|
||||
atlas = ExtResource("5_ohfsq")
|
||||
region = Rect2(0, 0, 15, 8)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_y4r1p"]
|
||||
atlas = ExtResource("5_ohfsq")
|
||||
region = Rect2(15, 0, 15, 8)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_d2wvv"]
|
||||
atlas = ExtResource("5_ohfsq")
|
||||
region = Rect2(30, 0, 15, 8)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_3v2ag"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qlg0r")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_y4r1p")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_d2wvv")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"stock",
|
||||
"speed": 15.0
|
||||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qlg0r"]
|
||||
size = Vector2(24, 10)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tuyoq"]
|
||||
size = Vector2(24, 30)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dqkch"]
|
||||
size = Vector2(6, 5.75)
|
||||
|
||||
[node name="Player" type="Area2D" unique_id=652131079]
|
||||
script = ExtResource("1_3ef36")
|
||||
|
||||
[node name="Ship" type="Sprite2D" parent="." unique_id=1155866924]
|
||||
unique_name_in_owner = true
|
||||
texture = ExtResource("3_63g5k")
|
||||
hframes = 3
|
||||
region_rect = Rect2(0, 0, 62, 24.370766)
|
||||
|
||||
[node name="Thrusters" type="AnimatedSprite2D" parent="Ship" unique_id=2096876587]
|
||||
position = Vector2(0, 15)
|
||||
sprite_frames = SubResource("SpriteFrames_y4r1p")
|
||||
animation = &"fwd"
|
||||
autoplay = "fwd"
|
||||
|
||||
[node name="MuzzleFlash" type="AnimatedSprite2D" parent="Ship" unique_id=1584132038]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
position = Vector2(0.5, -16)
|
||||
sprite_frames = SubResource("SpriteFrames_3v2ag")
|
||||
animation = &"stock"
|
||||
autoplay = "stock"
|
||||
|
||||
[node name="MuzzleBox" type="CollisionShape2D" parent="." unique_id=1042837273]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2(0, -17)
|
||||
shape = SubResource("RectangleShape2D_qlg0r")
|
||||
disabled = true
|
||||
debug_color = Color(1, 0.5058824, 0.21960784, 0.41960785)
|
||||
|
||||
[node name="HelpBox" type="CollisionShape2D" parent="." unique_id=938667427]
|
||||
position = Vector2(0, 3)
|
||||
shape = SubResource("RectangleShape2D_tuyoq")
|
||||
debug_color = Color(0, 1, 0, 0.41960785)
|
||||
|
||||
[node name="HitBox" type="CollisionShape2D" parent="." unique_id=485826453]
|
||||
position = Vector2(0, 2)
|
||||
shape = SubResource("RectangleShape2D_dqkch")
|
||||
debug_color = Color(0.9843137, 0, 0, 0.80784315)
|
||||
|
||||
[node name="WeaponCooldown" type="Timer" parent="." unique_id=269678170]
|
||||
|
||||
[node name="InputComponent" type="Node" parent="." unique_id=2022056363]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("4_14jeh")
|
||||
metadata/_custom_type_script = "uid://dss0dbwr71y6m"
|
||||
|
||||
[node name="MovementComponent" type="Node" parent="." unique_id=964075256 node_paths=PackedStringArray("player")]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("6_l5qtw")
|
||||
player = NodePath("..")
|
||||
metadata/_custom_type_script = "uid://c0rikbakpcags"
|
||||
|
||||
[node name="ShootComponent" type="Node" parent="." unique_id=623642425]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("7_63g5k")
|
||||
metadata/_custom_type_script = "uid://bgd1hwindc2ui"
|
||||
|
||||
[node name="WeaponComponent" type="Node" parent="." unique_id=1648685183]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("8_ohfsq")
|
||||
weapon_current = ExtResource("2_l5qtw")
|
||||
metadata/_custom_type_script = "uid://ylmao2ndp22y"
|
||||
|
||||
[connection signal="timeout" from="WeaponCooldown" to="." method="_on_weapon_cooldown_timeout"]
|
||||
|
|
@ -1,24 +1,15 @@
|
|||
[gd_scene format=3 uid="uid://ddpclu2vdy2ve"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1rwqotmrag1r" path="res://scripts/stock_weapon.gd" id="1_hsma2"]
|
||||
[ext_resource type="Script" uid="uid://ccdohs4gduee5" path="res://scripts/player_shot.gd" id="2_mvdrj"]
|
||||
[ext_resource type="Resource" uid="uid://cels8t3hqjtsu" path="res://resources/shot_stock.tres" id="2_ckjv1"]
|
||||
[ext_resource type="Texture2D" uid="uid://ti1uy42vnnhw" path="res://graphics/shot.png" id="3_mvdrj"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pax02"]
|
||||
script = ExtResource("2_mvdrj")
|
||||
shot_name = "Stock"
|
||||
damage = 3
|
||||
speed = -350
|
||||
projectiles = 1
|
||||
cooldown = 0.0
|
||||
metadata/_custom_type_script = "uid://ccdohs4gduee5"
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"]
|
||||
size = Vector2(6, 14)
|
||||
|
||||
[node name="StockWeapon" type="Area2D" unique_id=1832200900]
|
||||
script = ExtResource("1_hsma2")
|
||||
shot_data = SubResource("Resource_pax02")
|
||||
shot_data = ExtResource("2_ckjv1")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=2134507225]
|
||||
texture = ExtResource("3_mvdrj")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene format=3 uid="uid://b2ltmeb14nc17"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1rwqotmrag1r" path="res://scripts/stock_weapon.gd" id="1_kx6bj"]
|
||||
[ext_resource type="Resource" uid="uid://cels8t3hqjtsu" path="res://resources/player_weapons/shot_stock.tres" id="2_hefae"]
|
||||
[ext_resource type="Resource" uid="uid://cels8t3hqjtsu" path="res://resources/shot_stock.tres" id="2_hefae"]
|
||||
[ext_resource type="Texture2D" uid="uid://ti1uy42vnnhw" path="res://graphics/shot.png" id="3_58qml"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"]
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
class_name InputComponent extends Node
|
||||
|
||||
var move_dir: Vector2 = Vector2.ZERO
|
||||
var shoot_pressed: bool = false
|
||||
var shooting: bool = false
|
||||
|
||||
|
||||
func update() -> void:
|
||||
move_dir = Input.get_vector("left", "right", "up", "down")
|
||||
shoot_pressed = Input.is_action_just_pressed("shoot")
|
||||
shooting = Input.is_action_pressed("shoot")
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://dss0dbwr71y6m
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
class_name MovementComponent extends Node
|
||||
|
||||
@export var player: Area2D
|
||||
@export var speed: float = 275
|
||||
@export var bounds_x: int = 12
|
||||
@export var bounds_y: int = 12
|
||||
|
||||
@onready var weapon_component: WeaponComponent = %WeaponComponent
|
||||
|
||||
|
||||
@onready var screensize = get_viewport().content_scale_size
|
||||
|
||||
var input = Input.get_vector("left", "right", "up","down")
|
||||
|
||||
func tick(delta: float):
|
||||
# Check to see if there's a player to move
|
||||
if player == null: return
|
||||
|
||||
# Calculate ship to bullet displacemnt
|
||||
player.ship_displacement = player.position.y - player.previous_position.y
|
||||
player.travel += abs(weapon_component.bullet_data.speed) * delta + (player.ship_displacement)
|
||||
player.travel = clamp(player.travel, 0, 1.9 * weapon_component.bullet_data.projectile_spacing)
|
||||
|
||||
# Thruster animation in relation to player movement
|
||||
if input.x > 0:
|
||||
player.position.x = player.position.x+1
|
||||
%Ship.frame = 2
|
||||
%Ship/Thrusters.flip_h = true
|
||||
%Ship/Thrusters.animation = "banked"
|
||||
elif input.x < 0:
|
||||
player.position.x = player.position.x-1
|
||||
%Ship.frame = 1
|
||||
%Ship/Thrusters.flip_h = false
|
||||
%Ship/Thrusters.animation = "banked"
|
||||
else:
|
||||
%Ship.frame = 0
|
||||
player.position.x = player.position.x
|
||||
%Ship/Thrusters.flip_h = false
|
||||
%Ship/Thrusters.animation = "fwd"
|
||||
|
||||
# Get previous positon for equidistant bullet calculation
|
||||
player.previous_position = player.position
|
||||
|
||||
# Move player within screenbounds
|
||||
player.position += input * speed * delta
|
||||
player.position = player.position.clamp(Vector2i(bounds_x,bounds_y), screensize - Vector2i(bounds_x,bounds_y))
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://c0rikbakpcags
|
||||
|
|
@ -87,7 +87,7 @@ func _on_weapon_cooldown_timeout() -> void:
|
|||
|
||||
|
||||
func shoot():
|
||||
var projectiles: int = 3
|
||||
var projectiles: int = 4
|
||||
const PROJECTILE_SPACING: float = 10
|
||||
const MUZZLE_HEIGHT: int = -23
|
||||
for b in projectiles:
|
||||
|
|
@ -99,7 +99,7 @@ func shoot():
|
|||
|
||||
# Get weapon speed and spacing for equidistant calculations
|
||||
weapon_rate = bullet.shot_data.rate
|
||||
weapon_spacing = bullet.shot_data.projectile_spacing
|
||||
weapon_spacing = bullet.shot_data.spacing
|
||||
bullet_speed = abs(bullet.shot_data.speed)
|
||||
|
||||
# Print which weapon is firing
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
class_name Player extends Area2D
|
||||
|
||||
@onready var input_component: InputComponent = %InputComponent
|
||||
@onready var movement_component: MovementComponent = %MovementComponent
|
||||
@onready var shoot_component: ShootComponent = %ShootComponent
|
||||
@onready var weapon_component: WeaponComponent = %WeaponComponent
|
||||
|
||||
@export var can_shoot: bool = true
|
||||
@export var is_shooting: bool = false
|
||||
|
||||
var previous_position: Vector2
|
||||
var ship_displacement: float
|
||||
var travel: float = 0
|
||||
|
||||
|
||||
func _process(delta) -> void:
|
||||
|
||||
# Read Controls
|
||||
input_component.update()
|
||||
|
||||
# Read Movement Component
|
||||
movement_component.input = input_component.move_dir
|
||||
movement_component.tick(delta)
|
||||
|
||||
# Set up shooting
|
||||
if input_component.shooting:
|
||||
is_shooting = true
|
||||
if travel > weapon_component.bullet_data.projectile_spacing:
|
||||
shoot_component.shoot()
|
||||
travel -= weapon_component.bullet_data.projectile_spacing
|
||||
|
||||
else: is_shooting = false
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://dulfr27gg4evl
|
||||
|
|
@ -11,5 +11,4 @@ extends Resource
|
|||
@export var projectiles: int = 2
|
||||
@export var rate: float = 0.1
|
||||
@export var cooldown: float = 0.25
|
||||
@export var projectile_spacing: float = 35
|
||||
@export var projectile_origin: int = -23
|
||||
@export var spacing: float = 35
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
class_name ShootComponent extends Node
|
||||
|
||||
@onready var weapon_component: Node = %WeaponComponent
|
||||
@onready var player: Player = $".."
|
||||
|
||||
var travel: float = 0
|
||||
var weapon_spacing: float = 0.1
|
||||
|
||||
|
||||
func shoot():
|
||||
|
||||
# Continuous fire
|
||||
if player.is_shooting == true:
|
||||
|
||||
# Adjust bullet spacing before firing
|
||||
|
||||
|
||||
for b in range(weapon_component.bullet_data.projectiles):
|
||||
|
||||
# Instantiate the bullets
|
||||
var bullet = weapon_component.weapon_current.instantiate()
|
||||
get_tree().root.add_child(bullet)
|
||||
bullet.position = player.position + Vector2((b - (weapon_component.bullet_data.projectiles - 1) / 2.0) * weapon_component.bullet_data.projectile_spacing, weapon_component.bullet_data.projectile_origin)
|
||||
|
||||
## Get weapon speed and spacing for equidistant calculations
|
||||
#weapon_rate = bullet.weapon_component.bullet_data.rate
|
||||
#weapon_spacing = bullet.weapon_component.bullet_data.projectile_spacing
|
||||
#bullet.weapon_component.bullet_data.speed = bullet.weapon_component.bullet_data.speed
|
||||
|
||||
# Print which weapon is firing
|
||||
prints(bullet.shot_data.shot_name, "weapon fired")
|
||||
|
||||
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://bgd1hwindc2ui
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
class_name WeaponComponent extends Node
|
||||
|
||||
@export var weapon_current : PackedScene
|
||||
#@export var projectile_origin: int = -23
|
||||
var bullet_data: PlayerShot = load("res://resources/player_weapons/shot_stock_static.tres")
|
||||
|
||||
#@export_category("Temp Bullet Data")
|
||||
#@export var projectiles: int = 3
|
||||
#@export var projectile_spacing: float = 10
|
||||
|
||||
#var damage: int = 0
|
||||
#var speed: int = 135
|
||||
#var projectiles: int = 2
|
||||
#var rate: float = 0.1
|
||||
#var cooldown: float = 0.25
|
||||
#var projectile_spacing: float = 10
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://ylmao2ndp22y
|
||||
Loading…
Add table
Add a link
Reference in a new issue