player death, player hurt, ui
This commit is contained in:
parent
7c292f7cec
commit
b25214ebfe
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://sdelsqhjm5a5"
|
||||||
|
path="res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/player/death/Player Death 64x64.png"
|
||||||
|
dest_files=["res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.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
|
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://ceif6mm7m5nqi"
|
||||||
|
path="res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/player/hurt/Player Hurt 48x48.png"
|
||||||
|
dest_files=["res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.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
|
@ -21,4 +21,5 @@ rotation = -3.1402
|
|||||||
scale = Vector2(0.171023, -0.0779315)
|
scale = Vector2(0.171023, -0.0779315)
|
||||||
texture = ExtResource("2_a2saw")
|
texture = ExtResource("2_a2saw")
|
||||||
|
|
||||||
|
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
||||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[gd_scene load_steps=24 format=4 uid="uid://dcmyx5g6dksl8"]
|
[gd_scene load_steps=25 format=4 uid="uid://dcmyx5g6dksl8"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://d1ej2kiy7jcpv" path="res://scenes/crate.tscn" id="1_uivx3"]
|
[ext_resource type="PackedScene" uid="uid://d1ej2kiy7jcpv" path="res://scenes/crate.tscn" id="1_uivx3"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cfmcjh6nskv2e" path="res://scenes/ui.tscn" id="2_gvfd3"]
|
||||||
[ext_resource type="Script" path="res://scripts/trigger.gd" id="3_2qbah"]
|
[ext_resource type="Script" path="res://scripts/trigger.gd" id="3_2qbah"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b75mow511wmmb" path="res://scenes/player.tscn" id="3_8h5jv"]
|
[ext_resource type="PackedScene" uid="uid://b75mow511wmmb" path="res://scenes/player.tscn" id="3_8h5jv"]
|
||||||
[ext_resource type="Texture2D" uid="uid://jlbx6yvcmten" path="res://assets/graphics/terrains/backgrounds/forestbackground.png" id="3_umlo6"]
|
[ext_resource type="Texture2D" uid="uid://jlbx6yvcmten" path="res://assets/graphics/terrains/backgrounds/forestbackground.png" id="3_umlo6"]
|
||||||
@ -427,6 +428,10 @@ size = Vector2(15, 18)
|
|||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
script = ExtResource("6_n2kp0")
|
script = ExtResource("6_n2kp0")
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="ui" parent="CanvasLayer" instance=ExtResource("2_gvfd3")]
|
||||||
|
|
||||||
[node name="Background" type="Parallax2D" parent="."]
|
[node name="Background" type="Parallax2D" parent="."]
|
||||||
repeat_size = Vector2(320, 0)
|
repeat_size = Vector2(320, 0)
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
[gd_scene load_steps=23 format=4 uid="uid://d383o6j0l3d2m"]
|
[gd_scene load_steps=24 format=4 uid="uid://d383o6j0l3d2m"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/scenemanager.gd" id="1_g37ru"]
|
[ext_resource type="Script" path="res://scripts/scenemanager.gd" id="1_g37ru"]
|
||||||
[ext_resource type="Texture2D" uid="uid://jlbx6yvcmten" path="res://assets/graphics/terrains/backgrounds/forestbackground.png" id="2_ehg0h"]
|
[ext_resource type="Texture2D" uid="uid://jlbx6yvcmten" path="res://assets/graphics/terrains/backgrounds/forestbackground.png" id="2_ehg0h"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cfmcjh6nskv2e" path="res://scenes/ui.tscn" id="2_patxi"]
|
||||||
[ext_resource type="Texture2D" uid="uid://8kaggg1kilxy" path="res://assets/graphics/terrains/backgrounds/skystrip.png" id="3_8wilj"]
|
[ext_resource type="Texture2D" uid="uid://8kaggg1kilxy" path="res://assets/graphics/terrains/backgrounds/skystrip.png" id="3_8wilj"]
|
||||||
[ext_resource type="Texture2D" uid="uid://b3smxb17ijk60" path="res://assets/graphics/terrains/backgrounds/midtrees.png" id="4_qwx2h"]
|
[ext_resource type="Texture2D" uid="uid://b3smxb17ijk60" path="res://assets/graphics/terrains/backgrounds/midtrees.png" id="4_qwx2h"]
|
||||||
[ext_resource type="Texture2D" uid="uid://btdvc25chjgd" path="res://assets/graphics/terrains/Terrain (32x32).png" id="5_p6mo5"]
|
[ext_resource type="Texture2D" uid="uid://btdvc25chjgd" path="res://assets/graphics/terrains/Terrain (32x32).png" id="5_p6mo5"]
|
||||||
@ -426,6 +427,10 @@ size = Vector2(15, 18)
|
|||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
script = ExtResource("1_g37ru")
|
script = ExtResource("1_g37ru")
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="ui" parent="CanvasLayer" instance=ExtResource("2_patxi")]
|
||||||
|
|
||||||
[node name="Background" type="Parallax2D" parent="."]
|
[node name="Background" type="Parallax2D" parent="."]
|
||||||
repeat_size = Vector2(320, 0)
|
repeat_size = Vector2(320, 0)
|
||||||
|
|
||||||
@ -514,6 +519,12 @@ position = Vector2(370, 40)
|
|||||||
[node name="Area2D2" parent="coins" instance=ExtResource("9_fv1rd")]
|
[node name="Area2D2" parent="coins" instance=ExtResource("9_fv1rd")]
|
||||||
position = Vector2(400, 40)
|
position = Vector2(400, 40)
|
||||||
|
|
||||||
|
[node name="Area2D4" parent="coins" instance=ExtResource("9_fv1rd")]
|
||||||
|
position = Vector2(464, 85)
|
||||||
|
|
||||||
|
[node name="Area2D5" parent="coins" instance=ExtResource("9_fv1rd")]
|
||||||
|
position = Vector2(276, 80)
|
||||||
|
|
||||||
[node name="enemies" type="Node2D" parent="."]
|
[node name="enemies" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="Area2D3" type="Area2D" parent="enemies" groups=["enemies"]]
|
[node name="Area2D3" type="Area2D" parent="enemies" groups=["enemies"]]
|
||||||
|
@ -1,12 +1,70 @@
|
|||||||
[gd_scene load_steps=28 format=3 uid="uid://b75mow511wmmb"]
|
[gd_scene load_steps=44 format=3 uid="uid://b75mow511wmmb"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/charactercontroller.gd" id="1_racyk"]
|
[ext_resource type="Script" path="res://scripts/charactercontroller.gd" id="1_racyk"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://sdelsqhjm5a5" path="res://assets/graphics/player/death/Player Death 64x64.png" id="2_2t5sp"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ceif6mm7m5nqi" path="res://assets/graphics/player/hurt/Player Hurt 48x48.png" id="2_rs8ny"]
|
||||||
[ext_resource type="Texture2D" uid="uid://d2gvpgkw8np1c" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_xdqt5"]
|
[ext_resource type="Texture2D" uid="uid://d2gvpgkw8np1c" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_xdqt5"]
|
||||||
[ext_resource type="Texture2D" uid="uid://ctneeupm1dwsb" path="res://assets/graphics/player/jump/player jump 48x48.png" id="3_0nv1p"]
|
[ext_resource type="Texture2D" uid="uid://ctneeupm1dwsb" path="res://assets/graphics/player/jump/player jump 48x48.png" id="3_0nv1p"]
|
||||||
[ext_resource type="Texture2D" uid="uid://ccxw74sa7kyv" path="res://assets/graphics/player/run/player run 48x48.png" id="3_d2rrr"]
|
[ext_resource type="Texture2D" uid="uid://ccxw74sa7kyv" path="res://assets/graphics/player/run/player run 48x48.png" id="3_d2rrr"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_i8a0m"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_i8a0m"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_bbe3f"]
|
||||||
|
atlas = ExtResource("2_2t5sp")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_1e5du"]
|
||||||
|
atlas = ExtResource("2_2t5sp")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_j0abf"]
|
||||||
|
atlas = ExtResource("2_2t5sp")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_6o4t2"]
|
||||||
|
atlas = ExtResource("2_2t5sp")
|
||||||
|
region = Rect2(144, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_gkmrp"]
|
||||||
|
atlas = ExtResource("2_2t5sp")
|
||||||
|
region = Rect2(192, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_hjsqv"]
|
||||||
|
atlas = ExtResource("2_2t5sp")
|
||||||
|
region = Rect2(240, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_0qj7s"]
|
||||||
|
atlas = ExtResource("2_2t5sp")
|
||||||
|
region = Rect2(288, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_mllfo"]
|
||||||
|
atlas = ExtResource("2_2t5sp")
|
||||||
|
region = Rect2(336, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_4kmyn"]
|
||||||
|
atlas = ExtResource("2_2t5sp")
|
||||||
|
region = Rect2(384, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_nhisu"]
|
||||||
|
atlas = ExtResource("2_2t5sp")
|
||||||
|
region = Rect2(432, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_o5yg8"]
|
||||||
|
atlas = ExtResource("2_rs8ny")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_3l8vl"]
|
||||||
|
atlas = ExtResource("2_rs8ny")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_rwn2k"]
|
||||||
|
atlas = ExtResource("2_rs8ny")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_2b7hu"]
|
||||||
|
atlas = ExtResource("2_rs8ny")
|
||||||
|
region = Rect2(144, 0, 48, 48)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_afagl"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_afagl"]
|
||||||
atlas = ExtResource("2_xdqt5")
|
atlas = ExtResource("2_xdqt5")
|
||||||
region = Rect2(0, 0, 48, 48)
|
region = Rect2(0, 0, 48, 48)
|
||||||
@ -95,6 +153,58 @@ region = Rect2(336, 0, 48, 48)
|
|||||||
animations = [{
|
animations = [{
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_bbe3f")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_1e5du")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_j0abf")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_6o4t2")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_gkmrp")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_hjsqv")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_0qj7s")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_mllfo")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_4kmyn")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_nhisu")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"death",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_o5yg8")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_3l8vl")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_rwn2k")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_2b7hu")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"hurt",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_afagl")
|
"texture": SubResource("AtlasTexture_afagl")
|
||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
@ -197,7 +307,7 @@ position = Vector2(-10, -5)
|
|||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
sprite_frames = SubResource("SpriteFrames_2kykc")
|
sprite_frames = SubResource("SpriteFrames_2kykc")
|
||||||
animation = &"jump"
|
animation = &"death"
|
||||||
autoplay = "jump"
|
autoplay = "jump"
|
||||||
frame = 2
|
|
||||||
frame_progress = 1.0
|
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"]
|
||||||
|
47
dariusgodotproject/scenes/ui.tscn
Normal file
47
dariusgodotproject/scenes/ui.tscn
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://cfmcjh6nskv2e"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/ui.gd" id="1_vhyum"]
|
||||||
|
|
||||||
|
[node name="Control" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_vhyum")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 10
|
||||||
|
anchor_right = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="health" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "HEALTH"
|
||||||
|
|
||||||
|
[node name="MarginContainer3" type="MarginContainer" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="timer" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "10"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="coins" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "COINS"
|
||||||
|
horizontal_alignment = 2
|
@ -3,7 +3,7 @@ class_name Bullet extends Area2D
|
|||||||
|
|
||||||
var speed = 700
|
var speed = 700
|
||||||
signal hit
|
signal hit
|
||||||
|
signal badguyHit(area)
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
@ -27,3 +27,10 @@ func _on_body_entered(body: Node2D) -> void:
|
|||||||
print("Bullet hits something")
|
print("Bullet hits something")
|
||||||
if not body.is_in_group("player"):
|
if not body.is_in_group("player"):
|
||||||
hit.emit(self, body)
|
hit.emit(self, body)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_area_entered(area: Area2D) -> void:
|
||||||
|
print("Bullet hitting area")
|
||||||
|
if area.is_in_group("enemies"):
|
||||||
|
badguyHit.emit(area)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
const RANGE = 400.0
|
||||||
const SPEED = 300.0
|
const SPEED = 300.0
|
||||||
const JUMP_VELOCITY = -400.0
|
const JUMP_VELOCITY = -400.0
|
||||||
const BUMP_FORCE = 50
|
const BUMP_FORCE = 50
|
||||||
@ -15,6 +15,8 @@ var pushLeftEnabled = false
|
|||||||
@export var PUSH_FORCE = 700
|
@export var PUSH_FORCE = 700
|
||||||
@onready var animation: AnimatedSprite2D = $AnimatedSprite2D
|
@onready var animation: AnimatedSprite2D = $AnimatedSprite2D
|
||||||
@onready var teleportZone: Area2D = $"../Area2D"
|
@onready var teleportZone: Area2D = $"../Area2D"
|
||||||
|
var teleportCounter = 0
|
||||||
|
|
||||||
|
|
||||||
# Bullet Attack Variables
|
# Bullet Attack Variables
|
||||||
@onready var right_target: Node2D = $RightTarget
|
@onready var right_target: Node2D = $RightTarget
|
||||||
@ -22,96 +24,128 @@ var pushLeftEnabled = false
|
|||||||
|
|
||||||
var isJumping = false
|
var isJumping = false
|
||||||
var safeTeleport = false
|
var safeTeleport = false
|
||||||
func _physics_process(delta: float) -> void:
|
|
||||||
# Add the gravity.
|
|
||||||
if not is_on_floor():
|
|
||||||
velocity += get_gravity() * delta
|
|
||||||
else:
|
|
||||||
isJumping = false
|
|
||||||
# Handle jump.
|
|
||||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
|
||||||
velocity.y = JUMP_VELOCITY
|
|
||||||
animation.play("jump")
|
|
||||||
isJumping = true
|
|
||||||
# Hover
|
|
||||||
if not is_on_floor() and Input.is_action_pressed("hover"):
|
|
||||||
velocity.x = 0
|
|
||||||
velocity.y = 0
|
|
||||||
# Shove Attack
|
|
||||||
if Input.is_action_just_pressed("shove"):
|
|
||||||
if pushRightEnabled && faceLeft == false:
|
|
||||||
pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE * 2)
|
|
||||||
if pushLeftEnabled && faceLeft == true:
|
|
||||||
pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE * 2)
|
|
||||||
# Teleport
|
|
||||||
if Input.is_action_just_pressed("teleport"):
|
|
||||||
while not safeTeleport:
|
|
||||||
teleportZone.position = Vector2(position.x+randf_range(-300,300),position.y+randf_range(-300,300))
|
|
||||||
if teleportZone.has_overlapping_bodies():
|
|
||||||
safeTeleport = false
|
|
||||||
else:
|
|
||||||
safeTeleport = true
|
|
||||||
safeTeleport= false
|
|
||||||
position = Vector2(teleportZone.position.x,teleportZone.position.y)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Handle Shooting
|
|
||||||
if Input.is_action_just_pressed("shoot"):
|
|
||||||
#print("I want to shoot")
|
|
||||||
#make a new bullet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if faceLeft == true:
|
|
||||||
var myBullet = %SceneManager.makeBullet(left_target.global_transform,-700)
|
|
||||||
#myBullet.transform = left_target.global_transform
|
|
||||||
#myBullet.setSpeed(-700)
|
|
||||||
if faceLeft == false:
|
|
||||||
var myBullet = %SceneManager.makeBullet(right_target.global_transform,700)
|
|
||||||
# Get the input direction and handle the movement/deceleration.
|
|
||||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
|
||||||
var direction := Input.get_axis("left", "right")
|
|
||||||
if direction:
|
|
||||||
velocity.x = direction * SPEED
|
|
||||||
if direction <0:
|
|
||||||
if not isJumping:
|
|
||||||
animation.play("run")
|
|
||||||
faceLeft = true
|
|
||||||
animation.flip_h = true
|
|
||||||
if direction >0:
|
|
||||||
if not isJumping:
|
|
||||||
animation.play("run")
|
|
||||||
faceLeft = false
|
|
||||||
animation.flip_h = false
|
|
||||||
else:
|
|
||||||
if not isJumping:
|
|
||||||
animation.play("idle")
|
|
||||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
|
||||||
|
|
||||||
move_and_slide()
|
var living = true
|
||||||
if right_ray.is_colliding():
|
var animPlaying = "idle"
|
||||||
# print("Right ray contact!")
|
|
||||||
if not faceLeft:
|
signal deathAnimationComplete
|
||||||
var collider = right_ray.get_collider()
|
|
||||||
if collider is RigidBody2D:
|
|
||||||
pushTarget = collider
|
func hurtPlayer(_amt):
|
||||||
pushRightEnabled = true
|
if _amt < 100:
|
||||||
else:
|
animPlaying = "hurt"
|
||||||
pushRightEnabled = false
|
animation.play(animPlaying)
|
||||||
|
|
||||||
if left_ray.is_colliding():
|
|
||||||
if faceLeft:
|
|
||||||
var collider = left_ray.get_collider()
|
|
||||||
if collider is RigidBody2D:
|
|
||||||
pushTarget = collider
|
|
||||||
pushLeftEnabled = true
|
|
||||||
else:
|
|
||||||
pushLeftEnabled = false
|
|
||||||
|
|
||||||
|
|
||||||
|
func killPlayer():
|
||||||
for i in get_slide_collision_count():
|
print("PC will kill player")
|
||||||
var c = get_slide_collision(i)
|
if living:
|
||||||
if c.get_collider() is RigidBody2D:
|
living = false
|
||||||
c.get_collider().apply_central_impulse(-c.get_normal() * BUMP_FORCE)
|
animPlaying = "death"
|
||||||
|
animation.play(animPlaying)
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
if living and not animPlaying == "hurt":
|
||||||
|
# Add the gravity.
|
||||||
|
if not is_on_floor():
|
||||||
|
velocity += get_gravity() * delta
|
||||||
|
else:
|
||||||
|
isJumping = false
|
||||||
|
# Handle jump.
|
||||||
|
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||||
|
velocity.y = JUMP_VELOCITY
|
||||||
|
animation.play("jump")
|
||||||
|
isJumping = true
|
||||||
|
# Hover
|
||||||
|
if not is_on_floor() and Input.is_action_pressed("hover"):
|
||||||
|
velocity.x = 0
|
||||||
|
velocity.y = 0
|
||||||
|
# Shove Attack
|
||||||
|
if Input.is_action_just_pressed("shove"):
|
||||||
|
if pushRightEnabled && faceLeft == false:
|
||||||
|
pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE * 2)
|
||||||
|
if pushLeftEnabled && faceLeft == true:
|
||||||
|
pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE * 2)
|
||||||
|
# Teleport
|
||||||
|
if Input.is_action_just_pressed("teleport"):
|
||||||
|
while not safeTeleport and teleportCounter < 100:
|
||||||
|
teleportZone.position = Vector2(position.x+randf_range(-RANGE,RANGE),position.y+randf_range(-RANGE,RANGE))
|
||||||
|
if teleportZone.has_overlapping_bodies():
|
||||||
|
safeTeleport = false
|
||||||
|
teleportCounter +=1
|
||||||
|
else:
|
||||||
|
safeTeleport = true
|
||||||
|
teleportCounter +=1
|
||||||
|
safeTeleport= false
|
||||||
|
teleportCounter = 0
|
||||||
|
position = Vector2(teleportZone.position.x,teleportZone.position.y)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Handle Shooting
|
||||||
|
if Input.is_action_just_pressed("shoot"):
|
||||||
|
#print("I want to shoot")
|
||||||
|
#make a new bullet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if faceLeft == true:
|
||||||
|
var myBullet = %SceneManager.makeBullet(left_target.global_transform,-700)
|
||||||
|
#myBullet.transform = left_target.global_transform
|
||||||
|
#myBullet.setSpeed(-700)
|
||||||
|
if faceLeft == false:
|
||||||
|
var myBullet = %SceneManager.makeBullet(right_target.global_transform,700)
|
||||||
|
# Get the input direction and handle the movement/deceleration.
|
||||||
|
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||||
|
var direction := Input.get_axis("left", "right")
|
||||||
|
if direction:
|
||||||
|
velocity.x = direction * SPEED
|
||||||
|
if direction <0:
|
||||||
|
if not isJumping:
|
||||||
|
animation.play("run")
|
||||||
|
faceLeft = true
|
||||||
|
animation.flip_h = true
|
||||||
|
if direction >0:
|
||||||
|
if not isJumping:
|
||||||
|
animation.play("run")
|
||||||
|
faceLeft = false
|
||||||
|
animation.flip_h = false
|
||||||
|
else:
|
||||||
|
if not isJumping:
|
||||||
|
animation.play("idle")
|
||||||
|
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||||
|
|
||||||
|
move_and_slide()
|
||||||
|
if right_ray.is_colliding():
|
||||||
|
# print("Right ray contact!")
|
||||||
|
if not faceLeft:
|
||||||
|
var collider = right_ray.get_collider()
|
||||||
|
if collider is RigidBody2D:
|
||||||
|
pushTarget = collider
|
||||||
|
pushRightEnabled = true
|
||||||
|
else:
|
||||||
|
pushRightEnabled = false
|
||||||
|
|
||||||
|
if left_ray.is_colliding():
|
||||||
|
if faceLeft:
|
||||||
|
var collider = left_ray.get_collider()
|
||||||
|
if collider is RigidBody2D:
|
||||||
|
pushTarget = collider
|
||||||
|
pushLeftEnabled = true
|
||||||
|
else:
|
||||||
|
pushLeftEnabled = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for i in get_slide_collision_count():
|
||||||
|
var c = get_slide_collision(i)
|
||||||
|
if c.get_collider() is RigidBody2D:
|
||||||
|
c.get_collider().apply_central_impulse(-c.get_normal() * BUMP_FORCE)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_animation_finished() -> void:
|
||||||
|
if animPlaying == "hurt":
|
||||||
|
animPlaying = "idle"
|
||||||
|
if animPlaying == "death":
|
||||||
|
# emit death signal
|
||||||
|
deathAnimationComplete.emit()
|
||||||
|
|
||||||
|
@ -13,13 +13,17 @@ var player:Resource
|
|||||||
|
|
||||||
#level information
|
#level information
|
||||||
var levels = ["res://scenes/game.tscn","res://scenes/level2.tscn"]
|
var levels = ["res://scenes/game.tscn","res://scenes/level2.tscn"]
|
||||||
var timers = [10, 15]
|
var timers = [20, 15]
|
||||||
var currentLevel = 0
|
var currentLevel = 0
|
||||||
#Signals from GC
|
#Signals from GC
|
||||||
signal destroyBox(body)
|
signal destroyBox(body)
|
||||||
|
signal destroyBadguy(area)
|
||||||
signal levelComplete (levelToLoad)
|
signal levelComplete (levelToLoad)
|
||||||
|
signal playerHurt(amt)
|
||||||
|
signal playerDeath
|
||||||
|
|
||||||
|
signal tick(timeRemaining)
|
||||||
|
signal coinsUpdate(coinsCollected, coinsAvailable)
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
@ -35,22 +39,40 @@ func _ready() -> void:
|
|||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
func reset():
|
func reset():
|
||||||
|
totalCoinsCollected = 0
|
||||||
|
player.health = player.starting_health
|
||||||
countdown = timers[currentLevel]
|
countdown = timers[currentLevel]
|
||||||
|
tick.emit.call_deferred(countdown)
|
||||||
|
coinsUpdate.emit.call_deferred(totalCoinsCollected, totalCoins)
|
||||||
|
playerHurt.emit.call_deferred(player.health)
|
||||||
|
|
||||||
func secondCounter():
|
func secondCounter():
|
||||||
# print("one second")
|
# print("one second")
|
||||||
countdown -=1
|
countdown -=1
|
||||||
|
tick.emit(countdown)
|
||||||
if countdown <=0:
|
if countdown <=0:
|
||||||
print("YOU LOSE")
|
print("YOU LOSE")
|
||||||
levelComplete.emit(levels[currentLevel])
|
levelComplete.emit(levels[currentLevel])
|
||||||
func coinCollected():
|
func coinCollected():
|
||||||
totalCoinsCollected +=1
|
totalCoinsCollected +=1
|
||||||
|
coinsUpdate.emit(totalCoinsCollected, totalCoins)
|
||||||
print("GC knows coin collected")
|
print("GC knows coin collected")
|
||||||
|
|
||||||
func playerDamaged():
|
func playerDamaged():
|
||||||
print("GC knows player taking damage")
|
print("GC knows player taking damage")
|
||||||
player.health -=20
|
player.health -=20
|
||||||
print("Health remaining: " +str(player.health))
|
print("Health remaining: " +str(player.health))
|
||||||
|
if player.health > 0:
|
||||||
|
playerHurt.emit(player.health)
|
||||||
|
else:
|
||||||
|
playerDeath.emit()
|
||||||
|
|
||||||
|
func bulletHitBadguy(area):
|
||||||
|
#decide what to do
|
||||||
|
#how many bad guys reamining
|
||||||
|
#send a signal
|
||||||
|
destroyBadguy.emit(area)
|
||||||
|
|
||||||
func bulletHit(body):
|
func bulletHit(body):
|
||||||
print("Game controller knows bullet hit something")
|
print("Game controller knows bullet hit something")
|
||||||
if body.is_in_group("destructable"):
|
if body.is_in_group("destructable"):
|
||||||
@ -73,3 +95,7 @@ func countCoins(value):
|
|||||||
func countBadGuys(value):
|
func countBadGuys(value):
|
||||||
totalBadGuys = value
|
totalBadGuys = value
|
||||||
|
|
||||||
|
|
||||||
|
func playerDead():
|
||||||
|
print("GC knows player is dead")
|
||||||
|
levelComplete.emit(levels[currentLevel])
|
||||||
|
@ -2,6 +2,8 @@ extends Node
|
|||||||
@onready var crates: Node2D = $"../crates"
|
@onready var crates: Node2D = $"../crates"
|
||||||
@onready var coins: Node2D = $"../coins"
|
@onready var coins: Node2D = $"../coins"
|
||||||
@onready var enemies: Node2D = $"../enemies"
|
@onready var enemies: Node2D = $"../enemies"
|
||||||
|
@onready var player: CharacterBody2D = $"../CharacterBody2D"
|
||||||
|
@onready var ui: Control = $"../CanvasLayer/ui"
|
||||||
|
|
||||||
|
|
||||||
var bullet = preload("res://scenes/bullet.tscn")
|
var bullet = preload("res://scenes/bullet.tscn")
|
||||||
@ -33,8 +35,19 @@ func _ready() -> void:
|
|||||||
Gamecontroller.countCoins(totalCoins)
|
Gamecontroller.countCoins(totalCoins)
|
||||||
Gamecontroller.countCrates(totalCrates)
|
Gamecontroller.countCrates(totalCrates)
|
||||||
|
|
||||||
|
#Player interactions
|
||||||
|
Gamecontroller.playerHurt.connect(player.hurtPlayer)
|
||||||
|
Gamecontroller.playerDeath.connect(player.killPlayer)
|
||||||
#Subscribe to vital events from GC
|
#Subscribe to vital events from GC
|
||||||
Gamecontroller.levelComplete.connect(changeLevel)
|
Gamecontroller.levelComplete.connect(changeLevel)
|
||||||
|
player.deathAnimationComplete.connect(Gamecontroller.playerDead)
|
||||||
|
# ui events
|
||||||
|
Gamecontroller.tick.connect(ui.timerUpdate)
|
||||||
|
Gamecontroller.playerHurt.connect(ui.healthUpdate)
|
||||||
|
Gamecontroller.playerDeath.connect(ui.healthGone)
|
||||||
|
Gamecontroller.coinsUpdate.connect(ui.coinsUpdate)
|
||||||
|
|
||||||
|
Gamecontroller.destroyBadguy.connect(killBadguy)
|
||||||
Gamecontroller.reset()
|
Gamecontroller.reset()
|
||||||
|
|
||||||
|
|
||||||
@ -50,6 +63,7 @@ func bulletFactory():
|
|||||||
if bulletArray.size() < 10:
|
if bulletArray.size() < 10:
|
||||||
myBullet = bullet.instantiate()
|
myBullet = bullet.instantiate()
|
||||||
myBullet.connect("hit", onBulletHit)
|
myBullet.connect("hit", onBulletHit)
|
||||||
|
myBullet.connect("badguyHit", Gamecontroller.bulletHitBadguy)
|
||||||
owner.add_child(myBullet)
|
owner.add_child(myBullet)
|
||||||
else:
|
else:
|
||||||
myBullet = bulletArray.pop_back()
|
myBullet = bulletArray.pop_back()
|
||||||
@ -64,7 +78,9 @@ func makeBullet(position, speed):
|
|||||||
|
|
||||||
return myBullet
|
return myBullet
|
||||||
|
|
||||||
|
func killBadguy(area):
|
||||||
|
area.queue_free()
|
||||||
|
|
||||||
func onBulletHit(bullet, body):
|
func onBulletHit(bullet, body):
|
||||||
bullet.position = Vector2(-100,-100)
|
bullet.position = Vector2(-100,-100)
|
||||||
bullet.setSpeed(0)
|
bullet.setSpeed(0)
|
||||||
|
19
dariusgodotproject/scripts/ui.gd
Normal file
19
dariusgodotproject/scripts/ui.gd
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
extends Control
|
||||||
|
@onready var timer: Label = $VBoxContainer/HBoxContainer/MarginContainer3/timer
|
||||||
|
@onready var health: Label = $VBoxContainer/HBoxContainer/MarginContainer/health
|
||||||
|
@onready var coins: Label = $VBoxContainer/HBoxContainer/MarginContainer2/coins
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
func timerUpdate(timeRemaining):
|
||||||
|
timer.text = str(timeRemaining)
|
||||||
|
|
||||||
|
func healthUpdate(healthRemaining):
|
||||||
|
health.text = "HEALTH "+str(healthRemaining)
|
||||||
|
func healthGone():
|
||||||
|
health.text = "HEALTH 0"
|
||||||
|
func coinsUpdate(coinsCollectedTotal, coinsAvailableTotal):
|
||||||
|
coins.text = str(coinsCollectedTotal) + " of " +str(coinsAvailableTotal)
|
Loading…
Reference in New Issue
Block a user