From 02ea283fa519372dc708a455a6c17aa66b380221 Mon Sep 17 00:00:00 2001 From: qwertzuiopy Date: Sat, 22 Mar 2025 13:32:53 +0100 Subject: [PATCH] an enemy :3 --- bullet/bullet.gd | 19 ++++ bullet/bullet.gd.uid | 1 + bullet/bullet.png | Bin 0 -> 171 bytes bullet/bullet.png.import | 34 +++++++ bullet/bullet.tscn | 155 +++++++++++++++++++++++++++++ bullet/bullet_colors.png | Bin 0 -> 83 bytes bullet/bullet_colors.png.import | 34 +++++++ effects/flash.gd | 16 +++ effects/flash.gd.uid | 1 + effects/flash.tscn | 99 ++++++++++++++++++ enemies/basic/basic.gd | 37 +++++++ enemies/basic/basic.gd.uid | 1 + enemies/basic/basic.png | Bin 0 -> 305 bytes enemies/basic/basic.png.import | 34 +++++++ enemies/basic/basic.tscn | 142 ++++++++++++++++++++++++++ enemies/dirmodule.gd | 28 ++++++ enemies/dirmodule.gd.uid | 1 + enemies/shootmodule.gd | 26 +++++ enemies/shootmodule.gd.uid | 1 + hud/radar/radar.gd | 30 ++++++ hud/radar/radar.gd.uid | 1 + hud/radar/radar.tscn | 9 ++ hud/radar/threat.gd | 21 ++++ hud/radar/threat.gd.uid | 1 + hud/radar/threat.tscn | 52 ++++++++++ hud/radar/threat_normal.png | Bin 0 -> 105 bytes hud/radar/threat_normal.png.import | 34 +++++++ main.tscn | 22 ++-- palette.png | Bin 229 -> 282 bytes player/player.gd | 6 ++ player/player.tscn | 100 ++++++++++++++++++- player/railgun.gd | 29 ++++++ player/railgun.gd.uid | 1 + player/thruster.gd | 7 +- player/thruster.tscn | 15 ++- project.godot | 6 ++ 36 files changed, 950 insertions(+), 13 deletions(-) create mode 100644 bullet/bullet.gd create mode 100644 bullet/bullet.gd.uid create mode 100644 bullet/bullet.png create mode 100644 bullet/bullet.png.import create mode 100644 bullet/bullet.tscn create mode 100644 bullet/bullet_colors.png create mode 100644 bullet/bullet_colors.png.import create mode 100644 effects/flash.gd create mode 100644 effects/flash.gd.uid create mode 100644 effects/flash.tscn create mode 100644 enemies/basic/basic.gd create mode 100644 enemies/basic/basic.gd.uid create mode 100644 enemies/basic/basic.png create mode 100644 enemies/basic/basic.png.import create mode 100644 enemies/basic/basic.tscn create mode 100644 enemies/dirmodule.gd create mode 100644 enemies/dirmodule.gd.uid create mode 100644 enemies/shootmodule.gd create mode 100644 enemies/shootmodule.gd.uid create mode 100644 hud/radar/radar.gd create mode 100644 hud/radar/radar.gd.uid create mode 100644 hud/radar/radar.tscn create mode 100644 hud/radar/threat.gd create mode 100644 hud/radar/threat.gd.uid create mode 100644 hud/radar/threat.tscn create mode 100644 hud/radar/threat_normal.png create mode 100644 hud/radar/threat_normal.png.import create mode 100644 player/railgun.gd create mode 100644 player/railgun.gd.uid diff --git a/bullet/bullet.gd b/bullet/bullet.gd new file mode 100644 index 0000000..4a50849 --- /dev/null +++ b/bullet/bullet.gd @@ -0,0 +1,19 @@ +extends RigidBody2D +class_name Bullet + +var player : Player +@export var flash : PackedScene = preload("res://effects/flash.tscn") +var pref : int = 0 + +func _integrate_forces(state) -> void: + pref += 1 + if state.get_contact_count() > 0 && pref > 10: + pref = 0 + var instance = flash.instantiate() + instance.global_position = state.get_contact_collider_position(0) + get_parent().add_child(instance) + + +func _on_body_entered(body: Node) -> void: + if body != Player and $animation.current_animation_position < 8: + $animation.seek(8) diff --git a/bullet/bullet.gd.uid b/bullet/bullet.gd.uid new file mode 100644 index 0000000..827f9bc --- /dev/null +++ b/bullet/bullet.gd.uid @@ -0,0 +1 @@ +uid://c3eechg8hdpsc diff --git a/bullet/bullet.png b/bullet/bullet.png new file mode 100644 index 0000000000000000000000000000000000000000..40fd1eb801a86297b7b98be4485b2df622b0e02b GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqMV>B>Are!2&nxmZ2Z*>_{471o zL2KWNj13%SL1(ir=CCxXa=5TA^kg-i&*r{qk=+X$CrF+=_-fO`#E2n&qnKR+-?9~~55103M<$b(9@!^}Z`tz&| V6Hc>@)7r6ic literal 0 HcmV?d00001 diff --git a/bullet/bullet_colors.png.import b/bullet/bullet_colors.png.import new file mode 100644 index 0000000..5b461d8 --- /dev/null +++ b/bullet/bullet_colors.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://coegvp4cunsnn" +path="res://.godot/imported/bullet_colors.png-6427ad6150c8a2cb40e110dd08b6f774.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://bullet/bullet_colors.png" +dest_files=["res://.godot/imported/bullet_colors.png-6427ad6150c8a2cb40e110dd08b6f774.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 diff --git a/effects/flash.gd b/effects/flash.gd new file mode 100644 index 0000000..814fef9 --- /dev/null +++ b/effects/flash.gd @@ -0,0 +1,16 @@ +extends Node2D +class_name Flash + +@export var oneshot : bool = true + +func _ready() -> void: + if oneshot: + flash() + +func flash() -> void: + if oneshot or not $animation.is_playing(): + $animation.play("flash") + +func destroy() -> void: + if oneshot: + queue_free() diff --git a/effects/flash.gd.uid b/effects/flash.gd.uid new file mode 100644 index 0000000..30f34f1 --- /dev/null +++ b/effects/flash.gd.uid @@ -0,0 +1 @@ +uid://ddh5k2bh3mqp7 diff --git a/effects/flash.tscn b/effects/flash.tscn new file mode 100644 index 0000000..c6ab9e6 --- /dev/null +++ b/effects/flash.tscn @@ -0,0 +1,99 @@ +[gd_scene load_steps=10 format=3 uid="uid://800ou0i3omcs"] + +[ext_resource type="Texture2D" uid="uid://coegvp4cunsnn" path="res://bullet/bullet_colors.png" id="1_7hhmj"] +[ext_resource type="Script" uid="uid://ddh5k2bh3mqp7" path="res://effects/flash.gd" id="1_xcggr"] + +[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_qjkh3"] +particles_animation = true +particles_anim_h_frames = 4 +particles_anim_v_frames = 1 +particles_anim_loop = false + +[sub_resource type="Curve" id="Curve_yw30f"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.188953, 1), 0.0, 0.0, 0, 0, Vector2(0.549419, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 4 + +[sub_resource type="CurveTexture" id="CurveTexture_qjkh3"] +curve = SubResource("Curve_yw30f") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_yw30f"] +particle_flag_disable_z = true +angle_min = -720.0 +angle_max = 720.0 +spread = 180.0 +initial_velocity_min = 20.0 +initial_velocity_max = 20.0 +gravity = Vector3(0, 0, 0) +damping_min = 30.0 +damping_max = 30.0 +scale_curve = SubResource("CurveTexture_qjkh3") +anim_offset_max = 1.0 + +[sub_resource type="Animation" id="Animation_qjkh3"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("particles:emitting") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} + +[sub_resource type="Animation" id="Animation_yw30f"] +resource_name = "flash" +length = 0.6 +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("particles:emitting") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.1), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [true, false] +} +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.6), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"destroy" +}] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_g6k8r"] +_data = { +&"RESET": SubResource("Animation_qjkh3"), +&"flash": SubResource("Animation_yw30f") +} + +[node name="flash" type="Node2D"] +script = ExtResource("1_xcggr") + +[node name="particles" type="GPUParticles2D" parent="."] +modulate = Color(2, 2, 2, 1) +material = SubResource("CanvasItemMaterial_qjkh3") +emitting = false +amount = 100 +texture = ExtResource("1_7hhmj") +lifetime = 0.3 +process_material = SubResource("ParticleProcessMaterial_yw30f") + +[node name="animation" type="AnimationPlayer" parent="."] +libraries = { +&"": SubResource("AnimationLibrary_g6k8r") +} diff --git a/enemies/basic/basic.gd b/enemies/basic/basic.gd new file mode 100644 index 0000000..9c5fca4 --- /dev/null +++ b/enemies/basic/basic.gd @@ -0,0 +1,37 @@ +extends RigidBody2D + +@export var player : Player + +@onready var dirmodule: DirModule = $dirmodule +@onready var shootmodule: ShootModule = $shootmodule + +@onready var thruster: Thruster = $thruster + +@export var thrust: float = 0.3 + +func _ready() -> void: + player.radar.declare_threat(self) +func _exit_tree() -> void: + player.radar.release_threat(self) + +func _physics_process(_delta: float) -> void: + if player == null: + print("no target for enemy!") + return + + dirmodule.active = true + dirmodule.target_position = player.global_position - 2.0 * linear_velocity.project((global_position-player.global_position).normalized().rotated(PI/2)) + var diff : float = Vector2.UP.rotated(global_rotation).dot((global_position - dirmodule.target_position).normalized()) + + if diff < -0.3: + apply_central_impulse(thrust * Vector2.UP.rotated(global_rotation)) + thruster.active = true + else: + thruster.active = false + + if diff < -0.9 && not $animations.is_playing() && shootmodule.can_shoot: + $animations.play("shoot") + player.radar.declare_danger(self) + +func done_shooting() -> void: + player.radar.release_danger(self) diff --git a/enemies/basic/basic.gd.uid b/enemies/basic/basic.gd.uid new file mode 100644 index 0000000..07f8c30 --- /dev/null +++ b/enemies/basic/basic.gd.uid @@ -0,0 +1 @@ +uid://buxbgc2aypffw diff --git a/enemies/basic/basic.png b/enemies/basic/basic.png new file mode 100644 index 0000000000000000000000000000000000000000..a142c1aff75a40c42d7433fb354d4a108ef300be GIT binary patch literal 305 zcmV-10nYx3P)n0nHbfvs$;@uG9iFfGrDu1U08_K`P8?WY|Y3{o}+mbE`DZpD~8i? z+B`?|D8o$#28L231Bljq6G}h%^O-o!voz+xoz{Kbn&HWx&kW0NdtjAE(L76I-v65n zs9^bR4~7>PPoTI4*#H!qpZxjE5UIKY!+FncKVj&u void: + if not active: + return + + var diff := parent.global_position.angle_to_point(target_position) - parent.global_rotation + offset + while diff < -PI: + diff += PI * 2 + while diff > PI: + diff -= PI * 2 + var closeness: float = abs(diff) / PI + parent.apply_torque_impulse( + pos_factor * sign(diff) * pos_controll.sample_baked(closeness) + - vel_factor * sign(parent.angular_velocity) * vel_controll.sample_baked(closeness)) diff --git a/enemies/dirmodule.gd.uid b/enemies/dirmodule.gd.uid new file mode 100644 index 0000000..95a4ae1 --- /dev/null +++ b/enemies/dirmodule.gd.uid @@ -0,0 +1 @@ +uid://v8qsd63ypr1y diff --git a/enemies/shootmodule.gd b/enemies/shootmodule.gd new file mode 100644 index 0000000..f19d0d7 --- /dev/null +++ b/enemies/shootmodule.gd @@ -0,0 +1,26 @@ +extends Marker2D +class_name ShootModule + +@export var bullet: PackedScene +@export var speed: float = 100.0 +@export var knockback: float = 10.0 +@export var timeout: float = 2.0 + +var can_shoot: bool = true + +@onready var parent: RigidBody2D = get_parent() + +func shoot() -> void: + if not can_shoot: + return + var instance : Bullet = bullet.instantiate() as Bullet + parent.get_parent().add_child(instance) + instance.global_position = global_position + instance.apply_central_impulse(Vector2.UP.rotated(global_rotation) * speed) + instance.apply_central_impulse(parent.linear_velocity.project(Vector2.UP.rotated(global_rotation))) + instance.player = parent.player + parent.apply_central_impulse(Vector2.DOWN.rotated(global_rotation) * knockback) + $flash.flash() + can_shoot = false + await get_tree().create_timer(timeout).timeout + can_shoot = true diff --git a/enemies/shootmodule.gd.uid b/enemies/shootmodule.gd.uid new file mode 100644 index 0000000..f25d355 --- /dev/null +++ b/enemies/shootmodule.gd.uid @@ -0,0 +1 @@ +uid://cuohktgei6yfn diff --git a/hud/radar/radar.gd b/hud/radar/radar.gd new file mode 100644 index 0000000..b14e15e --- /dev/null +++ b/hud/radar/radar.gd @@ -0,0 +1,30 @@ +extends Node2D +class_name Radar + +@export var threat_packed: PackedScene + +func declare_threat(node: Node2D) -> void: + var instance: Threat = threat_packed.instantiate() + instance.node = node + add_child(instance) + +func release_threat(node: Node2D) -> void: + for i: int in get_child_count(): + var threat: Threat = get_child(i) + if threat.node == node: + remove_child(threat) + return + +func declare_danger(node: Node2D) -> void: + for i: int in get_child_count(): + var threat: Threat = get_child(i) + if threat.node == node: + threat.declare_danger() +func release_danger(node: Node2D) -> void: + for i: int in get_child_count(): + var threat: Threat = get_child(i) + if threat.node == node: + threat.release_danger() + +func _process(_delta: float) -> void: + global_rotation = 0.0 diff --git a/hud/radar/radar.gd.uid b/hud/radar/radar.gd.uid new file mode 100644 index 0000000..11df950 --- /dev/null +++ b/hud/radar/radar.gd.uid @@ -0,0 +1 @@ +uid://s6xe11km41qe diff --git a/hud/radar/radar.tscn b/hud/radar/radar.tscn new file mode 100644 index 0000000..554ac46 --- /dev/null +++ b/hud/radar/radar.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=3 format=3 uid="uid://dfm1atk5lpdo4"] + +[ext_resource type="Script" uid="uid://s6xe11km41qe" path="res://hud/radar/radar.gd" id="1_jp2lf"] +[ext_resource type="PackedScene" uid="uid://dwk5lnfnntqh2" path="res://hud/radar/threat.tscn" id="2_23wok"] + +[node name="radar" type="Node2D"] +z_index = 1 +script = ExtResource("1_jp2lf") +threat_packed = ExtResource("2_23wok") diff --git a/hud/radar/threat.gd b/hud/radar/threat.gd new file mode 100644 index 0000000..c4e5f39 --- /dev/null +++ b/hud/radar/threat.gd @@ -0,0 +1,21 @@ +extends Sprite2D +class_name Threat + +@export var node: Node2D + +const dst: float = 70.0 + +func _physics_process(_delta: float) -> void: + if (node.global_position - get_parent().global_position).length() < dst: + modulate.a = 0 + else: + position = dst * (node.global_position - get_parent().global_position).normalized() + modulate.a = 1 + +func declare_danger(): + print("danger") + $animations.play("blink") +func release_danger(): + print("no danger") + $animations.stop() + visible = true diff --git a/hud/radar/threat.gd.uid b/hud/radar/threat.gd.uid new file mode 100644 index 0000000..e54294c --- /dev/null +++ b/hud/radar/threat.gd.uid @@ -0,0 +1 @@ +uid://bm76ox7rvuita diff --git a/hud/radar/threat.tscn b/hud/radar/threat.tscn new file mode 100644 index 0000000..849851b --- /dev/null +++ b/hud/radar/threat.tscn @@ -0,0 +1,52 @@ +[gd_scene load_steps=6 format=3 uid="uid://dwk5lnfnntqh2"] + +[ext_resource type="Texture2D" uid="uid://b8u4cc61kpl" path="res://hud/radar/threat_normal.png" id="1_cuq7j"] +[ext_resource type="Script" uid="uid://bm76ox7rvuita" path="res://hud/radar/threat.gd" id="2_oq6ws"] + +[sub_resource type="Animation" id="Animation_oq6ws"] +resource_name = "blink" +length = 0.8 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.2, 0.4, 0.6), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 1, +"values": [false, true, false, true] +} + +[sub_resource type="Animation" id="Animation_3aocn"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_3aocn"] +_data = { +&"RESET": SubResource("Animation_3aocn"), +&"blink": SubResource("Animation_oq6ws") +} + +[node name="threat" type="Sprite2D"] +modulate = Color(2, 2, 2, 1) +texture = ExtResource("1_cuq7j") +script = ExtResource("2_oq6ws") + +[node name="animations" type="AnimationPlayer" parent="."] +libraries = { +&"": SubResource("AnimationLibrary_3aocn") +} diff --git a/hud/radar/threat_normal.png b/hud/radar/threat_normal.png new file mode 100644 index 0000000000000000000000000000000000000000..d279da2cd52231e4f2004514c6dd83a03432c8f4 GIT binary patch literal 105 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~2A(dCAsjQ4bHq3O%|G+4{oxyZ zF*dQ}ZT38FZ}KH2Bw8dR&izYDOh^z&v-sWJ%E<7xitAgNL6{g&FN3G6pUXO@geCxa CvmW^X literal 0 HcmV?d00001 diff --git a/hud/radar/threat_normal.png.import b/hud/radar/threat_normal.png.import new file mode 100644 index 0000000..0e1cc33 --- /dev/null +++ b/hud/radar/threat_normal.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b8u4cc61kpl" +path="res://.godot/imported/threat_normal.png-3e4084ea6f7067b067f49c4502cd25f5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://hud/radar/threat_normal.png" +dest_files=["res://.godot/imported/threat_normal.png-3e4084ea6f7067b067f49c4502cd25f5.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 diff --git a/main.tscn b/main.tscn index 66efb58..03254ef 100644 --- a/main.tscn +++ b/main.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=12 format=4 uid="uid://dh8rn8jgqd1vu"] +[gd_scene load_steps=13 format=4 uid="uid://dh8rn8jgqd1vu"] [ext_resource type="PackedScene" uid="uid://b3xadpl4pu33u" path="res://player/player.tscn" id="1_1fxsm"] [ext_resource type="Texture2D" uid="uid://dywcxixvvt1u5" path="res://tiles/big_wall.png" id="2_xpfyb"] [ext_resource type="Texture2D" uid="uid://2b3vdhhu0yih" path="res://tiles/wall.png" id="3_bw3wk"] [ext_resource type="Texture2D" uid="uid://d0wr4ox4fkkt" path="res://tiles/small_wall.png" id="4_e7cbe"] +[ext_resource type="PackedScene" uid="uid://cwedpavtb5vfc" path="res://enemies/basic/basic.tscn" id="5_lquwl"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_x4q1a"] texture = ExtResource("2_xpfyb") @@ -39,12 +40,12 @@ sources/1 = SubResource("TileSetAtlasSource_8fd31") [sub_resource type="Environment" id="Environment_iwcc3"] background_mode = 3 glow_enabled = true -glow_levels/1 = 1.0 -glow_levels/2 = 0.5 -glow_levels/3 = 0.3 -glow_levels/4 = 0.1 -glow_levels/5 = 0.0 -glow_levels/7 = 1.0 +glow_levels/1 = 2.0 +glow_levels/2 = 1.0 +glow_levels/3 = 0.5 +glow_levels/4 = 0.3 +glow_levels/5 = 0.1 +glow_levels/7 = 0.1 glow_bloom = 0.05 glow_blend_mode = 1 @@ -64,5 +65,10 @@ tile_set = SubResource("TileSet_mnawe") tile_map_data = PackedByteArray("AADk/+D/AQAAAAAAAADn/+D/AQAAAAAAAADg/+T/AQAAAAAAAADg/+f/AQAAAAAAAADl/+P/AQAAAAAAAADi/+L/AQAAAAAAAADo/+r/AQAAAAAAAADq/+j/AQAAAAAAAADs/+T/AQAAAAAAAADs/+X/AQAAAAAAAADu/+L/AQAAAAAAAADv/+L/AQAAAAAAAADy/+D/AQAAAAAAAADz/+D/AQAAAAAAAAD3/+D/AQAAAAAAAAD2/+D/AQAAAAAAAAD1/+D/AQAAAAAAAAD7/+L/AQAAAAAAAAD6/+L/AQAAAAAAAAD9/+T/AQAAAAAAAAD//+b/AQAAAAAAAAADAOj/AQAAAAAAAAACAOj/AQAAAAAAAAAGAOr/AQAAAAAAAAAHAOr/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AMABsAAQAAAAAAAAANABsAAQAAAAAAAAACABkAAQAAAAAAAAADABkAAQAAAAAAAAAAABcAAQAAAAAAAAAAABYAAQAAAAAAAAD//xkAAQAAAAAAAAD//xoAAQAAAAAAAAD//xsAAQAAAAAAAAD+/xsAAQAAAAAAAAD2/xsAAQAAAAAAAAD3/xsAAQAAAAAAAAD4/xsAAQAAAAAAAAD5/xsAAQAAAAAAAAD0/xIAAQAAAAAAAADw//7/AQAAAAAAAADy//z/AQAAAAAAAADw////AQAAAAAAAADz//z/AQAAAAAAAADy//f/AQAAAAAAAADw//X/AQAAAAAAAADw//T/AQAAAAAAAADp//P/AQAAAAAAAADo//P/AQAAAAAAAADn//b/AQAAAAAAAADn//f/AQAAAAAAAADn//j/AQAAAAAAAADn//n/AQAAAAAAAADn//r/AQAAAAAAAADo//z/AQAAAAAAAADp//z/AQAAAAAAAADr//7/AQAAAAAAAADk//D/AQAAAAAAAAA=") tile_set = SubResource("TileSet_5p5j0") -[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +[node name="environment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_iwcc3") + +[node name="basic" parent="." node_paths=PackedStringArray("player") instance=ExtResource("5_lquwl")] +visible = true +position = Vector2(-70, -17) +player = NodePath("../player") diff --git a/palette.png b/palette.png index 3d347c3246136950781660699c3e338701ce56e0..144946a2f58a08c235c272a96fa5ddf31829e5a1 100644 GIT binary patch literal 282 zcmV+#0pPx#)Ja4^R0x?(!Ld%lKpeo~-<4BL9MEXgIIuZ7xcNlBfY0FQllTG-PPn)LVK9*r ztC)IM(NOSDdTkGSu700t!Z>83C(I#iAU&3rE+oE_ui4ox>=HxahJp_N-U#R7fLIUigwl|Wls9Jz?q+mglz gn;#*4yjA@32M8H=5&j{vp#T5?07*qoM6N<$f>Wh*DgXcg literal 229 zcmV^P)_jF>W@& znMpF~F%v4c^ARI$kW?+?$fizv6xNFS;l(60sbwE03~-YKD;Df`S1PMbA$}|>i1R*L zD%qUggsR3|QJ5MZ%G^MgO}5W3Lv6s?EGbl*%+c}cF6HBbqUp3d9dz5o3p}DCryL3L fC_wl=SrqaILKPRnKVu|)00000NkvXXu0mjfiF{wf diff --git a/player/player.gd b/player/player.gd index da3a19e..8abd56e 100644 --- a/player/player.gd +++ b/player/player.gd @@ -8,6 +8,9 @@ class_name Player var angular_velocity_target := 0.0 +@onready var radar: Radar = $radar + +var delay := false func _physics_process(delta: float) -> void: var input := Vector2(Input.get_action_strength("right") - Input.get_action_strength("left"), Input.get_action_strength("boost")) @@ -22,6 +25,9 @@ func _physics_process(delta: float) -> void: %thruster.active = true else: %thruster.active = false + + if Input.is_action_just_pressed("shoot"): + %railgun.shoot() func _integrate_forces(state: PhysicsDirectBodyState2D) -> void: state.angular_velocity = lerp(state.angular_velocity, angular_velocity_target, 0.1) diff --git a/player/player.tscn b/player/player.tscn index e471dc3..5a83d4f 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -1,8 +1,12 @@ -[gd_scene load_steps=11 format=3 uid="uid://b3xadpl4pu33u"] +[gd_scene load_steps=18 format=3 uid="uid://b3xadpl4pu33u"] [ext_resource type="Script" uid="uid://erjhplyctxik" path="res://player/player.gd" id="1_kkw55"] [ext_resource type="Texture2D" uid="uid://dlenptyfk1iwn" path="res://player/ship.png" id="2_1h4u8"] +[ext_resource type="PackedScene" uid="uid://dnndsvtgqr8eq" path="res://bullet/bullet.tscn" id="2_yw30f"] [ext_resource type="PackedScene" uid="uid://y08tu4ftj3t4" path="res://player/thruster.tscn" id="3_r6c8y"] +[ext_resource type="Script" uid="uid://dccya6vnwi1x4" path="res://player/railgun.gd" id="5_g6k8r"] +[ext_resource type="PackedScene" uid="uid://800ou0i3omcs" path="res://effects/flash.tscn" id="5_qjkh3"] +[ext_resource type="PackedScene" uid="uid://dfm1atk5lpdo4" path="res://hud/radar/radar.tscn" id="7_rgyib"] [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_6481p"] friction = 0.0 @@ -40,12 +44,86 @@ scale_max = 2.0 scale_curve = SubResource("CurveTexture_w2mcu") alpha_curve = SubResource("CurveTexture_q5aon") +[sub_resource type="Animation" id="Animation_qjkh3"] +resource_name = "shoot" +length = 0.4 +step = 0.1 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("%railgun/../image:scale:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(1, -0.25, 0, 0.1, 0.003124, 0.835, -0.066667, -0.000579298, 0.133333, -0.000579298, 1, -0.2, 0.00127017, 0.25, 0), +"times": PackedFloat32Array(0, 0.166667, 0.4) +} +tracks/1/type = "bezier" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("%railgun/../image:scale:y") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(1, -0.25, 0, 0.1, -0.000583708, 1.177, -0.066667, -0.00146496, 0.133333, -0.00517273, 1, -0.2, 0.003124, 0.25, 0), +"times": PackedFloat32Array(0, 0.166667, 0.4) +} +tracks/2/type = "method" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0.1), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"do_shoot" +}] +} + +[sub_resource type="Animation" id="Animation_g6k8r"] +length = 0.001 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("%railgun/../image:scale:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/1/type = "bezier" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("%railgun/../image:scale:y") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_g6k8r"] +_data = { +&"RESET": SubResource("Animation_g6k8r"), +&"shoot": SubResource("Animation_qjkh3") +} + [node name="player" type="RigidBody2D"] physics_material_override = SubResource("PhysicsMaterial_6481p") gravity_scale = 0.0 can_sleep = false angular_damp = 2.0 script = ExtResource("1_kkw55") +thruster_strength = null +rotation_strength = null drift_curve = SubResource("Curve_f6djc") [node name="camera" type="Camera2D" parent="."] @@ -54,8 +132,8 @@ position_smoothing_enabled = true [node name="stars" type="GPUParticles2D" parent="camera"] amount = 100 -process_material = SubResource("ParticleProcessMaterial_k0vl1") lifetime = 30.0 +process_material = SubResource("ParticleProcessMaterial_k0vl1") [node name="collision" type="CollisionPolygon2D" parent="."] polygon = PackedVector2Array(-5, 7, 0, -7, 5, 7, 2, 8, -2, 8) @@ -66,3 +144,21 @@ texture = ExtResource("2_1h4u8") [node name="thruster" parent="." instance=ExtResource("3_r6c8y")] unique_name_in_owner = true position = Vector2(0, 8) + +[node name="railgun" type="Marker2D" parent="."] +unique_name_in_owner = true +position = Vector2(0, -10) +gizmo_extents = 3.0 +script = ExtResource("5_g6k8r") +bullet = ExtResource("2_yw30f") + +[node name="flash" parent="railgun" instance=ExtResource("5_qjkh3")] +unique_name_in_owner = true +oneshot = false + +[node name="animations" type="AnimationPlayer" parent="railgun"] +libraries = { +&"": SubResource("AnimationLibrary_g6k8r") +} + +[node name="radar" parent="." instance=ExtResource("7_rgyib")] diff --git a/player/railgun.gd b/player/railgun.gd new file mode 100644 index 0000000..2909b28 --- /dev/null +++ b/player/railgun.gd @@ -0,0 +1,29 @@ +extends Marker2D + +@export var bullet : PackedScene +@export var speed : float = 100.0 +@export var knockback : float = 30.0 + +@onready var flash: Flash = %flash +@onready var parent: RigidBody2D = get_parent() + +var can_shoot: bool = true + +func shoot() -> void: + if not can_shoot or $animations.is_playing(): + return + $animations.play("shoot") + +func do_shoot() -> void: + if not can_shoot: + return + var instance : Bullet = bullet.instantiate() as Bullet + parent.get_parent().add_child(instance) + instance.global_position = global_position + instance.apply_central_impulse(Vector2.UP.rotated(global_rotation) * speed) + instance.player = parent + parent.apply_central_impulse(Vector2.DOWN.rotated(global_rotation) * knockback) + flash.flash() + can_shoot = false + await get_tree().create_timer(0.5).timeout + can_shoot = true diff --git a/player/railgun.gd.uid b/player/railgun.gd.uid new file mode 100644 index 0000000..d613a45 --- /dev/null +++ b/player/railgun.gd.uid @@ -0,0 +1 @@ +uid://dccya6vnwi1x4 diff --git a/player/thruster.gd b/player/thruster.gd index 8c9ec96..143d5da 100644 --- a/player/thruster.gd +++ b/player/thruster.gd @@ -1,11 +1,16 @@ extends Marker2D +class_name Thruster @export var active : bool -func _physics_process(delta: float) -> void: +@onready var pushback: Area2D = $pushback + +func _physics_process(_delta: float) -> void: if active: %fire.emitting = true %smoke.emitting = true + pushback.gravity = -1500.0 else: %fire.emitting = false %smoke.emitting = false + pushback.gravity = 0 diff --git a/player/thruster.tscn b/player/thruster.tscn index bfce5fc..209c1fb 100644 --- a/player/thruster.tscn +++ b/player/thruster.tscn @@ -51,15 +51,26 @@ script = ExtResource("1_ua4l5") unique_name_in_owner = true rotation = 1.5708 amount = 50 -process_material = SubResource("ParticleProcessMaterial_wobn2") texture = ExtResource("3_gj8x6") lifetime = 2.0 fixed_fps = 60 +process_material = SubResource("ParticleProcessMaterial_wobn2") [node name="fire" type="GPUParticles2D" parent="."] unique_name_in_owner = true rotation = 1.5708 amount = 50 -process_material = SubResource("ParticleProcessMaterial_wobn2") texture = ExtResource("2_jmeol") fixed_fps = 60 +process_material = SubResource("ParticleProcessMaterial_wobn2") + +[node name="pushback" type="Area2D" parent="."] +gravity_space_override = 1 +gravity_point = true +gravity_point_unit_distance = 3.0 +gravity_point_center = Vector2(0, 0) +gravity_direction = Vector2(0, 0) +gravity = -1500.0 + +[node name="shape" type="CollisionPolygon2D" parent="pushback"] +polygon = PackedVector2Array(-3, 5, -15, 80, 14, 80, 3, 5) diff --git a/project.godot b/project.godot index b6de4a9..4bfbe3c 100644 --- a/project.godot +++ b/project.godot @@ -41,6 +41,11 @@ right={ , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null) ] } +shoot={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +] +} [physics] @@ -51,4 +56,5 @@ right={ [rendering] textures/canvas_textures/default_texture_filter=0 +viewport/hdr_2d=true environment/defaults/default_clear_color=Color(0, 0, 0, 1)