added Graphics and sound Effects and more overhauls

This commit is contained in:
Exobyt 2025-08-03 20:56:32 +02:00
parent c887a2168c
commit b9d4288900
214 changed files with 3378 additions and 198 deletions

View file

@ -0,0 +1,19 @@
extends Control
@onready var waveInfo = $CenterContainer/VBoxContainer/HBoxContainer/WaveInfo
@onready var destroyedInfo = $CenterContainer/VBoxContainer/HBoxContainer2/DestroyedInfo
@onready var mainMenu = preload("res://scenes/UI/mainMenu/mainMenu.tscn")
func _ready() -> void:
waveInfo.text = str(Globals.currentWave)
destroyedInfo.text = str(Globals.destroyedShips)
func _on_button_pressed() -> void:
loadMainMenu()
func loadMainMenu():
get_tree().get_root().add_child(load("res://scenes/UI/mainMenu/mainMenu.tscn").instantiate())
queue_free()

View file

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

View file

@ -0,0 +1,64 @@
[gd_scene load_steps=4 format=3 uid="uid://jiaqas4j8vty"]
[ext_resource type="Script" uid="uid://bj337ebonpkf8" path="res://scenes/UI/loseScreen/endScreen.gd" id="1_dvdsp"]
[ext_resource type="Theme" uid="uid://bcbicfiflkrja" path="res://theme/interface.tres" id="1_hccji"]
[ext_resource type="Texture2D" uid="uid://beyhkcr2uvmc7" path="res://assets/space.png" id="2_hccji"]
[node name="EndScreen" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_hccji")
script = ExtResource("1_dvdsp")
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 0
offset_left = -2160.0
offset_top = -2624.0
offset_right = 3984.0
offset_bottom = 3520.0
texture = ExtResource("2_hccji")
stretch_mode = 1
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer"]
layout_mode = 2
[node name="WaveLabel" type="Label" parent="CenterContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Survided to Wave: "
[node name="WaveInfo" type="Label" parent="CenterContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
[node name="HBoxContainer2" type="HBoxContainer" parent="CenterContainer/VBoxContainer"]
layout_mode = 2
[node name="DestroyedLabel" type="Label" parent="CenterContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "Destroyed Ships: "
[node name="DestroyedInfo" type="Label" parent="CenterContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="CenterContainer/VBoxContainer"]
layout_mode = 2
[node name="Button" type="Button" parent="CenterContainer/VBoxContainer/MarginContainer"]
layout_mode = 2
text = "Back to Menu"
[connection signal="pressed" from="CenterContainer/VBoxContainer/MarginContainer/Button" to="." method="_on_button_pressed"]

View file

@ -0,0 +1,16 @@
extends Control
@onready var game = preload("res://scenes/main/main.tscn")
func _on_button_start_pressed() -> void:
laodGame()
Globals.touchscreen = false
func laodGame():
get_tree().get_root().add_child(game.instantiate())
queue_free()
func _on_button_start_touch_pressed() -> void:
Globals.touchscreen = true
laodGame()

View file

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

View file

@ -0,0 +1,58 @@
[gd_scene load_steps=5 format=3 uid="uid://cx1lvrbofx0je"]
[ext_resource type="Texture2D" uid="uid://beyhkcr2uvmc7" path="res://assets/space.png" id="1_l1ky1"]
[ext_resource type="Theme" uid="uid://bcbicfiflkrja" path="res://theme/interface.tres" id="1_yi36i"]
[ext_resource type="Script" uid="uid://b1rw7bmvcl11o" path="res://scenes/UI/mainMenu/mainMenu.gd" id="2_dwrcc"]
[ext_resource type="Texture2D" uid="uid://cd5anydes4tv3" path="res://assets/player/shotgunShip.png" id="4_u55jd"]
[node name="mainMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_yi36i")
script = ExtResource("2_dwrcc")
[node name="TextureRect" type="TextureRect" parent="."]
offset_left = -2160.0
offset_top = -2624.0
offset_right = 3984.0
offset_bottom = 3520.0
texture = ExtResource("1_l1ky1")
stretch_mode = 1
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
layout_mode = 2
[node name="TextureRect" type="TextureRect" parent="CenterContainer/VBoxContainer"]
layout_mode = 2
texture = ExtResource("4_u55jd")
stretch_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="CenterContainer/VBoxContainer"]
layout_mode = 2
[node name="ButtonStart" type="Button" parent="CenterContainer/VBoxContainer/MarginContainer"]
layout_mode = 2
text = "Play"
[node name="MarginContainer3" type="MarginContainer" parent="CenterContainer/VBoxContainer"]
layout_mode = 2
[node name="ButtonStartTouch" type="Button" parent="CenterContainer/VBoxContainer/MarginContainer3"]
layout_mode = 2
text = "Play
Touchscreen"
[connection signal="pressed" from="CenterContainer/VBoxContainer/MarginContainer/ButtonStart" to="." method="_on_button_start_pressed"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/MarginContainer3/ButtonStartTouch" to="." method="_on_button_start_touch_pressed"]

View file

@ -1,8 +1,15 @@
extends Area2D
#
#@export var damage: int
#
@export var damage: int
#func _on_area_entered(area: Area2D) -> void:
#if area.is_in_group("hurtArea"):
#area.hurt.emit(damage)
func _on_area_entered(area: Area2D) -> void:
if area.is_in_group("healthArea"):
area.hurt.emit(damage)
func damageHurtArea(_area: Area2D, _damage: int):
if get_parent().is_in_group("timeGhost") and _area.get_parent() == Globals.getPlayer():
print("time")
return
if _area.is_in_group("hurtArea"):
_area.hurt.emit(_damage)

View file

@ -8,5 +8,3 @@ collision_mask = 1073741824
script = ExtResource("1_jlldj")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
[connection signal="area_entered" from="." to="." method="_on_area_entered"]

View file

@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://1a30h315e73b" path="res://scenes/areas/hurtArea/hurt_area.gd" id="1_c51ym"]
[node name="hurtArea" type="Area2D" groups=["healthArea"]]
[node name="hurtArea" type="Area2D" groups=["hurtArea"]]
collision_layer = 1073741824
collision_mask = 2147483648
script = ExtResource("1_c51ym")

View file

@ -1,8 +1,3 @@
extends Area2D
signal hurt(amount: int)
#
#func _on_area_entered(area: Area2D) -> void:
#print(area.name)
#

View file

@ -10,15 +10,15 @@ var penetration: int = 1
var penetratedCount: int = 0
var range: float = 1.0
var fromTimeGhost = false
func _ready() -> void:
damageArea.damage = damage
rangeTimer.start(range)
func spawn(_positon: Vector2, _rotation: float, _damage: int, _range: float = 8.0, _penetration: int = 1, _speed: int = 10) -> void:
global_position = _positon
rotation = _rotation
damage = _damage
$DamageArea.damage = _damage
penetration = _penetration
range = _range
speed = _speed * 10000
@ -29,6 +29,12 @@ func _physics_process(delta: float) -> void:
move_and_slide()
func _on_damage_area_area_entered(area: Area2D) -> void:
if fromTimeGhost:
#print(area.get_parent())
#print(Globals.getPlayer())
if area.get_parent() == Globals.getPlayer():
return
damageArea.damageHurtArea(area, damage)
penetratedCount += 1
checkPenetration()

View file

@ -4,6 +4,7 @@
[ext_resource type="Script" uid="uid://w5vknsebe1yd" path="res://scenes/bullet/bullet.gd" id="1_mkndb"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mkndb"]
size = Vector2(16, 48)
[node name="Bullet" type="CharacterBody2D" groups=["bullet"]]
collision_layer = 0
@ -14,7 +15,6 @@ script = ExtResource("1_mkndb")
[node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(0, -9.53674e-07)
scale = Vector2(0.125, 0.25)
[node name="rangeTimer" type="Timer" parent="."]
one_shot = true

View file

@ -2,14 +2,16 @@
[ext_resource type="PackedScene" uid="uid://0ndix1r8v6i1" path="res://scenes/bullet/bullet.tscn" id="1_a54uy"]
[ext_resource type="Script" uid="uid://58udf4vhqogw" path="res://scenes/bullet/bulletMinigun/bulletMinigun.gd" id="2_4u8er"]
[ext_resource type="Texture2D" uid="uid://cfwyw1sr6x2np" path="res://icon.svg" id="3_xaefx"]
[ext_resource type="Texture2D" uid="uid://d2h1eyb147j7t" path="res://assets/bullets/minigunBullet.png" id="3_xaefx"]
[node name="BulletMinigun" instance=ExtResource("1_a54uy")]
script = ExtResource("2_4u8er")
[node name="Sprite2D" parent="." index="1"]
position = Vector2(4.76837e-07, 3.41061e-13)
scale = Vector2(0.25, 0.25)
position = Vector2(0, 0)
texture = ExtResource("3_xaefx")
[node name="CollisionShape2D" parent="DamageArea" index="0"]
position = Vector2(0, 4)
[editable path="DamageArea"]

View file

@ -1,3 +0,0 @@
[gd_scene format=3 uid="uid://dm0rd88xd5m7k"]
[node name="bulletPool" type="Node2D" groups=["bulletPool"]]

View file

@ -1,9 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://y7lohopyn6bw"]
[gd_scene load_steps=4 format=3 uid="uid://y7lohopyn6bw"]
[ext_resource type="PackedScene" uid="uid://0ndix1r8v6i1" path="res://scenes/bullet/bullet.tscn" id="1_0cdtm"]
[ext_resource type="Script" uid="uid://b884kxhja5sib" path="res://scenes/bullet/bulletRailgun/bulletRailgun.gd" id="2_pmqys"]
[ext_resource type="Texture2D" uid="uid://xj1r10s5lg48" path="res://assets/bullets/railgunBullet.png" id="3_5rfgl"]
[node name="BulletRailgun" instance=ExtResource("1_0cdtm")]
script = ExtResource("2_pmqys")
[node name="Sprite2D" parent="." index="1"]
texture = ExtResource("3_5rfgl")
[editable path="DamageArea"]

View file

@ -1,9 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://bye43kihfl72l"]
[gd_scene load_steps=4 format=3 uid="uid://bye43kihfl72l"]
[ext_resource type="PackedScene" uid="uid://0ndix1r8v6i1" path="res://scenes/bullet/bullet.tscn" id="1_shfn0"]
[ext_resource type="Script" uid="uid://ddbv5kpk32diu" path="res://scenes/bullet/bulletShotgun/bulletShotgun.gd" id="2_mk7vs"]
[ext_resource type="Texture2D" uid="uid://b8y5bc5ntygd8" path="res://assets/bullets/shotgunBullet.png" id="3_uxgou"]
[node name="BulletShotgun" instance=ExtResource("1_shfn0")]
script = ExtResource("2_mk7vs")
[node name="Sprite2D" parent="." index="1"]
texture = ExtResource("3_uxgou")
[editable path="DamageArea"]

View file

@ -1,14 +1,80 @@
extends Node
var destroyedShips: int = 0
var currentDelay: float = 1.0
var player: Player = null
var currentWave: int = 0
var enemyCount: int = 0
var touchscreen: bool = false
var UPGRADES: Array[Upgrade] = [
TimeGhostUpgrade.new(),
SpeedUpgrade.new(),
SelfHealUpgrade.new(),
MinigunUpgrade.new(),
ShotgunUpgrade.new(),
RailgunUpgrade.new(),
Heal50Upgrade.new(),
Heal100Upgrade.new(),
HealthUpgrade.new(),
#DashUpgrade.new(),
#StrafeUpgrade.new(),
#DamageUpgrade.new()
]
var currentUpgrades: Array[Upgrade] = UPGRADES
signal waveComplete
func _ready() -> void:
pass
process_mode = Node.PROCESS_MODE_ALWAYS
reset()
func _physics_process(delta: float) -> void:
if Input.is_action_just_pressed("fullscreen"):
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
elif DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_WINDOWED:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
func setPlayer(_player: Player):
player = _player
func getPlayer() -> Player:
return player
func reset():
currentDelay = 1.0
currentWave = 0
enemyCount = 0
destroyedShips = 0
currentUpgrades = UPGRADES
touchscreen = false
#func nextWave():
#currentWave += 1
#enemyCount = 0
#waveComplete.emit()
func enemyDestroyed():
destroyedShips += 1
enemyCount -= 1
if enemyCount <= 0:
await get_tree().create_timer(1).timeout
waveComplete.emit()
func getUpgrades() -> Array[Upgrade]:
return currentUpgrades
func getUpgrade(upgrade: int):
return currentUpgrades[upgrade]
func removeUpgrade(upgrade: int):
currentUpgrades.pop_at(upgrade)
func removeSpeedUPgrade():
for i in currentUpgrades:
if i is SpeedUpgrade:
currentUpgrades.erase(i)

View file

@ -0,0 +1,90 @@
shader_type canvas_item;
render_mode unshaded;
uniform int iterations = 20;
uniform float formuparam = 1.00;
uniform int volsteps = 20;
uniform float stepsize = 0.1;
uniform float zoom = 0.800;
uniform float tile = 0.5;
uniform float speed = 0.001;
uniform float brightness = 0.002;
uniform float darkmatter = 0.100;
uniform float distfading = 0.650;
uniform float saturation = 0.750;
uniform vec2 iResolution = vec2(192, 192);
uniform vec2 iMouse = vec2(0,0);
float SCurve (float value) {
if (value < 0.5)
{
return value * value * value * value * value * 16.0;
}
value -= 1.0;
return value * value * value * value * value * 16.0 + 1.0;
}
void fragment()
{
//get coords and direction
vec2 uv=FRAGCOORD.xy/iResolution.xy-.5;
uv.y*=iResolution.y/iResolution.x;
vec3 dir=vec3(uv*zoom,1.);
float time=TIME*speed+.25;
//mouse rotation
float a1=0.5+iMouse.x/iResolution.x*2.;
float a2=0.8+iMouse.y/iResolution.y*2.;
mat2 rot1=mat2(vec2(cos(a1),sin(a1)),vec2(-sin(a1),cos(a1)));
mat2 rot2=mat2(vec2(cos(a2),sin(a2)),vec2(-sin(a2),cos(a2)));
dir.xy*=rot1;
dir.xz*=rot2;
vec3 from=vec3(1.0,0.5,0.5);
from-=vec3(0.0,time,0.0);
from.xz*=rot1;
from.xy*=rot2;
//volumetric rendering
float s=0.1,fade=1.;
vec3 v=vec3(0.);
for (int r=0; r<volsteps; r++) {
vec3 p=from+s*dir*0.5;
p = abs(vec3(tile)-mod(p,vec3(tile*2.))); // tiling fold
float pa,a=pa=0.;
for (int i=0; i<iterations; i++) {
p=abs(p)/dot(p,p)-formuparam; // the magic formula
a+=abs(length(p)-pa); // absolute sum of average change
pa=length(p);
}
float dm=max(0.,darkmatter-a*a*.001); //dark matter
a = pow(a, 2.3); // add contrast
if (r>6) fade*=1.-dm; // dark matter, don't render near
//v+=vec3(dm,dm*.5,0.);
v+=fade;
v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade; // coloring based on distance
fade*=distfading; // distance fading
s+=stepsize;
}
v=mix(vec3(length(v)),v,saturation); //color adjust
vec4 C = vec4(v*.01,1.);
C.r = pow(C.r, 0.35);
C.g = pow(C.g, 0.36);
C.b = pow(C.b, 0.38);
vec4 L = C;
COLOR.r = mix(L.r, SCurve(C.r), 0.7);
COLOR.g = mix(L.g, SCurve(C.g), 1.0);
COLOR.b = mix(L.b, SCurve(C.b), 0.2);
}

View file

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

View file

@ -1,50 +1,69 @@
extends Node2D
@onready var obstaclesSpawnTimer = $obstaclesSpawnTimer
@onready var timeGhost = preload("res://scenes/spaceShip/timeGhost/timeghost.tscn")
@onready var minigun = preload("res://scenes/weapon/minigun/minigun.tscn")
@onready var railgun = preload("res://scenes/weapon/railgun/railgun.tscn")
@onready var shotgun = preload("res://scenes/weapon/shotgun/shotgun.tscn")
@onready var shotgunEnemy: PackedScene = preload("res://scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.tscn")
@onready var minigunEnemy: PackedScene = preload("res://scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.tscn")
@onready var railgunEnemy: PackedScene = preload("res://scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.tscn")
@onready var meteor: PackedScene = preload("res://scenes/obstacle/meteor/meteor.tscn")
@onready var radiation: PackedScene = preload("res://scenes/obstacle/radiation/radiation.tscn")
@onready var obstaclePool = $obstaclePool
@onready var enemyPool = $enemyPool
@onready var enemySpawnTimer = $spawnTimer/enemySpawnTimer
@onready var obstaclesSpawnTimer = $spawnTimer/obstaclesSpawnTimer
@onready var enemy: PackedScene = preload("res://scenes/spaceShip/enemy/enemy.tscn")
@onready var obstacle: PackedScene = preload("res://scenes/obstacle/meteor/meteor.tscn")
@onready var endScreen: PackedScene = preload("res://scenes/UI/loseScreen/endScreen.tscn")
var minigunRatio = 5
var railgunRatio = 10
var endedRound = false
@onready var player = $Player
func _ready() -> void:
obstaclesSpawnTimer.autostart = true
obstaclesSpawnTimer.start()
Globals.setPlayer(player)
player.changeWeapon(shotgun)
Globals.waveComplete.connect(nextWave)
player.destroyed.connect(endRound)
nextWave()
for i in range(1, 10):
addGhost()
func addGhost():
var ghost = timeGhost.instantiate()
add_child(ghost)
player.addTimeGhost(ghost)
func spawnObstacle(_obstacle: PackedScene, _position: Vector2):
var newObstacle = _obstacle.instantiate()
newObstacle.global_position = _position
obstaclePool.add_child(newObstacle)
if get_tree().get_first_node_in_group("obstaclePool") != null:
get_tree().get_first_node_in_group("obstaclePool").add_child(newObstacle)
func spawnEnemy(_enemy: PackedScene, _position: Vector2):
Globals.enemyCount += 1
var newEnemy = _enemy.instantiate()
newEnemy.global_position = _position
enemyPool.add_child(newEnemy)
if get_tree().get_first_node_in_group("enemyPool") != null:
get_tree().get_first_node_in_group("enemyPool").add_child(newEnemy)
func _on_enemy_spawn_timer_timeout() -> void:
spawnEnemy(enemy, Globals.getPlayer().getRandomSpawnPointPosition())
for i in enemyPool.get_children():
i.changeWeapon(shotgun)
#newEnemy.destroyed.connect(startEnemySpawnTimer)
func _on_obstacles_spawn_timer_timeout() -> void:
spawnObstacle(obstacle, Globals.getPlayer().getRandomSpawnPointPosition())
var rng = RandomNumberGenerator.new()
var number = rng.randi_range(0, 10)
if number == 10:
if Globals.getPlayer() != null:
spawnObstacle(radiation, Globals.getPlayer().getRandomSpawnPointPosition())
else:
if Globals.getPlayer() != null:
spawnObstacle(meteor, Globals.getPlayer().getRandomSpawnPointPosition())
func nextWave():
Globals.enemyCount = 0
Globals.currentWave += 1
if Globals.getPlayer() != null:
for i in range(1, Globals.currentWave+1):
if i % railgunRatio == 0:
spawnEnemy(railgunEnemy, Globals.getPlayer().getRandomSpawnPointPosition())
elif i % minigunRatio == 0:
spawnEnemy(minigunEnemy, Globals.getPlayer().getRandomSpawnPointPosition())
else:
spawnEnemy(shotgunEnemy, Globals.getPlayer().getRandomSpawnPointPosition())
func endRound():
if not endedRound:
endedRound = true
get_tree().get_root().add_child(endScreen.instantiate())
self.queue_free()

View file

@ -2,38 +2,26 @@
[ext_resource type="Script" uid="uid://cvoco1axom40" path="res://scenes/main/main.gd" id="1_kdt4m"]
[ext_resource type="PackedScene" uid="uid://bmc2exqutt6vu" path="res://scenes/spaceShip/player/player.tscn" id="2_ia3nl"]
[ext_resource type="PackedScene" uid="uid://dm0rd88xd5m7k" path="res://scenes/bullet/bulletPool.tscn" id="3_2s0fe"]
[ext_resource type="Texture2D" uid="uid://cfwyw1sr6x2np" path="res://icon.svg" id="4_r8qeh"]
[ext_resource type="Texture2D" uid="uid://beyhkcr2uvmc7" path="res://assets/space.png" id="2_l3cfh"]
[ext_resource type="PackedScene" uid="uid://dm0rd88xd5m7k" path="res://scenes/pools/pools.tscn" id="3_2s0fe"]
[node name="main" type="Node2D"]
script = ExtResource("1_kdt4m")
[node name="obstaclesSpawnTimer" type="Timer" parent="."]
autostart = true
[node name="TextureRect" type="TextureRect" parent="."]
modulate = Color(0.605274, 0.605274, 0.605274, 1)
offset_left = -11272.0
offset_top = -6736.0
offset_right = 12152.0
offset_bottom = 7008.0
texture = ExtResource("4_r8qeh")
offset_left = -147424.0
offset_top = -96136.0
offset_right = 176160.0
offset_bottom = 137080.0
texture = ExtResource("2_l3cfh")
stretch_mode = 1
[node name="Pools" parent="." instance=ExtResource("3_2s0fe")]
[node name="Player" parent="." instance=ExtResource("2_ia3nl")]
spawnDistance = 1000
[node name="bulletPool" parent="." instance=ExtResource("3_2s0fe")]
[node name="obstaclePool" type="Node2D" parent="."]
[node name="enemyPool" type="Node2D" parent="."]
[node name="spawnTimer" type="Node" parent="."]
[node name="enemySpawnTimer" type="Timer" parent="spawnTimer"]
wait_time = 10.0
autostart = true
[node name="obstaclesSpawnTimer" type="Timer" parent="spawnTimer"]
autostart = true
[connection signal="timeout" from="spawnTimer/enemySpawnTimer" to="." method="_on_enemy_spawn_timer_timeout"]
[connection signal="timeout" from="spawnTimer/obstaclesSpawnTimer" to="." method="_on_obstacles_spawn_timer_timeout"]
[connection signal="timeout" from="obstaclesSpawnTimer" to="." method="_on_obstacles_spawn_timer_timeout"]

View file

@ -0,0 +1,4 @@
extends AnimationPlayer
func _ready() -> void:
play("spin")

View file

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

View file

@ -1,18 +1,36 @@
class_name Meteor extends "res://scenes/obstacle/obstacle.gd"
@onready var animationPlayer = $AnimationPlayer
@export var minSpeed: int = 100
@export var maxSpeed: int = 1000
@export var minScale: float = 0.5
@export var maxScale: float = 2
var rotated = false
var speed: int = 1000
var offset: int = 0
var direction: int
func _init() -> void:
var rng = RandomNumberGenerator.new()
direction = rng.randi_range(0, 360)
var newScale = rng.randf_range(minScale, maxScale)
scale = Vector2(newScale, newScale)
var direction = Vector2.UP.rotated(rotation)
direction = rng.randi_range(0, 20)
speed = rng.randi_range(minSpeed, maxSpeed)
rotation = direction
#rotation = direction
func _physics_process(delta: float) -> void:
velocity = Vector2.UP.rotated(direction).normalized() * speed
if not rotated:
rotated = true
if Globals.getPlayer() != null:
look_at(Globals.getPlayer().global_position)
var rng = RandomNumberGenerator.new()
velocity = Vector2.RIGHT.rotated(rotation+offset).normalized() * speed
move_and_slide()

View file

@ -1,36 +1,83 @@
[gd_scene load_steps=7 format=3 uid="uid://vl8duuwwrpqm"]
[gd_scene load_steps=11 format=3 uid="uid://vl8duuwwrpqm"]
[ext_resource type="PackedScene" uid="uid://cgqo1nxq6xprm" path="res://scenes/obstacle/obstacle.tscn" id="1_skd46"]
[ext_resource type="PackedScene" uid="uid://cgqo1nxq6xprm" path="res://scenes/obstacle/obstacle.tscn" id="1_8c34n"]
[ext_resource type="Script" uid="uid://b82cnxsh4mn0f" path="res://scenes/obstacle/meteor/meteor.gd" id="2_8c34n"]
[ext_resource type="Texture2D" uid="uid://cfwyw1sr6x2np" path="res://icon.svg" id="3_jb48p"]
[sub_resource type="CircleShape2D" id="CircleShape2D_8c34n"]
radius = 56.0
[ext_resource type="Texture2D" uid="uid://drk4xkhlq00x3" path="res://assets/obstacles/meteor.png" id="3_jb48p"]
[ext_resource type="Script" uid="uid://mnl62nrp3ffi" path="res://scenes/obstacle/meteor/animation_player.gd" id="4_pganv"]
[sub_resource type="CircleShape2D" id="CircleShape2D_jb48p"]
radius = 64.0
radius = 128.0
[sub_resource type="CircleShape2D" id="CircleShape2D_pganv"]
radius = 64.0
radius = 144.0
[node name="Meteor" instance=ExtResource("1_skd46")]
modulate = Color(1, 0, 0, 1)
[sub_resource type="CircleShape2D" id="CircleShape2D_22u22"]
radius = 128.25
[sub_resource type="Animation" id="Animation_22u22"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
[sub_resource type="Animation" id="Animation_pganv"]
resource_name = "spin"
length = 5.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = false
tracks/0/keys = {
"times": PackedFloat32Array(0, 5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.0, 6.28319]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_b3sfu"]
_data = {
&"RESET": SubResource("Animation_22u22"),
&"spin": SubResource("Animation_pganv")
}
[node name="Meteor" instance=ExtResource("1_8c34n")]
script = ExtResource("2_8c34n")
minSpeed = 100
maxSpeed = 1000
health = 10
minScale = 0.5
maxScale = 2.0
[node name="CollisionShape2D" parent="." index="0"]
shape = SubResource("CircleShape2D_8c34n")
[node name="CollisionShape2D" parent="DamageArea" index="0"]
shape = SubResource("CircleShape2D_jb48p")
[node name="CollisionShape2D" parent="hurtArea" index="0"]
[node name="CollisionShape2D" parent="DamageArea" index="0"]
shape = SubResource("CircleShape2D_pganv")
[node name="CollisionShape2D" parent="hurtArea" index="0"]
shape = SubResource("CircleShape2D_22u22")
[node name="Sprite2D" parent="." index="3"]
position = Vector2(5.72205e-06, 5.72205e-06)
scale = Vector2(0.666667, 0.666667)
texture = ExtResource("3_jb48p")
[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="6"]
libraries = {
&"": SubResource("AnimationLibrary_b3sfu")
}
script = ExtResource("4_pganv")
[editable path="DamageArea"]
[editable path="hurtArea"]

View file

@ -2,22 +2,25 @@ class_name Obstacle extends CharacterBody2D
@onready var sprite = $Sprite2D
@onready var lifeTimeTimer = $lifeTimeTimer
@onready var damageArea = $DamageArea
@onready var hit = $hit
@export var damage: int = 10
@export var health: int = 1
@export var damage: int = 100
@export var minHealth: int = 1
@export var maxHealth: int = 1
@export var maxHealth: int = 100
@export var health: int
@export var lifeTime: int = 600
func _ready() -> void:
health = maxHealth + damage + 1
lifeTimeTimer.start(lifeTime)
health += damage
func spawn(damage: int):
pass
func _on_hurt_area_hurt(amount: int) -> void:
hit.play()
hurt(amount)
func hurt(amount: int):
@ -29,3 +32,7 @@ func hurt(amount: int):
func _on_life_time_timer_timeout() -> void:
queue_free()
func _on_damage_area_area_entered(area: Area2D) -> void:
damageArea.damageHurtArea(area, damage)

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://cgqo1nxq6xprm"]
[gd_scene load_steps=5 format=3 uid="uid://cgqo1nxq6xprm"]
[ext_resource type="PackedScene" uid="uid://eqo7k2ronf8k" path="res://scenes/areas/damageArea/damageArea.tscn" id="1_1ys07"]
[ext_resource type="Script" uid="uid://iu7hvfpevs65" path="res://scenes/obstacle/obstacle.gd" id="1_osovj"]
[ext_resource type="PackedScene" uid="uid://cglnd1ekr5u6r" path="res://scenes/areas/hurtArea/hurtArea.tscn" id="2_osovj"]
[ext_resource type="AudioStream" uid="uid://vjxm7ay4t2ju" path="res://assets/sound/hit2.wav" id="4_ckc2h"]
[node name="Obstacle" type="CharacterBody2D" groups=["obstacle"]]
collision_layer = 2
@ -20,6 +21,10 @@ script = ExtResource("1_osovj")
[node name="lifeTimeTimer" type="Timer" parent="."]
one_shot = true
[node name="hit" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("4_ckc2h")
[connection signal="area_entered" from="DamageArea" to="." method="_on_damage_area_area_entered"]
[connection signal="hurt" from="hurtArea" to="." method="_on_hurt_area_hurt"]
[connection signal="timeout" from="lifeTimeTimer" to="." method="_on_life_time_timer_timeout"]

View file

@ -0,0 +1,6 @@
class_name Radiation extends "res://scenes/obstacle/obstacle.gd"
func _physics_process(delta: float) -> void:
for i: Spaceship in $range.get_overlapping_bodies():
i.applyRadiation(damage)

View file

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

View file

@ -0,0 +1,49 @@
shader_type canvas_item;
uniform float time : hint_range(0.0, 10.0);
float snoise(vec3 uv, float res)
{
const vec3 s = vec3(1e0, 1e2, 1e3);
uv *= res;
vec3 uv0 = floor(mod(uv, res)) * s;
vec3 uv1 = floor(mod(uv + vec3(1.0), res)) * s;
vec3 f = fract(uv);
f = f * f * (3.0 - 2.0 * f);
vec4 v = vec4(uv0.x + uv0.y + uv0.z, uv1.x + uv0.y + uv0.z,
uv0.x + uv1.y + uv0.z, uv1.x + uv1.y + uv0.z);
vec4 r = fract(sin(v * 1e-1) * 1e3);
float r0 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
r = fract(sin((v + uv1.z - uv0.z) * 1e-1) * 1e3);
float r1 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
return mix(r0, r1, f.z) * 2.0 - 1.0;
}
void fragment()
{
// Calcular las coordenadas de la pantalla usando SCREEN_PIXEL_SIZE
vec2 screen_size = vec2(1.0 / SCREEN_PIXEL_SIZE.x, 1.0 / SCREEN_PIXEL_SIZE.y);
vec2 fragCoord = FRAGCOORD.xy;
vec2 p = -0.5 + fragCoord.xy / screen_size;
p.x *= screen_size.x / screen_size.y;
float color = 3.0 - (3.0 * length(2.0 * p));
vec3 coord = vec3(atan(p.x, p.y) / 6.2832 + 0.5, length(p) * 0.4, 0.5);
// if you dont want use gdscript to animate you can replace the 'time' to 'TIME'
for (int i = 1; i <= 7; i++)
{
float power = pow(2.0, float(i));
color += (1.5 / power) * snoise(coord + vec3(0.0, -time * 0.05, time * 0.01), power * 16.0);
}
COLOR = vec4(color, pow(max(color, 0.0), 2.0) * 0.4, pow(max(color, 0.0), 3.0) * 0.15, 1.0);
}

View file

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

View file

@ -0,0 +1,57 @@
[gd_scene load_steps=8 format=3 uid="uid://dhkcgxwakdha7"]
[ext_resource type="PackedScene" uid="uid://cgqo1nxq6xprm" path="res://scenes/obstacle/obstacle.tscn" id="1_0jyim"]
[ext_resource type="Script" uid="uid://cf6le506yx5kl" path="res://scenes/obstacle/radiation/radiation.gd" id="2_7r84j"]
[ext_resource type="Texture2D" uid="uid://cfwyw1sr6x2np" path="res://icon.svg" id="3_o6dqs"]
[ext_resource type="Texture2D" uid="uid://bwnpsmrwskrgh" path="res://assets/radiation.png" id="4_pc435"]
[sub_resource type="CircleShape2D" id="CircleShape2D_7r84j"]
radius = 64.0
[sub_resource type="ShaderMaterial" id="ShaderMaterial_as1jp"]
[sub_resource type="CircleShape2D" id="CircleShape2D_pc435"]
radius = 192.0
[node name="Radiation" instance=ExtResource("1_0jyim")]
collision_layer = 128
collision_mask = 44
script = ExtResource("2_7r84j")
damage = 1
lifeTime = 180
[node name="CollisionShape2D" parent="DamageArea" index="0"]
shape = SubResource("CircleShape2D_7r84j")
disabled = true
[node name="CollisionShape2D" parent="hurtArea" index="0"]
disabled = true
[node name="Sprite2D" parent="." index="3"]
visible = false
material = SubResource("ShaderMaterial_as1jp")
texture = ExtResource("3_o6dqs")
[node name="range" type="Area2D" parent="." index="6"]
collision_layer = 128
collision_mask = 40
[node name="CollisionShape2D" type="CollisionShape2D" parent="range" index="0"]
shape = SubResource("CircleShape2D_pc435")
[node name="CPUParticles2D" type="CPUParticles2D" parent="." index="7"]
amount = 100
texture = ExtResource("4_pc435")
lifetime = 1.8
speed_scale = 0.1
randomness = 1.0
spread = 180.0
gravity = Vector2(0, 0)
initial_velocity_min = 100.0
initial_velocity_max = 100.0
angle_max = 720.0
scale_amount_min = 0.8
scale_amount_max = 1.2
[editable path="DamageArea"]
[editable path="hurtArea"]

11
scenes/pools/pools.tscn Normal file
View file

@ -0,0 +1,11 @@
[gd_scene format=3 uid="uid://dm0rd88xd5m7k"]
[node name="Pools" type="Node2D"]
[node name="enemyPool" type="Node2D" parent="." groups=["enemyPool"]]
[node name="timeGhostPool" type="Node2D" parent="." groups=["timeGhostPool"]]
[node name="obstaclePool" type="Node2D" parent="." groups=["obstaclePool"]]
[node name="bulletPool" type="Node2D" parent="." groups=["bulletPool"]]

View file

@ -1,22 +1,67 @@
class_name Enemy extends "res://scenes/spaceShip/spaceShip.gd"
@onready var visionArea: VisionArea = $VisionAreas/VisionArea
@onready var visionAreaStop: VisionArea = $VisionAreas/VisionAreaStop
@onready var visionAreaEnemy: VisionArea = $VisionAreas/VisionAreaEnemy
@onready var raycast: RayCast2D = $RayCast2D
@onready var hit = $hit
@export var range: int = 800
func _ready() -> void:
setVision()
func setVision():
visionArea.changeViewSize(range)
visionAreaStop.changeViewSize(range-50)
visionAreaEnemy.changeViewSize(200)
raycast.target_position.y = -range
func _physics_process(delta: float) -> void:
#print(name, " velocity: ", velocity," velocityMedian: ", getVelocityMedian(), " radius: ", $VisionAreas/VisionAreaStop/CollisionShape2D.shape.radius)
#if Globals.getPlayer() != null:
#if getVelocityMedian()*8 > range:
#visionAreaStop.changeViewSize(getVelocityMedian()*8)
#global_position.distance_to(Globals.getPlayer().global_position)
if Globals.getPlayer() != null:
look_at(Globals.getPlayer().global_position)
var direction = Vector2.RIGHT.rotated(rotation)
rotation += PI / 2
if Globals.getPlayer() != null:
rotation += PI / 2
if visionArea.has_overlapping_bodies():
if not raycast.is_colliding():
attack()
#if getEnemyList() != []:
#for i in getEnemyList():
##print(global_position.distance_to(i.global_position))
#direction -= Vector2.UP.rotated(rad_to_deg(global_position.angle_to(i.global_position))) * -10
#break
#print(self)
#print(visionAreaEnemy.get_overlapping_bodies())
#print(getEnemyList())
if not visionAreaStop.has_overlapping_bodies():
velocity = velocity.lerp(direction * speed, acceleration * delta)
else:
if not raycast.is_colliding():
attack()
velocity = velocity.lerp(Vector2.ZERO, acceleration * delta)
move_and_slide()
func _on_hurt_area_hurt(amount: int) -> void:
hit.play()
damage(amount)
func getVelocityMedian() -> float:
var _velocity = velocity
if _velocity.x < 0:
_velocity.x *= -1
if _velocity.y < 0:
_velocity.y *= -1
return (_velocity.x + _velocity.y) / 2
func getEnemyList() -> Array:
var enemies = visionAreaEnemy.get_overlapping_bodies()
enemies.erase(self)
return enemies

View file

@ -1,9 +1,13 @@
[gd_scene load_steps=8 format=3 uid="uid://bodpgjdjhfn4w"]
[gd_scene load_steps=11 format=3 uid="uid://bodpgjdjhfn4w"]
[ext_resource type="PackedScene" uid="uid://csacin2gx2tum" path="res://scenes/spaceShip/spaceShip.tscn" id="1_5w6ng"]
[ext_resource type="Script" uid="uid://djlqf2g8ho05r" path="res://scenes/spaceShip/enemy/enemy.gd" id="2_2erf0"]
[ext_resource type="Texture2D" uid="uid://cfwyw1sr6x2np" path="res://icon.svg" id="2_u13ds"]
[ext_resource type="Texture2D" uid="uid://dansb0wnm00vb" path="res://assets/enemy/shotgunEnemy.png" id="3_7vnn2"]
[ext_resource type="Texture2D" uid="uid://bkc8av1vbis4r" path="res://assets/enemy/enemy.png" id="3_hybmu"]
[ext_resource type="PackedScene" uid="uid://k5fr6bfn6kkd" path="res://scenes/spaceShip/enemy/visionArea/visionArea.tscn" id="4_hybmu"]
[ext_resource type="Texture2D" uid="uid://mftd7366eymt" path="res://assets/enemy/minigunEnemy.png" id="4_ibucj"]
[ext_resource type="Texture2D" uid="uid://iddqk6g00rku" path="res://assets/enemy/RailgunEnemy.png" id="5_fmf0p"]
[ext_resource type="AudioStream" uid="uid://vjxm7ay4t2ju" path="res://assets/sound/hit2.wav" id="5_gid86"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2erf0"]
size = Vector2(112, 112)
@ -11,15 +15,16 @@ size = Vector2(112, 112)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_u13ds"]
size = Vector2(112, 112)
[sub_resource type="CircleShape2D" id="CircleShape2D_hybmu"]
radius = 448.071
[node name="Enemy" groups=["enemy"] instance=ExtResource("1_5w6ng")]
modulate = Color(1, 0, 1, 1)
collision_layer = 36
collision_mask = 35
collision_mask = 67
script = ExtResource("2_2erf0")
speed = 700
range = 800
shotgunTexture = ExtResource("3_7vnn2")
minigunTexture = ExtResource("4_ibucj")
railgunTexture = ExtResource("5_fmf0p")
maxHealth = 10
speed = 1000
[node name="CollisionShape2D" parent="." index="0"]
shape = SubResource("RectangleShape2D_2erf0")
@ -28,19 +33,29 @@ shape = SubResource("RectangleShape2D_2erf0")
shape = SubResource("RectangleShape2D_u13ds")
[node name="Sprite2D" parent="." index="2"]
texture = ExtResource("2_u13ds")
position = Vector2(0, -24)
texture = ExtResource("3_hybmu")
[node name="VisionAreas" type="Node2D" parent="." index="5"]
[node name="VisionAreaStop" parent="VisionAreas" index="0" instance=ExtResource("4_hybmu")]
[node name="VisionArea" parent="VisionAreas" index="0" instance=ExtResource("4_hybmu")]
[node name="CollisionShape2D" parent="VisionAreas/VisionAreaStop" index="0"]
shape = SubResource("CircleShape2D_hybmu")
[node name="VisionAreaStop" parent="VisionAreas" index="1" instance=ExtResource("4_hybmu")]
[node name="VisionAreaEnemy" parent="VisionAreas" index="2" instance=ExtResource("4_hybmu")]
collision_mask = 32
[node name="RayCast2D" type="RayCast2D" parent="." index="6"]
target_position = Vector2(0, -448)
collision_mask = 32
hit_from_inside = true
[node name="hit" type="AudioStreamPlayer2D" parent="." index="7"]
stream = ExtResource("5_gid86")
[connection signal="hurt" from="hurtArea" to="." method="_on_hurt_area_hurt"]
[editable path="hurtArea"]
[editable path="VisionAreas/VisionArea"]
[editable path="VisionAreas/VisionAreaStop"]
[editable path="VisionAreas/VisionAreaEnemy"]

View file

@ -0,0 +1,5 @@
class_name MinigunEnemy extends "res://scenes/spaceShip/enemy/enemy.gd"
func _ready() -> void:
changeWeapon(MINIGUN)
setVision()

View file

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

View file

@ -0,0 +1,16 @@
[gd_scene load_steps=4 format=3 uid="uid://bydt20jefk35d"]
[ext_resource type="PackedScene" uid="uid://bodpgjdjhfn4w" path="res://scenes/spaceShip/enemy/enemy.tscn" id="1_h0ios"]
[ext_resource type="Script" uid="uid://dbxjdkvkkv5cm" path="res://scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.gd" id="2_ltdg3"]
[ext_resource type="Texture2D" uid="uid://mftd7366eymt" path="res://assets/enemy/minigunEnemy.png" id="3_ltdg3"]
[node name="MinigunEnemy" instance=ExtResource("1_h0ios")]
script = ExtResource("2_ltdg3")
[node name="Sprite2D" parent="." index="2"]
texture = ExtResource("3_ltdg3")
[editable path="hurtArea"]
[editable path="VisionAreas/VisionArea"]
[editable path="VisionAreas/VisionAreaStop"]
[editable path="VisionAreas/VisionAreaEnemy"]

View file

@ -0,0 +1,5 @@
class_name RailgunEnemy extends "res://scenes/spaceShip/enemy/enemy.gd"
func _ready() -> void:
changeWeapon(RAILGUN)
setVision()

View file

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

View file

@ -0,0 +1,18 @@
[gd_scene load_steps=4 format=3 uid="uid://tvds0d2gclgg"]
[ext_resource type="PackedScene" uid="uid://bodpgjdjhfn4w" path="res://scenes/spaceShip/enemy/enemy.tscn" id="1_0ankw"]
[ext_resource type="Script" uid="uid://cjge3ovdfjmdn" path="res://scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.gd" id="2_s6fkk"]
[ext_resource type="Texture2D" uid="uid://iddqk6g00rku" path="res://assets/enemy/RailgunEnemy.png" id="3_k5wkg"]
[node name="RailgunEnemy" instance=ExtResource("1_0ankw")]
script = ExtResource("2_s6fkk")
range = 1200
speed = 500
[node name="Sprite2D" parent="." index="2"]
texture = ExtResource("3_k5wkg")
[editable path="hurtArea"]
[editable path="VisionAreas/VisionArea"]
[editable path="VisionAreas/VisionAreaStop"]
[editable path="VisionAreas/VisionAreaEnemy"]

View file

@ -0,0 +1,6 @@
class_name ShotgunEnemy extends "res://scenes/spaceShip/enemy/enemy.gd"
func _ready() -> void:
changeWeapon(SHOTGUN)
setVision()

View file

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

View file

@ -0,0 +1,18 @@
[gd_scene load_steps=4 format=3 uid="uid://dcmfud0437rkx"]
[ext_resource type="PackedScene" uid="uid://bodpgjdjhfn4w" path="res://scenes/spaceShip/enemy/enemy.tscn" id="1_lma5b"]
[ext_resource type="Script" uid="uid://bxd6hh53c3h4p" path="res://scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.gd" id="2_3bd2j"]
[ext_resource type="Texture2D" uid="uid://dansb0wnm00vb" path="res://assets/enemy/shotgunEnemy.png" id="3_5lm6h"]
[node name="ShotgunEnemy" instance=ExtResource("1_lma5b")]
script = ExtResource("2_3bd2j")
range = 400
speed = 1200
[node name="Sprite2D" parent="." index="2"]
texture = ExtResource("3_5lm6h")
[editable path="hurtArea"]
[editable path="VisionAreas/VisionArea"]
[editable path="VisionAreas/VisionAreaStop"]
[editable path="VisionAreas/VisionAreaEnemy"]

View file

@ -1 +1,9 @@
class_name VisionArea extends Area2D
@onready var collisionShape = $CollisionShape2D
func _ready() -> void:
collisionShape.shape = CircleShape2D.new()
func changeViewSize(size: int):
collisionShape.shape.radius = size

View file

@ -0,0 +1,8 @@
extends Control
func _ready() -> void:
progressBarHealth.max_value = Globals.getPlayer().maxHealthh
func _physics_process(delta: float) -> void:

View file

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

View file

@ -0,0 +1,22 @@
extends Camera2D
var shake_duration: float = 0.5
var shake_magnitude: float = 10.0
var shake_timer: float = 0.0
var original_position: Vector2
func _ready():
original_position = position
func _process(delta: float) -> void:
if shake_timer > 0:
shake_timer -= delta
var offset = Vector2(randf_range(-shake_magnitude, shake_magnitude), randf_range(-shake_magnitude, shake_magnitude))
position = original_position + offset
else:
position = original_position
func shake(duration: float, magnitude: float) -> void:
shake_duration = duration
shake_magnitude = magnitude
shake_timer = shake_duration

View file

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

View file

@ -0,0 +1,10 @@
extends Control
@onready var moveButton = $MoveButton
@onready var shootButton = $ShootButton
@onready var shootButtonCorner = $ShootButtonCorner
@onready var moveButtonCorner = $MoveButtonCorner
func _physics_process(delta: float) -> void:
shootButton.global_position = shootButtonCorner.global_position
moveButton.global_position = moveButtonCorner.global_position

View file

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

View file

@ -1,42 +1,178 @@
class_name Player extends "res://scenes/spaceShip/spaceShip.gd"
@onready var dashCooldown = $dashCooldown
@onready var spawnPointPool = $spawnPointPool
@onready var timeGhostScene = preload("res://scenes/spaceShip/timeGhost/timeghost.tscn")
@onready var dashCooldown = $dashCooldown
@onready var selfHealTimer = $selfHealTimer
@onready var selfHealCountdownTimer = $selfHealCountdownTimer
@onready var progressBarHealth = $Camera2D/CanvasLayer/Control/VBoxContainer/HealthUi/ProgressBarHealth
@onready var progressBarSpeed = $Camera2D/CanvasLayer/Control/VBoxContainer/SpeedUi/ProgressBarSpeed
@onready var progressBarDashCooldown = $Camera2D/CanvasLayer/Control/VBoxContainer/DashCooldownUi/ProgressBarDashCooldown
@onready var progressBarWeaponCooldown = $Camera2D/CanvasLayer/Control/VBoxContainer/WeaponCooldown/ProgressBarWeaponCooldown
@onready var labelWaveInfo = $Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer/LabelWaveInfo
@onready var labelWaveEnemiesInfo = $Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer2/LabelWaveEnemiesInfo
@onready var labelWaveDestroyedInfo = $Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer3/LabelWaveDestroyedInfo
@onready var upgradeChooser = $Camera2D/CanvasLayer/Control/UpgradeChooser
@onready var hit = $hit
@onready var input = $Camera2D/CanvasLayer/Control/Input
@export var spawnDistance: int = 5000
var maxSpeedMult: float = 3
var maxAcceleration: float = 1
var speedMult: float = 1
var damageMult: float = 1
var dashUnlocked: bool = false
var strifeUnlocked: bool = false
var selfHealUnlocked: bool = false
@export var spawnDistance: int = 1000
func _ready() -> void:
if Globals.touchscreen:
input.show()
progressBarHealth.max_value = maxHealth
progressBarSpeed.max_value = speed / 2
progressBarDashCooldown.max_value = dashCooldown.wait_time
randomize()
func _init() -> void:
pass
changeWeapon(SHOTGUN)
progressBarWeaponCooldown.max_value = weapon.cooldown
shortInvincibility()
await get_tree().create_timer(Globals.currentDelay).timeout
addGhost()
newUpgrade()
Globals.waveComplete.connect(newUpgrade)
func _physics_process(delta: float) -> void:
#if Input.is_action_pressed("attack"):
#attack()
#
#look_at(get_global_mouse_position())
#rotation += PI / 2
#var direction = Vector2.UP.normalized().rotated(rotation) * Input.get_action_strength("moveForward")
##Input.get_vector("moveForward", "moveBackward").normalized().rotated(rotation)
#if Input.is_action_just_pressed("dash") and dashCooldown.is_stopped():
#dash()
#velocity = velocity.lerp(direction * speed, acceleration * delta)
#move_and_slide()
#if timeGhost != null:
#moveTimeGhost(global_position, rotation)
if Input.is_action_pressed("attack"):
attack()
look_at(get_global_mouse_position())
var controllerDirection = Input.get_vector("lookLeft", "lookRight", "lookForward", "lookDown")
controllerDirection
if controllerDirection == Vector2.ZERO:
look_at(get_global_mouse_position())
else:
look_at(global_position+controllerDirection)
rotation += PI / 2
var direction = Input.get_vector("moveLeft", "moveRight", "moveForward", "moveBackward").normalized().rotated(rotation)
if Input.is_action_just_pressed("dash") and dashCooldown.is_stopped():
var direction: Vector2
#if strifeUnlocked:
#direction = Input.get_vector("moveLeft", "moveRight", "moveForward", "moveBackward").normalized().rotated(rotation)
if Globals.touchscreen:
if Input.is_action_pressed("touchscreenForward"):
direction = Vector2.UP.normalized().rotated(rotation) * Input.get_action_strength("touchscreenForward")
else:
direction = Vector2.UP.normalized().rotated(rotation) * Input.get_action_strength("moveForward")
if Input.is_action_just_pressed("dash") and dashCooldown.is_stopped() and dashUnlocked:
dash()
velocity = velocity.lerp(direction * speed, acceleration * delta)
#if Input.is_action_pressed("moveForward") or Input.is_action_pressed("moveLeft") or Input.is_action_pressed("moveRight"):
if Input.is_action_pressed("moveForward") or Input.is_action_pressed("touchscreenForward"):
velocity = velocity.lerp(direction * speed * speedMult, 1 * delta)
move_and_slide()
if timeGhost != null:
moveTimeGhost(global_position, rotation)
setInterface()
func _on_hurt_area_hurt(amount: int) -> void:
damage(amount)
hit.play()
$Camera2D.shake(0.5, 5.0)
if selfHealUnlocked:
selfHealTimer.stop()
selfHealCountdownTimer.start()
func dash():
shortInvincibility()
dashCooldown.start()
global_position += Vector2.UP.rotated(rotation) * 1000
func getRandomSpawnPointPosition() -> Vector2:
var rng = RandomNumberGenerator.new()
print(deg_to_rad(rng.randi_range(0, 360)))
print(Vector2.UP.rotated(deg_to_rad(rng.randi_range(0, 360))) * spawnDistance)
return global_position + Vector2.UP.rotated(deg_to_rad(rng.randi_range(0, 360))) * spawnDistance
#return spawnPointPool.get_children()[rng.randi_range(0, spawnPointPool.get_children().size()-1)].global_position
func addGhost():
var _timeGhost = timeGhostScene.instantiate()
get_tree().get_first_node_in_group("timeGhostPool").add_child(_timeGhost)
addTimeGhost(_timeGhost)
func unlockDash():
dashUnlocked = true
func unlockStrife():
strifeUnlocked = true
func _on_self_heal_countdown_timeout() -> void:
selfHealTimer.start()
func _on_self_heal_timer_timeout() -> void:
if health >= maxHealth:
selfHealTimer.stop()
else:
heal(1)
selfHealTimer.start()
func setInterface():
if dashUnlocked:
$Camera2D/CanvasLayer/Control/VBoxContainer/DashCooldownUi.visible = true
progressBarHealth.value = Globals.getPlayer().health
progressBarSpeed.value = getVelocityMedian()
if dashCooldown.is_stopped():
progressBarDashCooldown.value = 0
else:
progressBarDashCooldown.value = dashCooldown.wait_time - dashCooldown.time_left
if weapon != null:
progressBarWeaponCooldown.value = weapon.cooldownTimer.wait_time - weapon.cooldownTimer.time_left
labelWaveInfo.text = str(Globals.currentWave)
labelWaveEnemiesInfo.text = str(Globals.enemyCount)
labelWaveDestroyedInfo.text = str(Globals.destroyedShips)
func getVelocityMedian() -> float:
var _velocity = velocity
if _velocity.x < 0:
_velocity.x *= -1
if _velocity.y < 0:
_velocity.y *= -1
return (_velocity.x + _velocity.y) / 2
func newUpgrade():
get_tree().paused = true
upgradeChooser.showUpgrades()
func addSpeedMult(mult: float):
if speedMult * mult > maxSpeedMult:
speedMult = maxSpeedMult
Globals.removeSpeedUPgrade()
else:
speedMult *= mult
func switchToMinigun():
changeWeapon(MINIGUN)
progressBarWeaponCooldown.max_value = weapon.cooldown
func switchToShotgun():
changeWeapon(SHOTGUN)
progressBarWeaponCooldown.max_value = weapon.cooldown
func switchToRailgun():
changeWeapon(RAILGUN)
progressBarWeaponCooldown.max_value = weapon.cooldown

View file

@ -1,8 +1,21 @@
[gd_scene load_steps=6 format=3 uid="uid://bmc2exqutt6vu"]
[gd_scene load_steps=19 format=3 uid="uid://bmc2exqutt6vu"]
[ext_resource type="PackedScene" uid="uid://csacin2gx2tum" path="res://scenes/spaceShip/spaceShip.tscn" id="1_nnn47"]
[ext_resource type="Script" uid="uid://0i8gdbb8f6ic" path="res://scenes/spaceShip/player/player.gd" id="2_acneu"]
[ext_resource type="Texture2D" uid="uid://cfwyw1sr6x2np" path="res://icon.svg" id="3_0gv45"]
[ext_resource type="Texture2D" uid="uid://cd5anydes4tv3" path="res://assets/player/shotgunShip.png" id="3_ah1lv"]
[ext_resource type="Texture2D" uid="uid://dlahm782n0awk" path="res://assets/player/minigunShip.png" id="4_1o0bm"]
[ext_resource type="Theme" uid="uid://bcbicfiflkrja" path="res://theme/interface.tres" id="4_o6j0d"]
[ext_resource type="Script" uid="uid://cb4i45ekmd2is" path="res://scenes/spaceShip/player/camera2d.gd" id="4_sk4ix"]
[ext_resource type="Texture2D" uid="uid://dhbn4acw1a6eu" path="res://assets/player/railgunShip.png" id="5_5sy6u"]
[ext_resource type="PackedScene" uid="uid://ha8undpo7d4d" path="res://scenes/upgradeChooser/upgradeChooser.tscn" id="5_nno2o"]
[ext_resource type="Texture2D" uid="uid://bwtb3m00d1gu2" path="res://assets/symbols/heart.png" id="6_sytd6"]
[ext_resource type="Texture2D" uid="uid://cmb78bi27e2jl" path="res://assets/ui/dash.png" id="7_qoa7h"]
[ext_resource type="AudioStream" uid="uid://xldfu6srikfp" path="res://assets/sound/hit.wav" id="7_sma6c"]
[ext_resource type="Script" uid="uid://ds2moov3l1dyk" path="res://scenes/spaceShip/player/input.gd" id="8_5l1u7"]
[ext_resource type="Texture2D" uid="uid://vxl26x3xc8ms" path="res://assets/ui/reload.png" id="8_48lx4"]
[ext_resource type="Texture2D" uid="uid://c0qub1plvyt4x" path="res://assets/ui/move.png" id="10_5l1u7"]
[ext_resource type="Texture2D" uid="uid://bgqfuj6p3h5ad" path="res://assets/ui/attack.png" id="11_5l1u7"]
[ext_resource type="Script" uid="uid://bqykrbwxdktxk" path="res://addons/virtual_joystick/virtual_joystick_instantiator.gd" id="13_1o0bm"]
[sub_resource type="CircleShape2D" id="CircleShape2D_0gv45"]
radius = 56.5685
@ -15,7 +28,11 @@ collision_layer = 12
collision_mask = 3
motion_mode = 1
script = ExtResource("2_acneu")
spawnDistance = 1000
spawnDistance = 5000
shotgunTexture = ExtResource("3_ah1lv")
minigunTexture = ExtResource("4_1o0bm")
railgunTexture = ExtResource("5_5sy6u")
invincible = true
[node name="CollisionShape2D" parent="." index="0"]
shape = SubResource("CircleShape2D_0gv45")
@ -24,30 +41,234 @@ shape = SubResource("CircleShape2D_0gv45")
shape = SubResource("RectangleShape2D_0gv45")
[node name="Sprite2D" parent="." index="2"]
texture = ExtResource("3_0gv45")
position = Vector2(0, -24)
[node name="dashCooldown" type="Timer" parent="." index="5"]
wait_time = 10.0
one_shot = true
autostart = true
[node name="Camera2D" type="Camera2D" parent="." index="6"]
[node name="selfHealTimer" type="Timer" parent="." index="6"]
one_shot = true
[node name="spawnPointPool" type="Node2D" parent="." index="7"]
[node name="selfHealCountdownTimer" type="Timer" parent="." index="7"]
wait_time = 10.0
one_shot = true
[node name="spawnPoint" type="Marker2D" parent="spawnPointPool" index="0"]
position = Vector2(360, -176)
[node name="Camera2D" type="Camera2D" parent="." index="8"]
script = ExtResource("4_sk4ix")
[node name="spawnPoint2" type="Marker2D" parent="spawnPointPool" index="1"]
position = Vector2(392, 256)
[node name="CanvasLayer" type="CanvasLayer" parent="Camera2D" index="0"]
[node name="spawnPoint3" type="Marker2D" parent="spawnPointPool" index="2"]
position = Vector2(-416, 224)
[node name="Control" type="Control" parent="Camera2D/CanvasLayer" index="0"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("4_o6j0d")
[node name="spawnPoint4" type="Marker2D" parent="spawnPointPool" index="3"]
position = Vector2(-408, -168)
[node name="Input" type="Control" parent="Camera2D/CanvasLayer/Control" index="0"]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("8_5l1u7")
[node name="Virtual Joystick" type="Control" parent="Camera2D/CanvasLayer/Control/Input" index="0"]
modulate = Color(1, 1, 1, 0.588235)
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -40.0
offset_right = 40.0
grow_vertical = 0
scale = Vector2(2.5, 2.5)
script = ExtResource("13_1o0bm")
metadata/_custom_type_script = "uid://bqykrbwxdktxk"
[node name="MoveButton" type="TouchScreenButton" parent="Camera2D/CanvasLayer/Control/Input" index="1"]
modulate = Color(1, 1, 1, 0.588235)
position = Vector2(1408, 576)
scale = Vector2(14, 14)
texture_normal = ExtResource("10_5l1u7")
action = "touchscreenForward"
[node name="ShootButton" type="TouchScreenButton" parent="Camera2D/CanvasLayer/Control/Input" index="2"]
modulate = Color(1, 1, 1, 0.588235)
position = Vector2(896, 560)
scale = Vector2(14, 14)
texture_normal = ExtResource("11_5l1u7")
action = "attack"
[node name="ShootButtonCorner" type="Control" parent="Camera2D/CanvasLayer/Control/Input" index="3"]
layout_mode = 1
anchor_left = 0.992
anchor_top = 0.985
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -1016.64
offset_top = -495.8
offset_right = -1024.0
offset_bottom = -504.0
grow_horizontal = 0
grow_vertical = 0
[node name="MoveButtonCorner" type="Control" parent="Camera2D/CanvasLayer/Control/Input" index="4"]
layout_mode = 1
anchor_left = 0.992
anchor_top = 0.985
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -504.64
offset_top = -495.8
offset_right = -512.0
offset_bottom = -504.0
grow_horizontal = 0
grow_vertical = 0
[node name="VBoxContainer" type="VBoxContainer" parent="Camera2D/CanvasLayer/Control" index="1"]
layout_mode = 1
offset_left = 64.0
offset_top = 64.0
offset_right = 1096.0
offset_bottom = 238.0
[node name="Weapon" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/VBoxContainer" index="0"]
layout_mode = 2
[node name="TextureRect" type="TextureRect" parent="Camera2D/CanvasLayer/Control/VBoxContainer/Weapon" index="0"]
layout_mode = 2
[node name="HealthUi" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/VBoxContainer" index="1"]
layout_mode = 2
[node name="TextureRect" type="TextureRect" parent="Camera2D/CanvasLayer/Control/VBoxContainer/HealthUi" index="0"]
layout_mode = 2
texture = ExtResource("6_sytd6")
expand_mode = 2
[node name="LabelHealth" type="Label" parent="Camera2D/CanvasLayer/Control/VBoxContainer/HealthUi" index="1"]
layout_mode = 2
[node name="ProgressBarHealth" type="ProgressBar" parent="Camera2D/CanvasLayer/Control/VBoxContainer/HealthUi" index="2"]
modulate = Color(1, 0, 0, 1)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
theme_override_font_sizes/font_size = 0
show_percentage = false
[node name="SpeedUi" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/VBoxContainer" index="2"]
visible = false
layout_mode = 2
[node name="LabelSpeed" type="Label" parent="Camera2D/CanvasLayer/Control/VBoxContainer/SpeedUi" index="0"]
layout_mode = 2
text = "S"
[node name="ProgressBarSpeed" type="ProgressBar" parent="Camera2D/CanvasLayer/Control/VBoxContainer/SpeedUi" index="1"]
layout_mode = 2
size_flags_horizontal = 3
step = 1.0
[node name="DashCooldownUi" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/VBoxContainer" index="3"]
visible = false
layout_mode = 2
[node name="TextureRect" type="TextureRect" parent="Camera2D/CanvasLayer/Control/VBoxContainer/DashCooldownUi" index="0"]
layout_mode = 2
texture = ExtResource("7_qoa7h")
expand_mode = 2
[node name="LabelDashCooldown" type="Label" parent="Camera2D/CanvasLayer/Control/VBoxContainer/DashCooldownUi" index="1"]
layout_mode = 2
[node name="ProgressBarDashCooldown" type="ProgressBar" parent="Camera2D/CanvasLayer/Control/VBoxContainer/DashCooldownUi" index="2"]
modulate = Color(0, 0.172549, 1, 1)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
show_percentage = false
[node name="WeaponCooldown" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/VBoxContainer" index="4"]
layout_mode = 2
[node name="TextureRect" type="TextureRect" parent="Camera2D/CanvasLayer/Control/VBoxContainer/WeaponCooldown" index="0"]
layout_mode = 2
texture = ExtResource("8_48lx4")
expand_mode = 2
[node name="LabelWeaponCooldown" type="Label" parent="Camera2D/CanvasLayer/Control/VBoxContainer/WeaponCooldown" index="1"]
layout_mode = 2
[node name="ProgressBarWeaponCooldown" type="ProgressBar" parent="Camera2D/CanvasLayer/Control/VBoxContainer/WeaponCooldown" index="2"]
modulate = Color(0.870588, 1, 0, 1)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
show_percentage = false
[node name="HBoxContainer" type="VBoxContainer" parent="Camera2D/CanvasLayer/Control" index="2"]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -560.0
offset_top = 64.0
offset_right = -61.0
offset_bottom = 321.0
grow_horizontal = 0
alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/HBoxContainer" index="0"]
layout_mode = 2
alignment = 1
[node name="LabelWave" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer" index="0"]
layout_mode = 2
text = "WAVE: "
[node name="LabelWaveInfo" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer" index="1"]
layout_mode = 2
[node name="HBoxContainer2" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/HBoxContainer" index="1"]
layout_mode = 2
alignment = 1
[node name="LabelWaveEnemies" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer2" index="0"]
layout_mode = 2
text = "Enemies: "
[node name="LabelWaveEnemiesInfo" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer2" index="1"]
layout_mode = 2
[node name="HBoxContainer3" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/HBoxContainer" index="2"]
layout_mode = 2
alignment = 1
[node name="LabelWaveDestroyed" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer3" index="0"]
layout_mode = 2
text = "Destroyed: "
[node name="LabelWaveDestroyedInfo" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer3" index="1"]
layout_mode = 2
[node name="UpgradeChooser" parent="Camera2D/CanvasLayer/Control" index="3" instance=ExtResource("5_nno2o")]
visible = false
layout_mode = 1
[node name="hit" type="AudioStreamPlayer2D" parent="." index="9"]
stream = ExtResource("7_sma6c")
[connection signal="hurt" from="hurtArea" to="." method="_on_hurt_area_hurt"]
[connection signal="timeout" from="dashCooldown" to="." method="_on_dash_cooldown_timeout"]
[connection signal="timeout" from="selfHealTimer" to="." method="_on_self_heal_timer_timeout"]
[connection signal="timeout" from="selfHealCountdownTimer" to="." method="_on_self_heal_countdown_timeout"]
[editable path="hurtArea"]

View file

@ -5,9 +5,21 @@ class_name Spaceship extends CharacterBody2D
@onready var weaponNode = $weaponNode
@onready var invincibleTimer = $invincibleTimer
@onready var MINIGUN = preload("res://scenes/weapon/minigun/minigun.tscn")
@onready var RAILGUN = preload("res://scenes/weapon/railgun/railgun.tscn")
@onready var SHOTGUN = preload("res://scenes/weapon/shotgun/shotgun.tscn")
@onready var radiationDamageTimer = $radiationDamageTimer
@onready var radiationDamage = $radiationDamage
@export var shotgunTexture: Texture2D
@export var minigunTexture: Texture2D
@export var railgunTexture: Texture2D
@export var minHealth: int = 0
@export var maxHealth: int = 100
@export var health: int = maxHealth
@onready var health: int = maxHealth
@export var speed: int = 800
@export var acceleration: float = 0.8
@ -16,23 +28,31 @@ class_name Spaceship extends CharacterBody2D
@export var timeGhost: TimeGhost = null
@export var weapon: Weapon = null
var currentWeapon: PackedScene
@export var invincible: bool = false
var currentRadiationDamage: int = 1
signal destroyed
func _init() -> void:
health = maxHealth
func _ready() -> void:
invincibleTimer.wait_time = Globals.currentDelay * 3
shortInvincibility()
func damage(amount: int):
if not invincible:
if health - amount <= minHealth:
if timeGhost == null:
emit_signal("destroyed")
if self.is_in_group("enemy"):
Globals.enemyDestroyed()
destroy()
health = minHealth
shortInvincibility()
health = maxHealth
else:
health -= amount
@ -44,6 +64,7 @@ func heal(amount: int):
func destroy():
if timeGhost == null:
destroyed.emit()
queue_free()
else:
timeGhost.destroy()
@ -63,19 +84,36 @@ func moveTimeGhost(_position: Vector2, _rotation: float):
timeGhost.moveTimeGhost(_position, _rotation)
func changeWeapon(_weapon: PackedScene):
currentWeapon = _weapon
var newWeapon = _weapon.instantiate()
for i in weaponNode.get_children():
i.queue_free()
weaponNode.add_child(newWeapon)
weapon = newWeapon
if newWeapon is Shotgun:
sprite.texture = shotgunTexture
elif newWeapon is Minigun:
sprite.texture = minigunTexture
elif newWeapon is Railgun:
sprite.texture = railgunTexture
await get_tree().create_timer(Globals.currentDelay).timeout
if timeGhost != null:
timeGhost.changeWeapon(_weapon)
#match newWeapon:
#Shotgun:
#sprite.texture = shotgunTexture
#Minigun:
#sprite.texture = minigunTexture
#Railgun:
#sprite.texture = railgunTexture
#
func addTimeGhost(_timeGhost: TimeGhost):
if timeGhost == null:
timeGhost = _timeGhost
timeGhost.setSpaceship(self)
timeGhost.changeWeapon(currentWeapon)
else:
timeGhost.addTimeGhost(_timeGhost)
@ -91,5 +129,19 @@ func _on_invincible_timer_timeout() -> void:
func _on_hurt_area_area_entered(area: Area2D) -> void:
if area.get_parent().is_in_group("obstacle"):
velocity = Vector2.UP.rotated(rotation) * -pushback
velocity = Vector2.UP.rotated(rad_to_deg(global_position.angle_to(area.global_position))) * -pushback
area.get_parent().queue_free()
func inceraseMaxhealth(increase: int):
maxHealth += increase
health += increase
func applyRadiation(amount: int):
if radiationDamageTimer.is_stopped():
currentRadiationDamage = amount
radiationDamageTimer.start()
func _on_radiation_damge_timer_timeout() -> void:
radiationDamage.play()
damage(currentRadiationDamage)

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=3 uid="uid://csacin2gx2tum"]
[gd_scene load_steps=4 format=3 uid="uid://csacin2gx2tum"]
[ext_resource type="Script" uid="uid://quxft75411y7" path="res://scenes/spaceShip/spaceShip.gd" id="1_a2e5l"]
[ext_resource type="PackedScene" uid="uid://cglnd1ekr5u6r" path="res://scenes/areas/hurtArea/hurtArea.tscn" id="2_b8guf"]
[ext_resource type="AudioStream" uid="uid://decf2fp3ve2v8" path="res://assets/sound/radiation.wav" id="3_6p3ob"]
[node name="Spaceship" type="CharacterBody2D" groups=["spaceShip"]]
collision_layer = 4
@ -19,5 +20,12 @@ script = ExtResource("1_a2e5l")
one_shot = true
autostart = true
[node name="radiationDamageTimer" type="Timer" parent="."]
one_shot = true
[node name="radiationDamage" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_6p3ob")
[connection signal="area_entered" from="hurtArea" to="." method="_on_hurt_area_area_entered"]
[connection signal="timeout" from="invincibleTimer" to="." method="_on_invincible_timer_timeout"]
[connection signal="timeout" from="radiationDamageTimer" to="." method="_on_radiation_damge_timer_timeout"]

View file

@ -1,11 +1,15 @@
class_name TimeGhost extends "res://scenes/spaceShip/spaceShip.gd"
@onready var damageArea = $DamageArea
@export var spaceShip: Spaceship = null
#func _init(_speed: int, _acceleration: float) -> void:
# speed = _speed
#acceleration = _acceleration
func _physics_process(delta: float) -> void:
move_and_slide()
@ -15,3 +19,8 @@ func setSpaceship(_spaceShip: Spaceship):
acceleration = spaceShip.acceleration
global_position = spaceShip.global_position
sprite.texture = spaceShip.sprite.texture
func _on_damage_area_area_entered(area: Area2D) -> void:
if area.get_parent().is_in_group("player"):
damageArea.damageHurtArea(area, Globals.getPlayer().maxHealth)

View file

@ -1,8 +1,11 @@
[gd_scene load_steps=6 format=3 uid="uid://dms0cw7opfd64"]
[gd_scene load_steps=9 format=3 uid="uid://dms0cw7opfd64"]
[ext_resource type="PackedScene" uid="uid://csacin2gx2tum" path="res://scenes/spaceShip/spaceShip.tscn" id="1_bm7fr"]
[ext_resource type="Script" uid="uid://m3hn5tl2nidk" path="res://scenes/spaceShip/timeGhost/timeghost.gd" id="2_57067"]
[ext_resource type="PackedScene" uid="uid://eqo7k2ronf8k" path="res://scenes/areas/damageArea/damageArea.tscn" id="3_5nmba"]
[ext_resource type="Texture2D" uid="uid://cd5anydes4tv3" path="res://assets/player/shotgunShip.png" id="3_37yrs"]
[ext_resource type="Texture2D" uid="uid://dlahm782n0awk" path="res://assets/player/minigunShip.png" id="4_s1boh"]
[ext_resource type="Texture2D" uid="uid://dhbn4acw1a6eu" path="res://assets/player/railgunShip.png" id="5_1tvm6"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5nmba"]
size = Vector2(50, 50)
@ -11,23 +14,24 @@ size = Vector2(50, 50)
size = Vector2(50, 50)
[node name="Timeghost" groups=["timeGhost"] instance=ExtResource("1_bm7fr")]
modulate = Color(0, 1, 1, 1)
modulate = Color(0.54902, 1, 1, 0.588235)
collision_layer = 20
script = ExtResource("2_57067")
shotgunTexture = ExtResource("3_37yrs")
minigunTexture = ExtResource("4_s1boh")
railgunTexture = ExtResource("5_1tvm6")
invincible = true
[node name="CollisionShape2D" parent="." index="0"]
shape = SubResource("RectangleShape2D_5nmba")
disabled = true
[node name="hurtArea" parent="." index="1"]
visible = false
[node name="DamageArea" parent="." index="4" instance=ExtResource("3_5nmba")]
damage = 10
[node name="CollisionShape2D" parent="DamageArea" index="0"]
shape = SubResource("RectangleShape2D_m3s7j")
disabled = true
[connection signal="area_entered" from="DamageArea" to="." method="_on_damage_area_area_entered"]
[editable path="hurtArea"]
[editable path="DamageArea"]

View file

@ -1,4 +1,9 @@
class_name Upgrade extends Node2D
class_name Upgrade extends Node
@onready var upgradeName: String = ""
@onready var description: String = ""
@export var texture: Texture2D
func select():
Globals.getPlayer()

View file

@ -2,7 +2,5 @@
[ext_resource type="Script" uid="uid://dww2ci11ovsub" path="res://scenes/upgrade/upgrade.gd" id="1_6bmsu"]
[node name="Upgrade" type="Node2D"]
[node name="Upgrade" type="Node"]
script = ExtResource("1_6bmsu")
[node name="Sprite2D" type="Sprite2D" parent="."]

View file

@ -0,0 +1,9 @@
class_name DamageUpgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "Damage Upgrade"
description = "Do 1 more Damage"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().damageMult + 1

View file

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

View file

@ -0,0 +1,10 @@
class_name DashUpgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "Dash Upgrade"
description = "Fast forward jump. Needs 30 seconds to recharge"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().dashUnlocked = true
Globals.getPlayer().dashCooldown.start()

View file

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

View file

@ -0,0 +1,9 @@
class_name Heal100Upgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "100% Health"
description = "Heals 100% of Health"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().heal(Globals.getPlayer().maxHealth)

View file

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

View file

@ -0,0 +1,9 @@
class_name Heal50Upgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "50% Health"
description = "Heals 50% of Health"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().heal(Globals.getPlayer().maxHealth/2)

View file

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

View file

@ -0,0 +1,9 @@
class_name HealthUpgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "Increase Health"
description = "Increase the amount of health you can have by 10"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().inceraseMaxhealth(10)

View file

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

View file

@ -0,0 +1,9 @@
class_name MinigunUpgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "Weapon Minigun"
description = "Switch Weapon to Minigun. Shoots fast but has a little bit of spread"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().switchToMinigun()

View file

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

View file

@ -0,0 +1,9 @@
class_name RailgunUpgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "Weapon Railgun"
description = "Switch Weapon to Railgun. Shoots slow but does a lot of damage and penetratres targets"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().switchToRailgun()

View file

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

View file

@ -0,0 +1,9 @@
class_name SelfHealUpgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "Self Heal Upgrade"
description = "Heal yourself after not taking damage for 10 seconds. After that you Heal 1 % health every second"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().selfHealUnlocked = true

View file

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

View file

@ -0,0 +1,9 @@
class_name ShotgunUpgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "Weapon Shotgun"
description = "Switch Weapon to Shotgun. Good on short range. Shoots multiple bullets with spread"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().switchToShotgun()

View file

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

View file

@ -0,0 +1,11 @@
class_name SpeedUpgrade extends "res://scenes/upgrade/upgrade.gd"
@export var damage: int = 1
func _init() -> void:
upgradeName = "Speed Upgrade"
description = "Increase speed by 10%"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().addSpeedMult(1.1)

View file

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

View file

@ -0,0 +1,9 @@
class_name StrafeUpgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "Strafe Upgrade"
description = "Move Left and Right"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().strifeUnlocked = true

View file

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

View file

@ -0,0 +1,9 @@
class_name TimeGhostUpgrade extends "res://scenes/upgrade/upgrade.gd"
func _init() -> void:
upgradeName = "Add Timeghost"
description = "Adds A Timeghost which repeats all actions you make. Acts as an extra life in case you get destroyed"
func select():
if Globals.getPlayer() != null:
Globals.getPlayer().addGhost()

View file

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

View file

@ -0,0 +1,17 @@
class_name Choice extends MarginContainer
@onready var nameLabel = $VBoxContainer/nameLabel
@onready var description = $VBoxContainer/description
var option: int
signal selected(_option: int)
func setValues(_text: String, _description: String, _option: int) -> void:
nameLabel.text = _text
description.text = _description
option = _option
func _on_button_pressed() -> void:
get_tree().paused = false
selected.emit(option)

View file

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

View file

@ -0,0 +1,40 @@
[gd_scene load_steps=2 format=3 uid="uid://cr7q4nm5daxmt"]
[ext_resource type="Script" uid="uid://dcgxmxoarxn0v" path="res://scenes/upgradeChooser/choice/choice.gd" id="1_ovap3"]
[node name="choice" type="MarginContainer"]
process_mode = 3
anchors_preset = -1
anchor_right = 0.0659583
anchor_bottom = 0.177963
offset_right = 1.35999
offset_bottom = -0.200005
size_flags_horizontal = 3
script = ExtResource("1_ovap3")
metadata/_edit_use_anchors_ = true
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
alignment = 1
[node name="nameLabel" type="Label" parent="VBoxContainer"]
layout_mode = 2
text = "test"
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
layout_mode = 2
[node name="description" type="RichTextLabel" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
text = "test"
fit_content = true
[node name="HSeparator2" type="HSeparator" parent="VBoxContainer"]
layout_mode = 2
[node name="Button" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Select"
[connection signal="pressed" from="VBoxContainer/Button" to="." method="_on_button_pressed"]

View file

@ -0,0 +1,45 @@
extends Control
@onready var choice = preload("res://scenes/upgradeChooser/choice/choice.tscn")
@onready var choiceContainer = $CenterContainer/VBoxContainer/ChoiceContainer
@onready var select = $select
func _ready() -> void:
randomize()
func showUpgrades():
show()
for i in choiceContainer.get_children():
i.queue_free()
var selectableUpgrades = getRandomUpgrades(3)
for i in selectableUpgrades:
addChoice(i)
func getRandomUpgrades(amount: int) -> Array[int]:
var selectableUpgrades: Array[int]
var rng = RandomNumberGenerator.new()
for i in range(0, amount):
var choice: int = rng.randi_range(0, Globals.getUpgrades().size()-1)
if choice in selectableUpgrades:
choice = rng.randi_range(0, Globals.getUpgrades().size()-1)
selectableUpgrades.append(choice)
return selectableUpgrades
func addChoice(option: int):
var _choice: Choice = choice.instantiate()
choiceContainer.add_child(_choice)
_choice.setValues(Globals.getUpgrade(option).upgradeName, Globals.getUpgrade(option).description, option)
_choice.selected.connect(choose)
func choose(option: int):
select.play()
var test = StrafeUpgrade.new()
Globals.getUpgrade(option).select()
if Globals.getUpgrade(option) is DashUpgrade or Globals.getUpgrade(option) is StrafeUpgrade or Globals.getUpgrade(option) is SelfHealUpgrade:
Globals.removeUpgrade(option)
hide()

View file

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

View file

@ -0,0 +1,46 @@
[gd_scene load_steps=3 format=3 uid="uid://ha8undpo7d4d"]
[ext_resource type="Script" uid="uid://l4hm6nxyte6r" path="res://scenes/upgradeChooser/upgradeChooser.gd" id="1_6njr4"]
[ext_resource type="AudioStream" uid="uid://bspgis3hy5scl" path="res://assets/sound/upgrade.wav" id="3_xdubl"]
[node name="UpgradeChooser" type="Control"]
process_mode = 3
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_6njr4")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0.333333)
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
layout_mode = 2
alignment = 1
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer"]
layout_mode = 2
text = "Upgrades"
[node name="ChoiceContainer" type="GridContainer" parent="CenterContainer/VBoxContainer"]
layout_mode = 2
columns = 6
[node name="select" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_xdubl")

View file

@ -4,11 +4,12 @@ class_name Minigun extends "res://scenes/weapon/weapon.gd"
func attack():
if cooldownTimer.is_stopped():
print(getSpread())
shoot.play()
spawnBullet()
cooldownTimer.start(cooldown)
func spawnBullet():
var newBullet = bullet.instantiate()
get_tree().get_first_node_in_group("bulletPool").add_child(newBullet)
var newBullet: Bullet = bullet.instantiate()
newBullet.spawn(bulletPoint.global_position, get_parent().get_parent().rotation + getSpread(), damage, range, penetration)
newBullet.fromTimeGhost = get_parent().get_parent().is_in_group("timeGhost")
get_tree().get_first_node_in_group("bulletPool").add_child(newBullet)

View file

@ -4,11 +4,12 @@ class_name Railgun extends "res://scenes/weapon/weapon.gd"
func attack():
if cooldownTimer.is_stopped():
shoot.play()
spawnBullet()
cooldownTimer.start(cooldown)
func spawnBullet():
var newBullet = bullet.instantiate()
newBullet.spawn(bulletPoint.global_position, get_parent().get_parent().rotation, damage, penetration)
var newBullet: Bullet = bullet.instantiate()
newBullet.spawn(bulletPoint.global_position, get_parent().get_parent().rotation, damage, penetration, bulletSpeed)
newBullet.fromTimeGhost = get_parent().get_parent().is_in_group("timeGhost")
get_tree().get_first_node_in_group("bulletPool").add_child(newBullet)

View file

@ -5,9 +5,10 @@
[node name="Railgun" instance=ExtResource("1_lb4uk")]
script = ExtResource("2_ur8td")
damage = 10
cooldown = 10.0
damage = 20
cooldown = 5.0
penetration = 5
bulletSpeed = 50.0
[node name="cooldownTimer" parent="." index="0"]
wait_time = 10.0

View file

@ -6,13 +6,13 @@ class_name Shotgun extends "res://scenes/weapon/weapon.gd"
func attack():
if cooldownTimer.is_stopped():
shoot.play()
spawnBullet()
cooldownTimer.start(cooldown)
func spawnBullet():
var rng = RandomNumberGenerator.new()
for i in range(0, bulletAmount):
var newBullet = bullet.instantiate()
newBullet.spawn(bulletPoint.global_position, get_parent().get_parent().rotation + getSpread(), damage, range, penetration)
newBullet.fromTimeGhost = get_parent().get_parent().is_in_group("timeGhost")
get_tree().get_first_node_in_group("bulletPool").add_child(newBullet)

View file

@ -3,13 +3,17 @@ class_name Weapon extends Node2D
@onready var bulletPoint = $BulletPoint
@onready var cooldownTimer = $cooldownTimer
@onready var shoot = $shoot
@export var damage: int = 1
@export var cooldown: float = 0.1
@export var penetration: int = 1
@export var spread: float = 0.1
@export var range: float = 8.0
@export var bulletSpeed: float = 10
func attack():
shoot.play()
randomize()
if cooldownTimer.is_stopped():
cooldownTimer.start(cooldown)

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://btyuxgfn12p1y"]
[gd_scene load_steps=3 format=3 uid="uid://btyuxgfn12p1y"]
[ext_resource type="Script" uid="uid://dpfc01642pwq0" path="res://scenes/weapon/weapon.gd" id="1_l3xq3"]
[ext_resource type="AudioStream" uid="uid://bi2ee654gcg2y" path="res://assets/sound/shooot2.wav" id="2_jej8l"]
[node name="Weapon" type="Node2D" groups=["weapon"]]
script = ExtResource("1_l3xq3")
@ -10,3 +11,7 @@ one_shot = true
[node name="BulletPoint" type="Marker2D" parent="."]
position = Vector2(0, -128)
[node name="shoot" type="AudioStreamPlayer2D" parent="."]
position = Vector2(0, -128)
stream = ExtResource("2_jej8l")