diff --git a/ahmedgg/assets/graphics/Objects/crate.png b/ahmedgg/assets/graphics/Objects/crate.png new file mode 100644 index 0000000..2b8bdcd Binary files /dev/null and b/ahmedgg/assets/graphics/Objects/crate.png differ diff --git a/ahmedgg/assets/graphics/Objects/crate.png.import b/ahmedgg/assets/graphics/Objects/crate.png.import new file mode 100644 index 0000000..9160192 --- /dev/null +++ b/ahmedgg/assets/graphics/Objects/crate.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://4nqpycrddg6h" +path="res://.godot/imported/crate.png-91fc7aa90c75ee2024a967b1d4565c18.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/Objects/crate.png" +dest_files=["res://.godot/imported/crate.png-91fc7aa90c75ee2024a967b1d4565c18.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/ahmedgg/assets/graphics/Player/Idle/Player Idle 48x48.png b/ahmedgg/assets/graphics/Player/Idle/Player Idle 48x48.png new file mode 100644 index 0000000..b618511 Binary files /dev/null and b/ahmedgg/assets/graphics/Player/Idle/Player Idle 48x48.png differ diff --git a/ahmedgg/assets/graphics/Player/Idle/Player Idle 48x48.png.import b/ahmedgg/assets/graphics/Player/Idle/Player Idle 48x48.png.import new file mode 100644 index 0000000..76f033b --- /dev/null +++ b/ahmedgg/assets/graphics/Player/Idle/Player Idle 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://icriib26yeyf" +path="res://.godot/imported/Player Idle 48x48.png-740fd4b43eb9bfbc6efa252928b4dd33.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/Player/Idle/Player Idle 48x48.png" +dest_files=["res://.godot/imported/Player Idle 48x48.png-740fd4b43eb9bfbc6efa252928b4dd33.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/ahmedgg/assets/graphics/Player/Jump/player jump 48x48.png b/ahmedgg/assets/graphics/Player/Jump/player jump 48x48.png new file mode 100644 index 0000000..dff105c Binary files /dev/null and b/ahmedgg/assets/graphics/Player/Jump/player jump 48x48.png differ diff --git a/ahmedgg/assets/graphics/Player/Jump/player jump 48x48.png.import b/ahmedgg/assets/graphics/Player/Jump/player jump 48x48.png.import new file mode 100644 index 0000000..a048662 --- /dev/null +++ b/ahmedgg/assets/graphics/Player/Jump/player jump 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bn36q6gcynhcq" +path="res://.godot/imported/player jump 48x48.png-1115ef88c02151688a170eaf350a6617.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/Player/Jump/player jump 48x48.png" +dest_files=["res://.godot/imported/player jump 48x48.png-1115ef88c02151688a170eaf350a6617.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/ahmedgg/assets/graphics/Player/Run/player run 48x48.png b/ahmedgg/assets/graphics/Player/Run/player run 48x48.png new file mode 100644 index 0000000..aca5b55 Binary files /dev/null and b/ahmedgg/assets/graphics/Player/Run/player run 48x48.png differ diff --git a/ahmedgg/assets/graphics/Player/Run/player run 48x48.png.import b/ahmedgg/assets/graphics/Player/Run/player run 48x48.png.import new file mode 100644 index 0000000..4efbd4e --- /dev/null +++ b/ahmedgg/assets/graphics/Player/Run/player run 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bof6t3qn0xd1x" +path="res://.godot/imported/player run 48x48.png-3a13b69f2b69d0a6e1784e4a5e90ca9c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/Player/Run/player run 48x48.png" +dest_files=["res://.godot/imported/player run 48x48.png-3a13b69f2b69d0a6e1784e4a5e90ca9c.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/ahmedgg/assets/graphics/projectiles/pixel_bullet.png b/ahmedgg/assets/graphics/projectiles/pixel_bullet.png new file mode 100644 index 0000000..900d030 Binary files /dev/null and b/ahmedgg/assets/graphics/projectiles/pixel_bullet.png differ diff --git a/ahmedgg/assets/graphics/projectiles/pixel_bullet.png.import b/ahmedgg/assets/graphics/projectiles/pixel_bullet.png.import new file mode 100644 index 0000000..8fb7959 --- /dev/null +++ b/ahmedgg/assets/graphics/projectiles/pixel_bullet.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dfufhh6qedp4f" +path="res://.godot/imported/pixel_bullet.png-30d6d1e8b5e1332f8b2e2cee72a9e790.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/projectiles/pixel_bullet.png" +dest_files=["res://.godot/imported/pixel_bullet.png-30d6d1e8b5e1332f8b2e2cee72a9e790.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/ahmedgg/bullet.gd b/ahmedgg/bullet.gd index 16e3d2d..34c982e 100644 --- a/ahmedgg/bullet.gd +++ b/ahmedgg/bullet.gd @@ -1,11 +1,16 @@ class_name Bullet extends Area2D +@onready var bulletGraphic: Sprite2D = $Sprite2D -var speed = 750 +var speed = 500 signal hit(bullet, body) func setSpeed(value): speed = value + if speed <0: + bulletGraphic.flip_h = true + if speed>0: + bulletGraphic.flip_h = false #animation func _physics_process(delta: float) -> void: @@ -13,5 +18,6 @@ func _physics_process(delta: float) -> void: func _on_body_entered(body: Node2D) -> void: - print ("bullet collision") + print ("bullet collision") + if not body is Player: hit.emit(self, body) diff --git a/ahmedgg/project.godot b/ahmedgg/project.godot index 9197317..dd056da 100644 --- a/ahmedgg/project.godot +++ b/ahmedgg/project.godot @@ -15,9 +15,18 @@ run/main_scene="res://scenes/ahmed_gg.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icon.svg" +[display] + +window/size/viewport_width=380 +window/size/viewport_height=240 +window/size/window_width_override=960 +window/size/window_height_override=540 +window/stretch/mode="viewport" + [file_customization] folder_colors={ +"res://assets/": "red", "res://scenes/": "green", "res://scripts/": "pink" } diff --git a/ahmedgg/scenes/ahmed_gg.tscn b/ahmedgg/scenes/ahmed_gg.tscn index a4784e8..03c4284 100644 --- a/ahmedgg/scenes/ahmed_gg.tscn +++ b/ahmedgg/scenes/ahmed_gg.tscn @@ -1,37 +1,32 @@ -[gd_scene load_steps=10 format=3 uid="uid://c7psh8jpkkc6x"] +[gd_scene load_steps=12 format=3 uid="uid://c7psh8jpkkc6x"] -[ext_resource type="Script" path="res://scripts/game controller.gd" id="1_pcysq"] -[ext_resource type="Script" path="res://scripts/trigger.gd" id="1_tp4vr"] +[ext_resource type="Script" path="res://scripts/game_controller.gd" id="1_pcysq"] +[ext_resource type="PackedScene" uid="uid://c81n274ug0a7g" path="res://scenes/trigger.tscn" id="2_ti1yu"] [ext_resource type="PackedScene" uid="uid://b0d1gs2knc2l8" path="res://scenes/player.tscn" id="3_70p4h"] +[ext_resource type="PackedScene" uid="uid://c0tjxqfvsxh5a" path="res://scenes/crate.tscn" id="3_af2om"] +[ext_resource type="Script" path="res://scripts/crate.gd" id="4_erghp"] [ext_resource type="PackedScene" uid="uid://dg6vhq7diydcj" path="res://scenes/bullet.tscn" id="4_vo7vc"] [ext_resource type="Script" path="res://scripts/scene_manager.gd" id="5_w3sh3"] -[sub_resource type="CircleShape2D" id="CircleShape2D_785vb"] -radius = 88.1419 - [sub_resource type="RectangleShape2D" id="RectangleShape2D_nynyi"] size = Vector2(96, 20) [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ukrrp"] +distance = -212.0 -[sub_resource type="RectangleShape2D" id="RectangleShape2D_gv8hf"] +[sub_resource type="CircleShape2D" id="CircleShape2D_5skqu"] -[node name="AhmedGG" type="Node2D"] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_xevc8"] +size = Vector2(12.7899, 20) + +[node name="Game" type="Node2D"] +scale = Vector2(1.00342, 1) script = ExtResource("1_pcysq") -[node name="Trigger" type="Area2D" parent="."] -position = Vector2(400, 339) -script = ExtResource("1_tp4vr") -metadata/_edit_group_ = true - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Trigger"] -shape = SubResource("CircleShape2D_785vb") -debug_color = Color(0.489643, 0.4608, 0.929032, 0.42) - [node name="level" type="Node2D" parent="."] [node name="StaticBody2D" type="StaticBody2D" parent="level"] -position = Vector2(296, 246) +position = Vector2(363.756, 472) metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="level/StaticBody2D"] @@ -41,10 +36,11 @@ shape = SubResource("RectangleShape2D_nynyi") [node name="CollisionShape2D" type="CollisionShape2D" parent="level/StaticBody2D2"] position = Vector2(295, 431) +scale = Vector2(9.37136, 1) shape = SubResource("WorldBoundaryShape2D_ukrrp") [node name="StaticBody2D3" type="StaticBody2D" parent="level"] -position = Vector2(394, 228) +position = Vector2(463.415, 416) metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="level/StaticBody2D3"] @@ -52,65 +48,55 @@ rotation = -0.412146 shape = SubResource("RectangleShape2D_nynyi") [node name="StaticBody2D4" type="StaticBody2D" parent="level"] -position = Vector2(109, 358) +position = Vector2(161.448, 545) metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="level/StaticBody2D4"] shape = SubResource("RectangleShape2D_nynyi") [node name="StaticBody2D5" type="StaticBody2D" parent="level"] -position = Vector2(182, 299) +position = Vector2(258.117, 505) metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="level/StaticBody2D5"] shape = SubResource("RectangleShape2D_nynyi") [node name="StaticBody2D6" type="StaticBody2D" parent="level"] -position = Vector2(161, 225) +position = Vector2(576.03, 550) metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="level/StaticBody2D6"] shape = SubResource("RectangleShape2D_nynyi") +[node name="StaticBody2D7" type="StaticBody2D" parent="level"] +position = Vector2(61.7887, 591) +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="level/StaticBody2D7"] +shape = SubResource("RectangleShape2D_nynyi") + [node name="crates" type="Node2D" parent="."] +scale = Vector2(1.00102, 1) -[node name="RigidBody2D" type="RigidBody2D" parent="crates"] -position = Vector2(307, 34) -rotation = 0.785398 -metadata/_edit_group_ = true +[node name="crate1" parent="crates" instance=ExtResource("3_af2om")] +position = Vector2(620.876, 381) +scale = Vector2(0.961, 1) +script = ExtResource("4_erghp") -[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/RigidBody2D"] -shape = SubResource("RectangleShape2D_gv8hf") -debug_color = Color(0.850993, 0.368517, 0.134324, 0.42) +[node name="crate2" parent="crates" instance=ExtResource("3_af2om")] +position = Vector2(665.723, 305) +scale = Vector2(0.961, 1) +script = ExtResource("4_erghp") -[node name="RigidBody2D2" type="RigidBody2D" parent="crates"] -position = Vector2(247, 100) -rotation = 1.33752 -metadata/_edit_group_ = true +[node name="crate3" parent="crates" instance=ExtResource("3_af2om")] +position = Vector2(740.467, 404) +scale = Vector2(0.961, 1) +script = ExtResource("4_erghp") -[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/RigidBody2D2"] -shape = SubResource("RectangleShape2D_gv8hf") -debug_color = Color(0.850993, 0.368517, 0.134324, 0.42) - -[node name="RigidBody2D3" type="RigidBody2D" parent="crates"] -position = Vector2(355, 185) -rotation = 2.67504 -scale = Vector2(1, 1) -metadata/_edit_group_ = true - -[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/RigidBody2D3"] -shape = SubResource("RectangleShape2D_gv8hf") -debug_color = Color(0.850993, 0.368517, 0.134324, 0.42) - -[node name="RigidBody2D4" type="RigidBody2D" parent="crates"] -position = Vector2(138.409, 137.33) -rotation = -0.933105 -scale = Vector2(1, 1) -metadata/_edit_group_ = true - -[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/RigidBody2D4"] -shape = SubResource("RectangleShape2D_gv8hf") -debug_color = Color(0.850993, 0.368517, 0.134324, 0.42) +[node name="crate4" parent="crates" instance=ExtResource("3_af2om")] +position = Vector2(821.191, 315) +scale = Vector2(0.961, 1) +script = ExtResource("4_erghp") [node name="CharacterBody2D" parent="." instance=ExtResource("3_70p4h")] position = Vector2(407, 65) @@ -122,5 +108,25 @@ position = Vector2(-95, 221) unique_name_in_owner = true script = ExtResource("5_w3sh3") -[connection signal="areatrigger" from="Trigger" to="." method="_on_trigger_areatrigger"] -[connection signal="body_entered" from="Trigger" to="Trigger" method="_on_body_entered"] +[node name="Triggers" type="Node2D" parent="."] + +[node name="Trigger" parent="Triggers" instance=ExtResource("2_ti1yu")] +position = Vector2(984.633, 590) +scale = Vector2(4.89056, -5.15013) +effect = "destroy" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Triggers/Trigger"] +shape = SubResource("CircleShape2D_5skqu") +debug_color = Color(0.852174, 0.268268, 0.648794, 0.42) + +[node name="powerup" parent="Triggers" instance=ExtResource("2_ti1yu")] +position = Vector2(485.34, 352) +rotation = 3.14159 +scale = Vector2(4.28659, -3.95816) +effect = "powerup" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Triggers/powerup"] +position = Vector2(-21.1567, 36.8858) +scale = Vector2(0.998303, 1.01771) +shape = SubResource("RectangleShape2D_xevc8") +debug_color = Color(0.161783, 0.629796, 0.397798, 0.42) diff --git a/ahmedgg/scenes/bullet.tscn b/ahmedgg/scenes/bullet.tscn index eb1e243..25566a1 100644 --- a/ahmedgg/scenes/bullet.tscn +++ b/ahmedgg/scenes/bullet.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=3 format=3 uid="uid://dg6vhq7diydcj"] +[gd_scene load_steps=4 format=3 uid="uid://dg6vhq7diydcj"] [ext_resource type="Script" path="res://bullet.gd" id="1_oufr4"] +[ext_resource type="Texture2D" uid="uid://dfufhh6qedp4f" path="res://assets/graphics/projectiles/pixel_bullet.png" id="2_c2mac"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_5fful"] size = Vector2(8, 2) @@ -12,4 +13,9 @@ script = ExtResource("1_oufr4") shape = SubResource("RectangleShape2D_5fful") debug_color = Color(0.900724, 0.259856, 0.444017, 0.42) +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(-2, 1) +scale = Vector2(-0.103094, 0.0402737) +texture = ExtResource("2_c2mac") + [connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/ahmedgg/scenes/crate.tscn b/ahmedgg/scenes/crate.tscn new file mode 100644 index 0000000..36dd0ec --- /dev/null +++ b/ahmedgg/scenes/crate.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=3 uid="uid://c0tjxqfvsxh5a"] + +[ext_resource type="Texture2D" uid="uid://4nqpycrddg6h" path="res://assets/graphics/Objects/crate.png" id="1_kwx7y"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_gv8hf"] +size = Vector2(40, 52) + +[node name="crate1" type="RigidBody2D"] +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_gv8hf") +debug_color = Color(0.850993, 0.368517, 0.134324, 0.42) + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture_filter = 1 +position = Vector2(0, -4) +scale = Vector2(-0.144321, -0.17212) +texture = ExtResource("1_kwx7y") diff --git a/ahmedgg/scenes/player.tscn b/ahmedgg/scenes/player.tscn index 3048dc4..f2cc0a5 100644 --- a/ahmedgg/scenes/player.tscn +++ b/ahmedgg/scenes/player.tscn @@ -1,6 +1,9 @@ -[gd_scene load_steps=4 format=3 uid="uid://b0d1gs2knc2l8"] +[gd_scene load_steps=29 format=3 uid="uid://b0d1gs2knc2l8"] [ext_resource type="Script" path="res://scripts/Player.gd" id="1_rdo8w"] +[ext_resource type="Texture2D" uid="uid://icriib26yeyf" path="res://assets/graphics/Player/Idle/Player Idle 48x48.png" id="2_x2pxh"] +[ext_resource type="Texture2D" uid="uid://bof6t3qn0xd1x" path="res://assets/graphics/Player/Run/player run 48x48.png" id="3_gk0t6"] +[ext_resource type="Texture2D" uid="uid://bn36q6gcynhcq" path="res://assets/graphics/Player/Jump/player jump 48x48.png" id="3_mnvao"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_wfabo"] @@ -18,6 +21,171 @@ func _process(delta: float) -> void: pass " +[sub_resource type="AtlasTexture" id="AtlasTexture_o8cwf"] +atlas = ExtResource("2_x2pxh") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qtraf"] +atlas = ExtResource("2_x2pxh") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wuftw"] +atlas = ExtResource("2_x2pxh") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_v4xka"] +atlas = ExtResource("2_x2pxh") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ho0ee"] +atlas = ExtResource("2_x2pxh") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_051bw"] +atlas = ExtResource("2_x2pxh") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_w1320"] +atlas = ExtResource("2_x2pxh") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hx0kr"] +atlas = ExtResource("2_x2pxh") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_axdda"] +atlas = ExtResource("2_x2pxh") +region = Rect2(384, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ae1dk"] +atlas = ExtResource("2_x2pxh") +region = Rect2(432, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_14dvy"] +atlas = ExtResource("3_mnvao") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nao2h"] +atlas = ExtResource("3_mnvao") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_fr1eb"] +atlas = ExtResource("3_mnvao") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sfbgs"] +atlas = ExtResource("3_gk0t6") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rk2g7"] +atlas = ExtResource("3_gk0t6") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bto8x"] +atlas = ExtResource("3_gk0t6") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ddwp3"] +atlas = ExtResource("3_gk0t6") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_3ldfs"] +atlas = ExtResource("3_gk0t6") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_jhtx2"] +atlas = ExtResource("3_gk0t6") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yjpde"] +atlas = ExtResource("3_gk0t6") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gjcsd"] +atlas = ExtResource("3_gk0t6") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="SpriteFrames" id="SpriteFrames_ogkf0"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_o8cwf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qtraf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wuftw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_v4xka") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ho0ee") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_051bw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_w1320") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_hx0kr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_axdda") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ae1dk") +}], +"loop": true, +"name": &"idle", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_14dvy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nao2h") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_fr1eb") +}], +"loop": false, +"name": &"jump", +"speed": 9.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_sfbgs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rk2g7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bto8x") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ddwp3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_3ldfs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_jhtx2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yjpde") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gjcsd") +}], +"loop": true, +"name": &"run", +"speed": 12.0 +}] + [node name="CharacterBody2D" type="CharacterBody2D"] script = ExtResource("1_rdo8w") @@ -37,3 +205,12 @@ position = Vector2(21, -20) [node name="leftTarget_Node2D" type="Node2D" parent="."] position = Vector2(15, -20) script = SubResource("GDScript_46ryu") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +texture_filter = 1 +position = Vector2(1, -2) +sprite_frames = SubResource("SpriteFrames_ogkf0") +animation = &"jump" +autoplay = "jump" + +[node name="Camera2D" type="Camera2D" parent="."] diff --git a/ahmedgg/scenes/trigger.tscn b/ahmedgg/scenes/trigger.tscn new file mode 100644 index 0000000..1f7edb6 --- /dev/null +++ b/ahmedgg/scenes/trigger.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://c81n274ug0a7g"] + +[ext_resource type="Script" path="res://scripts/trigger.gd" id="1_ivj0o"] + +[node name="Trigger" type="Area2D"] +script = ExtResource("1_ivj0o") +metadata/_edit_group_ = true + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/ahmedgg/scripts/Player.gd b/ahmedgg/scripts/Player.gd index 014a06a..c808e2c 100644 --- a/ahmedgg/scripts/Player.gd +++ b/ahmedgg/scripts/Player.gd @@ -1,4 +1,5 @@ -extends CharacterBody2D +class_name Player extends CharacterBody2D +@onready var playerGraphic: AnimatedSprite2D = $AnimatedSprite2D const SPEED = 300.0 @@ -9,6 +10,7 @@ var faceLeft=false var pushRightEnabled = false var pushLeftEnabled = false var pushTarget +var isJumping = false @onready var right_target: Node2D = $rightTarget_Node2D @onready var left_target: Node2D = $leftTarget_Node2D @@ -22,10 +24,14 @@ func _physics_process(delta: float) -> void: # Add the gravity. if not is_on_floor(): velocity += get_gravity() * delta + else: + isJumping = false # Handle jump.right_cast if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY + isJumping = true + playerGraphic.play("jump") # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. @@ -51,10 +57,18 @@ func _physics_process(delta: float) -> void: velocity.x = direction * SPEED else: velocity.x = move_toward(velocity.x, 0, SPEED) + if direction: + if not isJumping: + playerGraphic.play("run") + if direction ==0: + if not isJumping: + playerGraphic.play("idle") if direction<0: faceLeft=true + playerGraphic.flip_h = true if direction>0: faceLeft=false + playerGraphic.flip_h = false move_and_slide() diff --git a/ahmedgg/scripts/crate.gd b/ahmedgg/scripts/crate.gd new file mode 100644 index 0000000..7f42195 --- /dev/null +++ b/ahmedgg/scripts/crate.gd @@ -0,0 +1 @@ +class_name Crate extends RigidBody2D diff --git a/ahmedgg/scripts/game controller.gd b/ahmedgg/scripts/game controller.gd deleted file mode 100644 index 507220c..0000000 --- a/ahmedgg/scripts/game controller.gd +++ /dev/null @@ -1,27 +0,0 @@ -extends Node2D - -# Game Data -var totalcrates=4 -var cratesdestroyed = 0 - - - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass - - -func _on_trigger_areatrigger(body) -> void: - print("game conroller knows about crate destruction") - cratesdestroyed +=1 - totalcrates -=1 - #kill - body.queue_free() - if totalcrates <=0: - print("you won") - diff --git a/ahmedgg/scripts/game_controller.gd b/ahmedgg/scripts/game_controller.gd new file mode 100644 index 0000000..17fe61e --- /dev/null +++ b/ahmedgg/scripts/game_controller.gd @@ -0,0 +1,43 @@ +class_name GameController extends Node2D + + +# Game Data +var totalcrates=4 +var cratesdestroyed = 0 + + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_trigger_areatrigger(effect, body) -> void: + print("Do effect " +effect) + match effect: + "destroy": + #write code to destroy + if body is Crate: + %SceneManager.destroy(body) + cratesdestroyed +=1 + "powerup": + #write code to power up + if body is Player: + print ("power up the player") + +func bulletHit(body): + print("Game Controller knows bullet hit") + if body is Crate: + print ("you hit a crate") + cratesdestroyed +=1 + %SceneManager.destroy(body) + print("Crates remaining::"+str(totalcrates - cratesdestroyed)) + +func numberofCrates (value): + totalcrates = value + print("Game Controller knows crates "+str(totalcrates)) diff --git a/ahmedgg/scripts/scene_manager.gd b/ahmedgg/scripts/scene_manager.gd index 4791b2d..c0e81d5 100644 --- a/ahmedgg/scripts/scene_manager.gd +++ b/ahmedgg/scripts/scene_manager.gd @@ -1,4 +1,7 @@ extends Node +@onready var gameController: GameController = $".." +@onready var crates: Node2D = $"../crates" +@onready var triggers: Node2D = $"../Triggers" var bulletsFiredTotal = 0 var bulletsMadeTotal = 0 @@ -29,3 +32,25 @@ func makeBullet(position,speed): newBullet.transform = position func bulletHit(bullet, body): print("tell game controller we hit something") + gameController.bulletHit(body) + bullet.setSpeed(0) + bullet.position = Vector2(-100,-100) + +func destroy(body): + body.queue_free() +func buildLevel(): + #how many crates? + var totalCrates = 0 + for obj in crates.get_children(): + if obj is Crate: + totalCrates +=1 + gameController.numberofCrates(totalCrates) + + #wire up the triggers + for obj in triggers.get_children(): + if obj is Trigger: + #wire out to GC + obj.areatrigger.connect(gameController._on_trigger_areatrigger) + +func _ready() -> void: + buildLevel() diff --git a/ahmedgg/scripts/trigger.gd b/ahmedgg/scripts/trigger.gd index 6637a82..533514b 100644 --- a/ahmedgg/scripts/trigger.gd +++ b/ahmedgg/scripts/trigger.gd @@ -1,6 +1,7 @@ -extends Area2D +class_name Trigger extends Area2D +@export var effect = "alert" -signal areatrigger(Object) +signal areatrigger(effect, Object) # Called when the node enters the scene tree for the first time. func _ready() -> void: print("Trigger is here") @@ -13,4 +14,5 @@ func _process(delta: float) -> void: func _on_body_entered(body: Node2D) -> void: print("Body Collision in trigger") - areatrigger.emit(body) + areatrigger.emit(effect, body) +