Initial Invader concept added

This commit is contained in:
Rain Clark 2024-05-14 20:08:32 -04:00
parent 8319ddf25a
commit 01f939df48
12 changed files with 326 additions and 2 deletions

BIN
assets/_RAW_/invader.pxo Normal file

Binary file not shown.

BIN
assets/img/invader.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://7n0aykgeuaaw"
path="res://.godot/imported/invader.png-e15e275fc7b6a81f2ac56e1169e2bfc2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/img/invader.png"
dest_files=["res://.godot/imported/invader.png-e15e275fc7b6a81f2ac56e1169e2bfc2.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
assets/sfx/crash2.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://tvb2iqqjjsnq"
path="res://.godot/imported/crash2.wav-7a2662502c34f1d9181d94c8e86425a0.sample"
[deps]
source_file="res://assets/sfx/crash2.wav"
dest_files=["res://.godot/imported/crash2.wav-7a2662502c34f1d9181d94c8e86425a0.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

BIN
assets/sfx/invader.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bb8i4s5bv1r4j"
path="res://.godot/imported/invader.wav-17eecca55097f63b87a6a4e28e915787.sample"
[deps]
source_file="res://assets/sfx/invader.wav"
dest_files=["res://.godot/imported/invader.wav-17eecca55097f63b87a6a4e28e915787.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

BIN
assets/sfx/shoot2.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bg2eft275t8xi"
path="res://.godot/imported/shoot2.wav-93cee12f82dd277d215b2c88cec2c4c4.sample"
[deps]
source_file="res://assets/sfx/shoot2.wav"
dest_files=["res://.godot/imported/shoot2.wav-93cee12f82dd277d215b2c88cec2c4c4.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

154
scenes/invader.tscn Normal file
View File

@ -0,0 +1,154 @@
[gd_scene load_steps=15 format=3 uid="uid://du1namnd5kxs4"]
[ext_resource type="Texture2D" uid="uid://7n0aykgeuaaw" path="res://assets/img/invader.png" id="1_3tryp"]
[ext_resource type="Script" path="res://scripts/invader.gd" id="1_vblvx"]
[ext_resource type="Shader" path="res://assets/shaders/PixelExplosion.gdshader" id="2_bav6d"]
[ext_resource type="AudioStream" uid="uid://bb8i4s5bv1r4j" path="res://assets/sfx/invader.wav" id="3_orakw"]
[ext_resource type="AudioStream" uid="uid://tvb2iqqjjsnq" path="res://assets/sfx/crash2.wav" id="4_5jebg"]
[ext_resource type="AudioStream" uid="uid://bg2eft275t8xi" path="res://assets/sfx/shoot2.wav" id="5_c2cqd"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_2etwc"]
noise_type = 0
seed = -13
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_ca84o"]
width = 64
height = 64
generate_mipmaps = false
noise = SubResource("FastNoiseLite_2etwc")
[sub_resource type="FastNoiseLite" id="FastNoiseLite_wjoqq"]
noise_type = 0
seed = -13
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_vfidg"]
width = 64
height = 64
generate_mipmaps = false
noise = SubResource("FastNoiseLite_wjoqq")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7qjt1"]
resource_local_to_scene = true
shader = ExtResource("2_bav6d")
shader_parameter/progress = null
shader_parameter/strength = 1.0
shader_parameter/noise_tex_normal = SubResource("NoiseTexture2D_vfidg")
shader_parameter/noise_tex = SubResource("NoiseTexture2D_ca84o")
[sub_resource type="Animation" id="Animation_l62j8"]
resource_name = "crash"
length = 0.4
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("CrashSound:playing")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/1/type = "method"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.4, 0.4001),
"transitions": PackedFloat32Array(1, 1),
"values": [{
"args": [],
"method": &"queue_free"
}, {
"args": [],
"method": &"queue_free"
}]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Sprite2D:material:shader_parameter/progress")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [null, 0.33, 0.66, 1.0]
}
[sub_resource type="Animation" id="Animation_cojig"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("CrashSound:playing")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite2D:material:shader_parameter/progress")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [null]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_1dk2o"]
_data = {
"RESET": SubResource("Animation_cojig"),
"crash": SubResource("Animation_l62j8")
}
[node name="Invader" type="Area2D"]
collision_layer = 3
collision_mask = 3
script = ExtResource("1_vblvx")
[node name="Sprite2D" type="Sprite2D" parent="."]
material = SubResource("ShaderMaterial_7qjt1")
texture = ExtResource("1_3tryp")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
polygon = PackedVector2Array(12, -15, 16, -10, 24, -10, 29, -6, 32, -2, 10, 15, -3, 15, -31, -1, -31, -3, -23, -10, -15, -10, -10, -15)
[node name="FlyingTone" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_orakw")
autoplay = true
[node name="ShootSound" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource("5_c2cqd")
[node name="CrashSound" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("4_5jebg")
[node name="ShootTimer" type="Timer" parent="."]
autostart = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_1dk2o")
}
[node name="GunMarker" type="Marker2D" parent="."]
position = Vector2(2, 17)
[node name="Projectiles" type="Node" parent="."]
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
[connection signal="finished" from="FlyingTone" to="." method="_on_flying_tone_finished"]
[connection signal="timeout" from="ShootTimer" to="." method="_on_shoot_timer_timeout"]

View File

@ -1,7 +1,5 @@
extends Node2D extends Node2D
# TODO: MAYBE make ufo enemey that randomly flies in from ones side to the other
const COMET_SPAWNER = preload("res://scenes/comet_spawner.tscn") const COMET_SPAWNER = preload("res://scenes/comet_spawner.tscn")
@export var level : int = 1 @export var level : int = 1

66
scripts/invader.gd Normal file
View File

@ -0,0 +1,66 @@
extends Area2D
# TODO: Make a random spawner for invaders
# TODO: Give points if shot
signal shot
const BULLET = preload("res://scenes/bullet.tscn")
@export var move_speed := 100.0
var movement_direction := Vector2.ZERO
var random_position := Vector2.ZERO
var can_shoot := false
var viewport_size : Vector2
func _ready() -> void:
viewport_size = get_viewport_rect().size
# I am sorry to who has to make sense of this
random_position.x = randi_range(1, 2)
if random_position.x == 2:
random_position.x = viewport_size.x-1
movement_direction.x = -1
else:
movement_direction.x = 1
random_position.y = randi_range(32, viewport_size.y + 32)
position = random_position
func _process(delta: float) -> void:
position += move_speed * movement_direction * delta
if can_shoot:
# FIXME: Proper shoot angle and not able to sudoku
shoot($GunMarker.global_position, randf_range(90.0, 100.0))
# "Die", if off screen
if position.x > viewport_size.x or position.x < 0:
queue_free()
func _on_flying_tone_finished() -> void:
$FlyingTone.play()
func _on_body_entered(body: Node2D) -> void:
if body.is_in_group("ship"):
body.crash()
func _on_area_entered(area: Area2D) -> void:
if area.is_in_group("bullet"):
shot.emit()
crash()
func shoot(pos : Vector2, rot : float) -> void:
var bullet := BULLET.instantiate()
bullet.position = pos
bullet.rotation = rot
$Projectiles.add_child(bullet)
$ShootSound.play()
can_shoot = false
$ShootTimer.start()
func crash() -> void:
$AnimationPlayer.play("crash")
func _on_shoot_timer_timeout() -> void:
can_shoot = true