added Graphics and sound Effects and more overhauls
This commit is contained in:
parent
c887a2168c
commit
b9d4288900
214 changed files with 3378 additions and 198 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
5
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.gd
Normal file
5
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class_name MinigunEnemy extends "res://scenes/spaceShip/enemy/enemy.gd"
|
||||
|
||||
func _ready() -> void:
|
||||
changeWeapon(MINIGUN)
|
||||
setVision()
|
||||
1
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.gd.uid
Normal file
1
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dbxjdkvkkv5cm
|
||||
16
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.tscn
Normal file
16
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.tscn
Normal 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"]
|
||||
5
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.gd
Normal file
5
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class_name RailgunEnemy extends "res://scenes/spaceShip/enemy/enemy.gd"
|
||||
|
||||
func _ready() -> void:
|
||||
changeWeapon(RAILGUN)
|
||||
setVision()
|
||||
1
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.gd.uid
Normal file
1
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cjge3ovdfjmdn
|
||||
18
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.tscn
Normal file
18
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.tscn
Normal 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"]
|
||||
6
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.gd
Normal file
6
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class_name ShotgunEnemy extends "res://scenes/spaceShip/enemy/enemy.gd"
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
changeWeapon(SHOTGUN)
|
||||
setVision()
|
||||
1
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.gd.uid
Normal file
1
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bxd6hh53c3h4p
|
||||
18
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.tscn
Normal file
18
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.tscn
Normal 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"]
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue