diff --git a/scenes/bullet/bullet.gd b/scenes/bullet/bullet.gd index 19ad82f..7697f0f 100644 --- a/scenes/bullet/bullet.gd +++ b/scenes/bullet/bullet.gd @@ -4,5 +4,11 @@ var speed = 100 var base_speed = 10 var direction = 0 +var damage +var hostile = false + func _physics_process(delta: float) -> void: position += speed*delta*base_speed*direction + + if position.x < 0 or position.x > 256 or position.y < 0 or position.y > 256: + queue_free() diff --git a/scenes/enemies/enemy.gd b/scenes/enemies/enemy.gd new file mode 100644 index 0000000..67fb443 --- /dev/null +++ b/scenes/enemies/enemy.gd @@ -0,0 +1,11 @@ +extends Node2D + +var speed = 10 + +@export var player : CharacterBody2D + +@onready var navigation : NavigationAgent2D = $NavigationAgent2D + +func _physics_process(delta: float) -> void: + navigation.target_position = player.positiond + position = position.move_toward(navigation.get_next_path_position(), delta*speed) diff --git a/scenes/enemies/enemy.gd.uid b/scenes/enemies/enemy.gd.uid new file mode 100644 index 0000000..bf1e15a --- /dev/null +++ b/scenes/enemies/enemy.gd.uid @@ -0,0 +1 @@ +uid://do2o6v238umse diff --git a/scenes/enemies/grunt/grunt.png b/scenes/enemies/grunt/grunt.png new file mode 100644 index 0000000..a88f2ab Binary files /dev/null and b/scenes/enemies/grunt/grunt.png differ diff --git a/scenes/enemies/grunt/grunt.png.import b/scenes/enemies/grunt/grunt.png.import new file mode 100644 index 0000000..115f2fe --- /dev/null +++ b/scenes/enemies/grunt/grunt.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://nj5tjjv0a6v8" +path="res://.godot/imported/grunt.png-dd52cfd366c89106c2822cb066859c32.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/enemies/grunt/grunt.png" +dest_files=["res://.godot/imported/grunt.png-dd52cfd366c89106c2822cb066859c32.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/scenes/enemies/grunt/grunt.tscn b/scenes/enemies/grunt/grunt.tscn new file mode 100644 index 0000000..a3d1237 --- /dev/null +++ b/scenes/enemies/grunt/grunt.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=4 format=3 uid="uid://bnufqnypubedj"] + +[ext_resource type="Script" uid="uid://do2o6v238umse" path="res://scenes/enemies/enemy.gd" id="1_y73h6"] +[ext_resource type="Texture2D" uid="uid://nj5tjjv0a6v8" path="res://scenes/enemies/grunt/grunt.png" id="2_668pk"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_cahuy"] + +[node name="Grunt" type="Area2D"] +script = ExtResource("1_y73h6") + +[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."] +avoidance_enabled = true +max_speed = 50.0 + +[node name="Grunt" type="Sprite2D" parent="."] +texture = ExtResource("2_668pk") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_cahuy") + +[node name="NavigationObstacle2D" type="NavigationObstacle2D" parent="."] +radius = 10.0 +avoidance_enabled = false diff --git a/scenes/inventory/WindowPane.png b/scenes/inventory/WindowPane.png index 1c15394..81bbffa 100644 Binary files a/scenes/inventory/WindowPane.png and b/scenes/inventory/WindowPane.png differ diff --git a/scenes/inventory/WindowPane.pxo b/scenes/inventory/WindowPane.pxo index 14bfad9..e7e24c9 100644 Binary files a/scenes/inventory/WindowPane.pxo and b/scenes/inventory/WindowPane.pxo differ diff --git a/scenes/inventory/inventory.gd b/scenes/inventory/inventory.gd index a161840..e1e7274 100644 --- a/scenes/inventory/inventory.gd +++ b/scenes/inventory/inventory.gd @@ -5,6 +5,11 @@ var items : Array[Array] @onready var positive_modifiers = [$Speed,$BulletSpeed,$Ammunition,$Damage] @onready var negative_modifiers = [$IncomingDamage,$FiringDelay,$Size,$TaxRate] +@onready var remaining_ammunition = $RemainingAmmunition +@onready var health = $Health +@onready var money = $Money +@onready var score = $Score + var item_offset : int = 26 @export var bonus_scene : PackedScene @@ -85,6 +90,11 @@ func update_calculations(): 3: player.tax = total negative_modifiers[x].text = '=' + str(total) +func update_stats(): + remaining_ammunition.text = '- ' + str(player.remaining_bullets) + health.text = '- ' + str(player.health) + money.text = '- ' + str(player.money) + score.text = 'SCORE - ' + str(player.score) func inventory_to_global_coords(position : Vector2i) -> Vector2: return items_start.global_position + Vector2(position.x*item_offset,position.y*item_offset) diff --git a/scenes/inventory/inventory.tscn b/scenes/inventory/inventory.tscn index 69dbce6..8cee76e 100644 --- a/scenes/inventory/inventory.tscn +++ b/scenes/inventory/inventory.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://o6e5ybx262ig"] +[gd_scene load_steps=12 format=3 uid="uid://o6e5ybx262ig"] [ext_resource type="Script" uid="uid://466pugqribug" path="res://scenes/inventory/inventory.gd" id="1_el5y6"] [ext_resource type="PackedScene" uid="uid://csdmile32lfyy" path="res://scenes/inventory/number/number.tscn" id="2_4axmw"] @@ -16,6 +16,21 @@ font = ExtResource("4_tvok8") font_size = 8 font_color = Color(0.156863, 0.137255, 0.156863, 1) +[sub_resource type="LabelSettings" id="LabelSettings_x4j3l"] +font = ExtResource("4_tvok8") +font_size = 8 +font_color = Color(0.772549, 0.411765, 0.505882, 1) + +[sub_resource type="LabelSettings" id="LabelSettings_l6cit"] +font = ExtResource("4_tvok8") +font_size = 8 +font_color = Color(0.329412, 0.360784, 0.494118, 1) + +[sub_resource type="LabelSettings" id="LabelSettings_efxst"] +font = ExtResource("4_tvok8") +font_size = 8 +font_color = Color(0.156863, 0.137255, 0.156863, 1) + [sub_resource type="LabelSettings" id="LabelSettings_v8e04"] font = ExtResource("4_tvok8") font_size = 8 @@ -59,9 +74,36 @@ offset_left = -105.0 offset_top = 26.0 offset_right = -85.0 offset_bottom = 49.0 -text = "- 100" +text = "- 7" label_settings = SubResource("LabelSettings_kl7fi") +[node name="Health" type="Label" parent="."] +layout_mode = 0 +offset_left = -105.0 +offset_top = 36.0 +offset_right = -85.0 +offset_bottom = 59.0 +text = "- 100" +label_settings = SubResource("LabelSettings_x4j3l") + +[node name="Money" type="Label" parent="."] +layout_mode = 0 +offset_left = -105.0 +offset_top = 48.0 +offset_right = -85.0 +offset_bottom = 71.0 +text = "- 0" +label_settings = SubResource("LabelSettings_l6cit") + +[node name="Score" type="Label" parent="."] +layout_mode = 0 +offset_left = -118.0 +offset_top = 115.0 +offset_right = 4.0 +offset_bottom = 140.0 +text = "SCORE - 0" +label_settings = SubResource("LabelSettings_efxst") + [node name="BulletSpeed" type="Label" parent="."] layout_mode = 0 offset_left = -20.0 @@ -88,6 +130,7 @@ text = "=10" label_settings = SubResource("LabelSettings_bxceu") [node name="Size" type="Label" parent="."] +layout_mode = 0 offset_left = -71.0 offset_top = -17.0 offset_right = -46.0 @@ -97,6 +140,7 @@ label_settings = SubResource("LabelSettings_v8e04") horizontal_alignment = 1 [node name="TaxRate" type="Label" parent="."] +layout_mode = 0 offset_left = -46.0 offset_top = -17.0 offset_right = -21.0 @@ -106,6 +150,7 @@ label_settings = SubResource("LabelSettings_v8e04") horizontal_alignment = 1 [node name="FiringDelay" type="Label" parent="."] +layout_mode = 0 offset_left = -98.0 offset_top = -17.0 offset_right = -73.0 @@ -115,6 +160,7 @@ label_settings = SubResource("LabelSettings_v8e04") horizontal_alignment = 1 [node name="IncomingDamage" type="Label" parent="."] +layout_mode = 0 offset_left = -124.0 offset_top = -17.0 offset_right = -99.0 diff --git a/scenes/player/player.gd b/scenes/player/player.gd index 80715b5..61da654 100644 --- a/scenes/player/player.gd +++ b/scenes/player/player.gd @@ -12,7 +12,17 @@ var bullet_delay var size = 100 var tax -var remaining_bullets = 100 +var reloading = false + +var remaining_bullets = 7 + +var health = 100 + +var money = 0 + +var score = 0 + +var reload_speed = 0.1 var bullet_timer = 0 @@ -44,17 +54,36 @@ func _physics_process(delta): sprite.global_position = Vector2i(global_position) collision.scale = Vector2(0.3,0.3)*(pow(size,0.2)) + + if bullet_timer < 0 and reloading: + remaining_bullets += 1 + bullet_timer = reload_speed + if remaining_bullets >= ammunition: + reloading = false + bullet_timer = 0.1*pow(bullet_delay,0.4) + inventory.update_stats() func reload(): - pass + reloading = true + func spawn_bullet(): - if bullet_timer > 0: return + if bullet_timer > 0 or reloading: return + var new_bullet = bullet_scene.instantiate() new_bullet.direction = global_position.direction_to(get_global_mouse_position()) new_bullet.position = position + new_bullet.damage = damage new_bullet.speed = sqrt(bullet_speed) get_tree().root.add_child(new_bullet) bullet_timer = 0.1*pow(bullet_delay,0.4) + remaining_bullets -= 1 + + inventory.update_stats() + + if remaining_bullets <= 0: + reload() + return + diff --git a/scenes/world/world.tscn b/scenes/world/world.tscn index d987f67..d04acba 100644 --- a/scenes/world/world.tscn +++ b/scenes/world/world.tscn @@ -1,7 +1,13 @@ -[gd_scene load_steps=3 format=3 uid="uid://dinanmpmnja1"] +[gd_scene load_steps=5 format=3 uid="uid://dinanmpmnja1"] [ext_resource type="PackedScene" uid="uid://o6e5ybx262ig" path="res://scenes/inventory/inventory.tscn" id="1_dphjl"] [ext_resource type="PackedScene" uid="uid://citwevx7xvypn" path="res://scenes/player/player.tscn" id="2_sl2e5"] +[ext_resource type="PackedScene" uid="uid://bnufqnypubedj" path="res://scenes/enemies/grunt/grunt.tscn" id="3_1fp7r"] + +[sub_resource type="NavigationPolygon" id="NavigationPolygon_6m72w"] +vertices = PackedVector2Array(230, 25.5312, 230, 244.82, 19.25, 241.148, 1.75781, 20.2891, 50.1172, 17.0078) +polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3, 4)]) +outlines = Array[PackedVector2Array]([PackedVector2Array(50, 7, 240, 16, 240, 255, 10, 251, -9, 11)]) [node name="World" type="Node2D"] @@ -13,3 +19,10 @@ player = NodePath("../../Player") [node name="Player" parent="." node_paths=PackedStringArray("inventory") instance=ExtResource("2_sl2e5")] position = Vector2(131, 131) inventory = NodePath("../UI/Inventory") + +[node name="Grunt" parent="." node_paths=PackedStringArray("player") instance=ExtResource("3_1fp7r")] +position = Vector2(42, 47) +player = NodePath("../Player") + +[node name="NavigationRegion2D" type="NavigationRegion2D" parent="."] +navigation_polygon = SubResource("NavigationPolygon_6m72w")