Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9448311064 | |||
| cdb1b5d632 | |||
| 5930d37049 | |||
| 4559b154a1 |
5
Readme.md
Normal file
5
Readme.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Week 5:
|
||||||
|
Coin collection, bad guys, dealing damage
|
||||||
|
|
||||||
|
In this lesson, we get some enemies in the game, and along the way w
|
||||||
|
learn some valuable principles.
|
||||||
BIN
assets/enemies/slime/slime_green.png
Normal file
BIN
assets/enemies/slime/slime_green.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 908 B |
40
assets/enemies/slime/slime_green.png.import
Normal file
40
assets/enemies/slime/slime_green.png.import
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bj3ccpqo3t7pv"
|
||||||
|
path="res://.godot/imported/slime_green.png-e5d60b3e093812754197fdd9edfc7bf5.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/enemies/slime/slime_green.png"
|
||||||
|
dest_files=["res://.godot/imported/slime_green.png-e5d60b3e093812754197fdd9edfc7bf5.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
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/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
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/player/death/Player Death 64x64.png
Normal file
BIN
assets/player/death/Player Death 64x64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
40
assets/player/death/Player Death 64x64.png.import
Normal file
40
assets/player/death/Player Death 64x64.png.import
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://k0r4u3odrun4"
|
||||||
|
path="res://.godot/imported/Player Death 64x64.png-4a0ce04f5d26e871d084fcfc48e67d00.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/player/death/Player Death 64x64.png"
|
||||||
|
dest_files=["res://.godot/imported/Player Death 64x64.png-4a0ce04f5d26e871d084fcfc48e67d00.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
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/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
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/player/hurt/Player Hurt 48x48.png
Normal file
BIN
assets/player/hurt/Player Hurt 48x48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
40
assets/player/hurt/Player Hurt 48x48.png.import
Normal file
40
assets/player/hurt/Player Hurt 48x48.png.import
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c7ike4q1xl2gy"
|
||||||
|
path="res://.godot/imported/Player Hurt 48x48.png-4f3bee63f7b077a423955d655b236738.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/player/hurt/Player Hurt 48x48.png"
|
||||||
|
dest_files=["res://.godot/imported/Player Hurt 48x48.png-4f3bee63f7b077a423955d655b236738.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
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/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
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
|
||||||
@ -20,4 +20,5 @@ rotation = -3.1367095
|
|||||||
scale = Vector2(0.07999989, 0.08039169)
|
scale = Vector2(0.07999989, 0.08039169)
|
||||||
texture = ExtResource("2_y25gk")
|
texture = ExtResource("2_y25gk")
|
||||||
|
|
||||||
|
[connection signal="area_entered" from="." to="." method="_on_body_entered"]
|
||||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://b6cmg0k8qjoxi" path="res://scenes/crate.tscn" id="5_iywne"]
|
[ext_resource type="PackedScene" uid="uid://b6cmg0k8qjoxi" path="res://scenes/crate.tscn" id="5_iywne"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b3hgbbmb0nohj" path="res://scenes/trigger.tscn" id="5_p57ef"]
|
[ext_resource type="PackedScene" uid="uid://b3hgbbmb0nohj" path="res://scenes/trigger.tscn" id="5_p57ef"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cfmbd0jdbrvd1" path="res://scenes/coin.tscn" id="13_kvuet"]
|
[ext_resource type="PackedScene" uid="uid://cfmbd0jdbrvd1" path="res://scenes/coin.tscn" id="13_kvuet"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b23q2ppkeamyh" path="res://scenes/slime.tscn" id="14_trtic"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_u5sy4"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_u5sy4"]
|
||||||
texture = ExtResource("2_p57ef")
|
texture = ExtResource("2_p57ef")
|
||||||
@ -448,7 +449,7 @@ tile_set = SubResource("TileSet_gee14")
|
|||||||
script = ExtResource("2_lbhrr")
|
script = ExtResource("2_lbhrr")
|
||||||
|
|
||||||
[node name="Player" parent="." unique_id=2145223914 instance=ExtResource("4_iywne")]
|
[node name="Player" parent="." unique_id=2145223914 instance=ExtResource("4_iywne")]
|
||||||
position = Vector2(495, 379)
|
position = Vector2(446.00003, 465.00003)
|
||||||
|
|
||||||
[node name="Crates" type="Node2D" parent="." unique_id=207771395]
|
[node name="Crates" type="Node2D" parent="." unique_id=207771395]
|
||||||
|
|
||||||
@ -526,6 +527,14 @@ position = Vector2(116, -31)
|
|||||||
[node name="Coin3" parent="Coins" unique_id=1071266659 instance=ExtResource("13_kvuet")]
|
[node name="Coin3" parent="Coins" unique_id=1071266659 instance=ExtResource("13_kvuet")]
|
||||||
position = Vector2(164, -65)
|
position = Vector2(164, -65)
|
||||||
|
|
||||||
|
[node name="Enemies" type="Node2D" parent="." unique_id=791989786]
|
||||||
|
|
||||||
|
[node name="Slime" parent="Enemies" unique_id=822623820 instance=ExtResource("14_trtic")]
|
||||||
|
position = Vector2(401, 470)
|
||||||
|
|
||||||
|
[node name="Slime2" parent="Enemies" unique_id=1058828655 instance=ExtResource("14_trtic")]
|
||||||
|
position = Vector2(654, 277)
|
||||||
|
|
||||||
[connection signal="areaTriggerSignal" from="Triggers/Trigger" to="." method="_on_trigger"]
|
[connection signal="areaTriggerSignal" from="Triggers/Trigger" to="." method="_on_trigger"]
|
||||||
[connection signal="areaTriggerSignal" from="Triggers/Trigger2" to="." method="_on_trigger"]
|
[connection signal="areaTriggerSignal" from="Triggers/Trigger2" to="." method="_on_trigger"]
|
||||||
[connection signal="areaTriggerSignal" from="Triggers/Trigger3" to="." method="_on_trigger"]
|
[connection signal="areaTriggerSignal" from="Triggers/Trigger3" to="." method="_on_trigger"]
|
||||||
|
|||||||
@ -4,7 +4,9 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://b1ai5l50rwv4u" path="res://assets/player/idle/Player Idle 48x48.png" id="2_g2els"]
|
[ext_resource type="Texture2D" uid="uid://b1ai5l50rwv4u" path="res://assets/player/idle/Player Idle 48x48.png" id="2_g2els"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dngnhx41kw3mw" path="res://assets/player/charging/Player Punch 64x64.png" id="2_qlg0r"]
|
[ext_resource type="Texture2D" uid="uid://dngnhx41kw3mw" path="res://assets/player/charging/Player Punch 64x64.png" id="2_qlg0r"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cgyc5mlhrd472" path="res://assets/player/jump_fall/player jump 48x48.png" id="3_dqkch"]
|
[ext_resource type="Texture2D" uid="uid://cgyc5mlhrd472" path="res://assets/player/jump_fall/player jump 48x48.png" id="3_dqkch"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://k0r4u3odrun4" path="res://assets/player/death/Player Death 64x64.png" id="3_fjrip"]
|
||||||
[ext_resource type="Texture2D" uid="uid://di17x5ovjtvtt" path="res://assets/player/run/player run 48x48.png" id="3_qhqgy"]
|
[ext_resource type="Texture2D" uid="uid://di17x5ovjtvtt" path="res://assets/player/run/player run 48x48.png" id="3_qhqgy"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c7ike4q1xl2gy" path="res://assets/player/hurt/Player Hurt 48x48.png" id="5_smehm"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_uwrxv"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_uwrxv"]
|
||||||
|
|
||||||
@ -12,10 +14,66 @@
|
|||||||
atlas = ExtResource("2_qlg0r")
|
atlas = ExtResource("2_qlg0r")
|
||||||
region = Rect2(128, 0, 64, 64)
|
region = Rect2(128, 0, 64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_pf23h"]
|
||||||
|
atlas = ExtResource("3_fjrip")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_dt7fs"]
|
||||||
|
atlas = ExtResource("3_fjrip")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_wqfne"]
|
||||||
|
atlas = ExtResource("3_fjrip")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_wnwbv"]
|
||||||
|
atlas = ExtResource("3_fjrip")
|
||||||
|
region = Rect2(144, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_gl8cc"]
|
||||||
|
atlas = ExtResource("3_fjrip")
|
||||||
|
region = Rect2(192, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_487ah"]
|
||||||
|
atlas = ExtResource("3_fjrip")
|
||||||
|
region = Rect2(240, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_md1ol"]
|
||||||
|
atlas = ExtResource("3_fjrip")
|
||||||
|
region = Rect2(288, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_bj30b"]
|
||||||
|
atlas = ExtResource("3_fjrip")
|
||||||
|
region = Rect2(336, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_jc3p3"]
|
||||||
|
atlas = ExtResource("3_fjrip")
|
||||||
|
region = Rect2(384, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_hax0n"]
|
||||||
|
atlas = ExtResource("3_fjrip")
|
||||||
|
region = Rect2(432, 0, 48, 48)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4ni07"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_4ni07"]
|
||||||
atlas = ExtResource("3_dqkch")
|
atlas = ExtResource("3_dqkch")
|
||||||
region = Rect2(96, 0, 48, 48)
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_t4otl"]
|
||||||
|
atlas = ExtResource("5_smehm")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_j2b1d"]
|
||||||
|
atlas = ExtResource("5_smehm")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_cs1tg"]
|
||||||
|
atlas = ExtResource("5_smehm")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_2dvfe"]
|
||||||
|
atlas = ExtResource("5_smehm")
|
||||||
|
region = Rect2(144, 0, 48, 48)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
|
||||||
atlas = ExtResource("2_g2els")
|
atlas = ExtResource("2_g2els")
|
||||||
region = Rect2(0, 0, 48, 48)
|
region = Rect2(0, 0, 48, 48)
|
||||||
@ -120,6 +178,41 @@ animations = [{
|
|||||||
}, {
|
}, {
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_pf23h")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_dt7fs")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_wqfne")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_wnwbv")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_gl8cc")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_487ah")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_md1ol")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_bj30b")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_jc3p3")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_hax0n")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"death",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_4ni07")
|
"texture": SubResource("AtlasTexture_4ni07")
|
||||||
}],
|
}],
|
||||||
"loop": false,
|
"loop": false,
|
||||||
@ -128,6 +221,23 @@ animations = [{
|
|||||||
}, {
|
}, {
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_t4otl")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_j2b1d")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_cs1tg")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_2dvfe")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"hurt",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_qhqgy")
|
"texture": SubResource("AtlasTexture_qhqgy")
|
||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
@ -232,19 +342,17 @@ target_position = Vector2(16.891893, 0)
|
|||||||
target_position = Vector2(-17.56757, -0.67567575)
|
target_position = Vector2(-17.56757, -0.67567575)
|
||||||
|
|
||||||
[node name="RightSpawn" type="Marker2D" parent="." unique_id=72314368]
|
[node name="RightSpawn" type="Marker2D" parent="." unique_id=72314368]
|
||||||
position = Vector2(12.837839, -8.1081085)
|
position = Vector2(12.837839, 0)
|
||||||
|
|
||||||
[node name="LeftSpawn" type="Marker2D" parent="." unique_id=374152113]
|
[node name="LeftSpawn" type="Marker2D" parent="." unique_id=374152113]
|
||||||
position = Vector2(-12.837839, -8.108109)
|
position = Vector2(-12.837839, 0.6756754)
|
||||||
|
|
||||||
[node name="PlayerGraphic" type="AnimatedSprite2D" parent="." unique_id=174634956]
|
[node name="PlayerGraphic" type="AnimatedSprite2D" parent="." unique_id=174634956]
|
||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
position = Vector2(0, -6.081082)
|
position = Vector2(0, -6.081082)
|
||||||
sprite_frames = SubResource("SpriteFrames_jej6c")
|
sprite_frames = SubResource("SpriteFrames_jej6c")
|
||||||
animation = &"shoving"
|
animation = &"death"
|
||||||
autoplay = "idle"
|
autoplay = "idle"
|
||||||
frame = 2
|
|
||||||
frame_progress = 1.0
|
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="." unique_id=839648774]
|
[node name="Camera2D" type="Camera2D" parent="." unique_id=839648774]
|
||||||
offset = Vector2(0, -60)
|
offset = Vector2(0, -60)
|
||||||
|
|||||||
71
scenes/slime.tscn
Normal file
71
scenes/slime.tscn
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
[gd_scene format=3 uid="uid://b23q2ppkeamyh"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bj3ccpqo3t7pv" path="res://assets/enemies/slime/slime_green.png" id="1_371uh"]
|
||||||
|
[ext_resource type="Script" uid="uid://d215jspbbgtq6" path="res://scripts/slime.gd" id="1_p2gj0"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_p2gj0"]
|
||||||
|
atlas = ExtResource("1_371uh")
|
||||||
|
region = Rect2(0, 24, 24, 24)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_n6pvg"]
|
||||||
|
atlas = ExtResource("1_371uh")
|
||||||
|
region = Rect2(24, 24, 24, 24)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_pjw23"]
|
||||||
|
atlas = ExtResource("1_371uh")
|
||||||
|
region = Rect2(48, 24, 24, 24)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_2npkn"]
|
||||||
|
atlas = ExtResource("1_371uh")
|
||||||
|
region = Rect2(72, 24, 24, 24)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_fd6lc"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_p2gj0")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_n6pvg")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_pjw23")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_2npkn")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"idle",
|
||||||
|
"speed": 12.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_gstla"]
|
||||||
|
|
||||||
|
[node name="Slime" type="Area2D" unique_id=822623820 groups=["shootable"]]
|
||||||
|
script = ExtResource("1_p2gj0")
|
||||||
|
|
||||||
|
[node name="SlimeGraphic" type="AnimatedSprite2D" parent="." unique_id=610452905]
|
||||||
|
texture_filter = 1
|
||||||
|
position = Vector2(0, -1)
|
||||||
|
sprite_frames = SubResource("SpriteFrames_fd6lc")
|
||||||
|
animation = &"idle"
|
||||||
|
autoplay = "idle"
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1641996317]
|
||||||
|
shape = SubResource("CircleShape2D_gstla")
|
||||||
|
|
||||||
|
[node name="RightCast" type="RayCast2D" parent="." unique_id=460628221]
|
||||||
|
target_position = Vector2(16, 0)
|
||||||
|
|
||||||
|
[node name="RightDownCast" type="RayCast2D" parent="." unique_id=1352799730]
|
||||||
|
position = Vector2(9, 0)
|
||||||
|
target_position = Vector2(1, 14)
|
||||||
|
|
||||||
|
[node name="LeftDownCast" type="RayCast2D" parent="." unique_id=1378900976]
|
||||||
|
position = Vector2(-9, 0)
|
||||||
|
target_position = Vector2(1, 14)
|
||||||
|
|
||||||
|
[node name="LeftCast" type="RayCast2D" parent="." unique_id=1023073791]
|
||||||
|
target_position = Vector2(-16, 0)
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
@ -9,5 +9,6 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_body_entered(body: Node2D) -> void:
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
if body is Crate:
|
if body.is_in_group("shootable"):
|
||||||
|
print("bullet hit!")
|
||||||
bulletHitSignal.emit(body,self)
|
bulletHitSignal.emit(body,self)
|
||||||
|
|||||||
@ -2,11 +2,19 @@ class_name GameController extends Node2D
|
|||||||
signal destroySignal(body)
|
signal destroySignal(body)
|
||||||
signal fanTriggerSignal(body, fanDirection)
|
signal fanTriggerSignal(body, fanDirection)
|
||||||
signal teleportTriggerSignal(body)
|
signal teleportTriggerSignal(body)
|
||||||
|
signal playerDamagedSignal(currentHealth,maxHealth)
|
||||||
|
signal playerDeathSignal
|
||||||
|
|
||||||
var numberOfCrates = 2
|
var numberOfCrates = 2
|
||||||
var timeAvailable = 50
|
var timeAvailable = 50
|
||||||
|
|
||||||
var totalCoinsCollected = 0
|
var totalCoinsCollected = 0
|
||||||
var timer = Timer.new()
|
var timer = Timer.new()
|
||||||
|
|
||||||
|
var enemiesDict={}
|
||||||
|
var playerStartingHealth = 100
|
||||||
|
var playerHealth = 100
|
||||||
|
|
||||||
# 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:
|
||||||
get_window().grab_focus()
|
get_window().grab_focus()
|
||||||
@ -21,7 +29,7 @@ func countdown()->void:
|
|||||||
timeAvailable-=1
|
timeAvailable-=1
|
||||||
if timeAvailable<=0 and numberOfCrates>0:
|
if timeAvailable<=0 and numberOfCrates>0:
|
||||||
print("LOOOOOSAH")
|
print("LOOOOOSAH")
|
||||||
get_tree().reload_current_scene()
|
playerDeathSignal.emit()
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
@ -51,15 +59,48 @@ func coinCollected(body,coin)->void:
|
|||||||
totalCoinsCollected +=1
|
totalCoinsCollected +=1
|
||||||
print("GC knows coin collected")
|
print("GC knows coin collected")
|
||||||
destroySignal.emit(coin)
|
destroySignal.emit(coin)
|
||||||
|
|
||||||
func coinTotal(totalAmount)->void:
|
func coinTotal(totalAmount)->void:
|
||||||
print("GC knows total coins "+str(totalAmount))
|
print("GC knows total coins remaining "+str(totalAmount))
|
||||||
|
|
||||||
func bulletDamage(body, _bullet)->void:
|
func bulletDamage(body, _bullet)->void:
|
||||||
|
print("bullet hit")
|
||||||
if body.is_in_group("shootable"):
|
if body.is_in_group("shootable"):
|
||||||
destroySignal.emit(body)
|
if body is Crate:
|
||||||
destroySignal.emit(_bullet)
|
destroySignal.emit(body)
|
||||||
|
destroySignal.emit(_bullet)
|
||||||
|
if body is Slime:
|
||||||
|
enemiesDict[body]["health"] -= 10
|
||||||
|
if enemiesDict[body]["health"]<=0:
|
||||||
|
#kill the enemy
|
||||||
|
enemiesDict.erase(body)
|
||||||
|
destroySignal.emit(body)
|
||||||
|
destroySignal.emit(_bullet)
|
||||||
|
|
||||||
func rocketDamage(body, rocket)->void:
|
func rocketDamage(body, rocket)->void:
|
||||||
if body.is_in_group("shootable"):
|
if body.is_in_group("shootable"):
|
||||||
print("Rocket strikes target!")
|
print("Rocket strikes target!")
|
||||||
destroySignal.emit(body)
|
destroySignal.emit(body)
|
||||||
|
|
||||||
|
func addEnemyToLevel(enemy:Slime)->void:
|
||||||
|
var enemyStat = {
|
||||||
|
"health": 30+randi_range(0,10),
|
||||||
|
"damage": 20+randi_range(0,10)
|
||||||
|
}
|
||||||
|
enemiesDict[enemy]=enemyStat
|
||||||
|
|
||||||
|
func _on_slime_damage(body, slime:Slime)->void:
|
||||||
|
#remove damage from player health
|
||||||
|
print("remove damage from player "+str(enemiesDict[slime]["damage"]))
|
||||||
|
playerHealth -= enemiesDict[slime]["damage"]
|
||||||
|
if playerHealth <=0:
|
||||||
|
print("You DED")
|
||||||
|
#send a signal about player death
|
||||||
|
playerDeathSignal.emit()
|
||||||
|
else:
|
||||||
|
print("You damaged")
|
||||||
|
#send a signal about player damage
|
||||||
|
playerDamagedSignal.emit(playerHealth,playerStartingHealth)
|
||||||
|
|
||||||
|
func loadLevel()->void:
|
||||||
|
get_tree().reload_current_scene()
|
||||||
|
|||||||
@ -2,6 +2,8 @@ class_name Player extends CharacterBody2D
|
|||||||
signal pushSignal(body, direction)
|
signal pushSignal(body, direction)
|
||||||
signal shootSignal(markerPosition, speed)
|
signal shootSignal(markerPosition, speed)
|
||||||
signal fireSignal(markerPosition, direction, speed)
|
signal fireSignal(markerPosition, direction, speed)
|
||||||
|
signal deathAnimationCompleteSignal
|
||||||
|
|
||||||
@onready var right_cast: RayCast2D = $RightCast
|
@onready var right_cast: RayCast2D = $RightCast
|
||||||
@onready var left_cast: RayCast2D = $LeftCast
|
@onready var left_cast: RayCast2D = $LeftCast
|
||||||
@onready var right_spawn: Marker2D = $RightSpawn
|
@onready var right_spawn: Marker2D = $RightSpawn
|
||||||
@ -19,12 +21,19 @@ const JUMP_VELOCITY = -400.0
|
|||||||
enum FaceDirection {RIGHT,LEFT}
|
enum FaceDirection {RIGHT,LEFT}
|
||||||
var facing:FaceDirection = FaceDirection.RIGHT
|
var facing:FaceDirection = FaceDirection.RIGHT
|
||||||
|
|
||||||
enum PlayerStates {IDLE,RUNNING,JUMPING,FALLING,CHARGING,SHOVING}
|
enum PlayerStates {IDLE,RUNNING,JUMPING,FALLING,CHARGING,SHOVING,HURT,DEAD}
|
||||||
var current_player_state:PlayerStates = PlayerStates.IDLE
|
var current_player_state:PlayerStates = PlayerStates.IDLE
|
||||||
var upJump:bool = false
|
var upJump:bool = false
|
||||||
|
func hurt(health,maxhealth)->void:
|
||||||
|
print("player hurt")
|
||||||
|
current_player_state=PlayerStates.HURT
|
||||||
|
func kill()->void:
|
||||||
|
print("player killed")
|
||||||
|
current_player_state=PlayerStates.DEAD
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
handle_input()
|
if current_player_state != PlayerStates.DEAD:
|
||||||
|
handle_input()
|
||||||
handle_movement(delta)
|
handle_movement(delta)
|
||||||
handle_states()
|
handle_states()
|
||||||
handle_animation()
|
handle_animation()
|
||||||
@ -39,7 +48,6 @@ func handle_input()->void:
|
|||||||
upJump = true
|
upJump = true
|
||||||
# Handle shove.
|
# Handle shove.
|
||||||
if Input.is_action_just_pressed("shove"):
|
if Input.is_action_just_pressed("shove"):
|
||||||
print("I want to shove")
|
|
||||||
if pushRightEnabled and facing==FaceDirection.RIGHT:
|
if pushRightEnabled and facing==FaceDirection.RIGHT:
|
||||||
current_player_state= PlayerStates.CHARGING
|
current_player_state= PlayerStates.CHARGING
|
||||||
pushTimer = Time.get_ticks_msec()
|
pushTimer = Time.get_ticks_msec()
|
||||||
@ -60,7 +68,7 @@ func handle_input()->void:
|
|||||||
current_player_state = PlayerStates.SHOVING
|
current_player_state = PlayerStates.SHOVING
|
||||||
#Handle Shoot Bullet
|
#Handle Shoot Bullet
|
||||||
if Input.is_action_just_pressed("shoot"):
|
if Input.is_action_just_pressed("shoot"):
|
||||||
print("Ima shoot a bullet")
|
|
||||||
#marker postion, speed
|
#marker postion, speed
|
||||||
match facing:
|
match facing:
|
||||||
FaceDirection.RIGHT:
|
FaceDirection.RIGHT:
|
||||||
@ -69,7 +77,7 @@ func handle_input()->void:
|
|||||||
shootSignal.emit(left_spawn.global_transform, -800)
|
shootSignal.emit(left_spawn.global_transform, -800)
|
||||||
#Handle fire rocket
|
#Handle fire rocket
|
||||||
if Input.is_action_just_pressed("fire"):
|
if Input.is_action_just_pressed("fire"):
|
||||||
print("Ima fire rocket")
|
|
||||||
match facing:
|
match facing:
|
||||||
FaceDirection.RIGHT:
|
FaceDirection.RIGHT:
|
||||||
fireSignal.emit(right_spawn.global_transform,Vector2(1,0), 800)
|
fireSignal.emit(right_spawn.global_transform,Vector2(1,0), 800)
|
||||||
@ -95,7 +103,7 @@ func handle_movement(delta)->void:
|
|||||||
velocity += get_gravity() * delta
|
velocity += get_gravity() * delta
|
||||||
func handle_collisions()->void:
|
func handle_collisions()->void:
|
||||||
if right_cast.is_colliding():
|
if right_cast.is_colliding():
|
||||||
print("Right raycast collision")
|
|
||||||
var collider = right_cast.get_collider()
|
var collider = right_cast.get_collider()
|
||||||
if collider is Node:
|
if collider is Node:
|
||||||
pushRightEnabled = true
|
pushRightEnabled = true
|
||||||
@ -104,7 +112,7 @@ func handle_collisions()->void:
|
|||||||
pushRightEnabled = false
|
pushRightEnabled = false
|
||||||
|
|
||||||
if left_cast.is_colliding():
|
if left_cast.is_colliding():
|
||||||
print("Left raycast collision")
|
|
||||||
var collider = left_cast.get_collider()
|
var collider = left_cast.get_collider()
|
||||||
if collider is Node:
|
if collider is Node:
|
||||||
pushLeftEnabled = true
|
pushLeftEnabled = true
|
||||||
@ -148,6 +156,10 @@ func handle_animation()->void:
|
|||||||
player_graphic.play("charging")
|
player_graphic.play("charging")
|
||||||
PlayerStates.SHOVING:
|
PlayerStates.SHOVING:
|
||||||
player_graphic.play("shoving")
|
player_graphic.play("shoving")
|
||||||
|
PlayerStates.HURT:
|
||||||
|
player_graphic.play("hurt")
|
||||||
|
PlayerStates.DEAD:
|
||||||
|
player_graphic.play("death")
|
||||||
|
|
||||||
|
|
||||||
func _on_animation_finished() -> void:
|
func _on_animation_finished() -> void:
|
||||||
@ -156,3 +168,8 @@ func _on_animation_finished() -> void:
|
|||||||
upJump = false
|
upJump = false
|
||||||
PlayerStates.SHOVING:
|
PlayerStates.SHOVING:
|
||||||
current_player_state = PlayerStates.IDLE
|
current_player_state = PlayerStates.IDLE
|
||||||
|
PlayerStates.HURT:
|
||||||
|
current_player_state = PlayerStates.IDLE
|
||||||
|
PlayerStates.DEAD:
|
||||||
|
#emit signal for end of death animation
|
||||||
|
deathAnimationCompleteSignal.emit()
|
||||||
|
|||||||
@ -4,6 +4,7 @@ extends Node2D
|
|||||||
@onready var player: Player = $"../Player"
|
@onready var player: Player = $"../Player"
|
||||||
@onready var coin: Coin = $"../Coins/Coin"
|
@onready var coin: Coin = $"../Coins/Coin"
|
||||||
@onready var coins: Node2D = $"../Coins"
|
@onready var coins: Node2D = $"../Coins"
|
||||||
|
@onready var enemies: Node2D = $"../Enemies"
|
||||||
|
|
||||||
var bullet = preload("res://scenes/bullet.tscn")
|
var bullet = preload("res://scenes/bullet.tscn")
|
||||||
var rocket = preload("res://scenes/rocket.tscn")
|
var rocket = preload("res://scenes/rocket.tscn")
|
||||||
@ -19,11 +20,14 @@ func _ready() -> void:
|
|||||||
player.pushSignal.connect(pushTarget)
|
player.pushSignal.connect(pushTarget)
|
||||||
player.shootSignal.connect(makeBullet)
|
player.shootSignal.connect(makeBullet)
|
||||||
player.fireSignal.connect(makeRocket)
|
player.fireSignal.connect(makeRocket)
|
||||||
|
player.deathAnimationCompleteSignal.connect(game.loadLevel)
|
||||||
|
|
||||||
#signals from the GameController
|
#signals from the GameController
|
||||||
game.destroySignal.connect(destroy)
|
game.destroySignal.connect(destroy)
|
||||||
game.fanTriggerSignal.connect(pushTarget)
|
game.fanTriggerSignal.connect(pushTarget)
|
||||||
game.teleportTriggerSignal.connect(teleportTarget)
|
game.teleportTriggerSignal.connect(teleportTarget)
|
||||||
|
game.playerDamagedSignal.connect(player.hurt)
|
||||||
|
game.playerDeathSignal.connect(player.kill)
|
||||||
|
|
||||||
#signals from pickups
|
#signals from pickups
|
||||||
coin.coinCollectedSignal.connect(game.coinCollected)
|
coin.coinCollectedSignal.connect(game.coinCollected)
|
||||||
@ -38,7 +42,17 @@ func buildLevel()->void:
|
|||||||
#tell GC how many crates...
|
#tell GC how many crates...
|
||||||
updateCrates()
|
updateCrates()
|
||||||
updateCoins()
|
updateCoins()
|
||||||
|
updateEnemies()
|
||||||
|
|
||||||
|
func updateEnemies()->void:
|
||||||
|
if enemies:
|
||||||
|
for obj in enemies.get_children():
|
||||||
|
if obj is Slime:
|
||||||
|
game.addEnemyToLevel(obj)
|
||||||
|
#hook up to game controller
|
||||||
|
if not obj.slimeDamageSignal.is_connected(game._on_slime_damage):
|
||||||
|
obj.slimeDamageSignal.connect(game._on_slime_damage)
|
||||||
|
|
||||||
func updateCrates()->void:
|
func updateCrates()->void:
|
||||||
var totalCrates = 0
|
var totalCrates = 0
|
||||||
if crates:
|
if crates:
|
||||||
@ -50,11 +64,16 @@ func updateCrates()->void:
|
|||||||
|
|
||||||
game.crateTotal(totalCrates)
|
game.crateTotal(totalCrates)
|
||||||
|
|
||||||
|
#any time a coin exits tree, game controller is updated
|
||||||
func updateCoins()->void:
|
func updateCoins()->void:
|
||||||
var totalCoins = 0
|
var totalCoins = 0
|
||||||
if coins:
|
if coins:
|
||||||
for obj in coins.get_children():
|
for obj in coins.get_children():
|
||||||
if obj is Coin:
|
if obj is Coin:
|
||||||
|
if not obj.coinCollectedSignal.is_connected(game.coinCollected):
|
||||||
|
obj.coinCollectedSignal.connect(game.coinCollected)
|
||||||
|
if not obj.tree_exited.is_connected(updateCoins):
|
||||||
|
obj.tree_exited.connect(updateCoins)
|
||||||
totalCoins +=1
|
totalCoins +=1
|
||||||
game.coinTotal(totalCoins)
|
game.coinTotal(totalCoins)
|
||||||
|
|
||||||
|
|||||||
33
scripts/slime.gd
Normal file
33
scripts/slime.gd
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
class_name Slime extends Area2D
|
||||||
|
@onready var right_cast: RayCast2D = $RightCast
|
||||||
|
@onready var right_down_cast: RayCast2D = $RightDownCast
|
||||||
|
@onready var left_down_cast: RayCast2D = $LeftDownCast
|
||||||
|
@onready var left_cast: RayCast2D = $LeftCast
|
||||||
|
@onready var slime_graphic: AnimatedSprite2D = $SlimeGraphic
|
||||||
|
|
||||||
|
var speed:int = 100
|
||||||
|
var direction = 1
|
||||||
|
|
||||||
|
signal slimeDamageSignal(body,slime)
|
||||||
|
|
||||||
|
#Animation code
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if not right_down_cast.is_colliding():
|
||||||
|
direction = -1
|
||||||
|
slime_graphic.flip_h = true
|
||||||
|
if not left_down_cast.is_colliding():
|
||||||
|
direction = 1
|
||||||
|
slime_graphic.flip_h = false
|
||||||
|
if right_cast.is_colliding() && not right_cast.get_collider() is Player:
|
||||||
|
direction = -1
|
||||||
|
slime_graphic.flip_h = true
|
||||||
|
if left_cast.is_colliding() && not left_cast.get_collider() is Player:
|
||||||
|
direction = 1
|
||||||
|
slime_graphic.flip_h = false
|
||||||
|
position.x += direction * speed * delta
|
||||||
|
|
||||||
|
|
||||||
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
|
if body is Player:
|
||||||
|
slimeDamageSignal.emit(body, self)
|
||||||
|
|
||||||
1
scripts/slime.gd.uid
Normal file
1
scripts/slime.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://d215jspbbgtq6
|
||||||
Loading…
Reference in New Issue
Block a user