First basic map with enemies

This commit is contained in:
2025-03-09 20:04:04 +01:00
parent a6a5b78d1c
commit 95fd58d6dc
10 changed files with 661 additions and 7 deletions

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dupna45m2cm80"
path="res://.godot/imported/1.png-68ab0678357bb454b7fc077a1f15a2cb.ctex"
path="res://.godot/imported/1.png-bcabb5244534d1a8db1963567483aafa.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Towers/1.png"
dest_files=["res://.godot/imported/1.png-68ab0678357bb454b7fc077a1f15a2cb.ctex"]
source_file="res://Assets/Tiles/Fields/1.png"
dest_files=["res://.godot/imported/1.png-bcabb5244534d1a8db1963567483aafa.ctex"]
[params]

15
Game/Maps/map_1.gd Normal file
View File

@ -0,0 +1,15 @@
extends Node2D
@onready var path_2d: Path2D = $Path2D
const FORKMAN = preload("res://Game/Mobs/forkman.tscn")
func _on_timer_timeout() -> void:
spawnMonster()
func spawnMonster():
var path = PathFollow2D.new()
var monster = FORKMAN.instantiate()
path.add_child(monster)
path_2d.add_child(path)

1
Game/Maps/map_1.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://xo6vbicdva8d

484
Game/Maps/map_1.tscn Normal file

File diff suppressed because one or more lines are too long

35
Game/Mobs/enemy.gd Normal file
View File

@ -0,0 +1,35 @@
extends Node2D
@export var speed = 100
var last_position: Vector2 = Vector2.ZERO # To store the previous position
func _ready() -> void:
last_position = get_parent().position # Set the initial position when the mob starts
func _process(delta: float) -> void:
var path_follow = get_parent()
# Update the progress along the path
path_follow.set_progress(path_follow.get_progress() + speed * delta)
# Prevent rotation (lock rotation to 0)
path_follow.rotation = 0
# Get the current position on the path (mob's position)
var current_position = path_follow.position
# Flip the character if moving left (when moving to the left, the x position decreases)
if current_position.x < last_position.x:
# Flip the character horizontally by inverting its scale on the x-axis
path_follow.scale.x = -abs(path_follow.scale.x)
else:
# Ensure the character is not flipped when moving right
path_follow.scale.x = abs(path_follow.scale.x)
# Update the last_position for the next frame
last_position = current_position
# If the mob reaches the end of the path, queue it for deletion
if path_follow.get_progress_ratio() >= 0.999:
get_parent().queue_free()

1
Game/Mobs/enemy.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://sh6qqbl8fdrr

111
Game/Mobs/forkman.tscn Normal file
View File

@ -0,0 +1,111 @@
[gd_scene load_steps=24 format=3 uid="uid://dnoajr7rj2um7"]
[ext_resource type="Script" uid="uid://sh6qqbl8fdrr" path="res://Game/Mobs/enemy.gd" id="1_pq2md"]
[ext_resource type="Texture2D" uid="uid://dl2w65j5jq0xc" path="res://Assets/Monsters/1/1_enemies_1_walk_000.png" id="1_ra45u"]
[ext_resource type="Texture2D" uid="uid://sxsuv85rgxa1" path="res://Assets/Monsters/1/1_enemies_1_walk_001.png" id="2_pq2md"]
[ext_resource type="Texture2D" uid="uid://bm073de32a3pu" path="res://Assets/Monsters/1/1_enemies_1_walk_002.png" id="3_gxpsl"]
[ext_resource type="Texture2D" uid="uid://bmloufrbidsqo" path="res://Assets/Monsters/1/1_enemies_1_walk_003.png" id="4_vb2u0"]
[ext_resource type="Texture2D" uid="uid://ck8av0egjy7r2" path="res://Assets/Monsters/1/1_enemies_1_walk_004.png" id="5_1x0wp"]
[ext_resource type="Texture2D" uid="uid://ok8wq17yge66" path="res://Assets/Monsters/1/1_enemies_1_walk_005.png" id="6_tgrc0"]
[ext_resource type="Texture2D" uid="uid://cl56mwcyom2vs" path="res://Assets/Monsters/1/1_enemies_1_walk_006.png" id="7_nt07g"]
[ext_resource type="Texture2D" uid="uid://du57hw0eh6wg4" path="res://Assets/Monsters/1/1_enemies_1_walk_007.png" id="8_yjyl6"]
[ext_resource type="Texture2D" uid="uid://8417txfhh37c" path="res://Assets/Monsters/1/1_enemies_1_walk_008.png" id="9_mpc1o"]
[ext_resource type="Texture2D" uid="uid://debvus3344n5c" path="res://Assets/Monsters/1/1_enemies_1_walk_009.png" id="10_q6pl0"]
[ext_resource type="Texture2D" uid="uid://docerq3efivq5" path="res://Assets/Monsters/1/1_enemies_1_walk_010.png" id="11_r662y"]
[ext_resource type="Texture2D" uid="uid://bhnf6gdnld6ck" path="res://Assets/Monsters/1/1_enemies_1_walk_011.png" id="12_ika66"]
[ext_resource type="Texture2D" uid="uid://b2bgvs1dnmp3v" path="res://Assets/Monsters/1/1_enemies_1_walk_012.png" id="13_5lf1w"]
[ext_resource type="Texture2D" uid="uid://bltn18wj6sqbv" path="res://Assets/Monsters/1/1_enemies_1_walk_013.png" id="14_u3sot"]
[ext_resource type="Texture2D" uid="uid://re1e2vxnkvny" path="res://Assets/Monsters/1/1_enemies_1_walk_014.png" id="15_0wrvp"]
[ext_resource type="Texture2D" uid="uid://0xbdj00hfiva" path="res://Assets/Monsters/1/1_enemies_1_walk_015.png" id="16_ipe57"]
[ext_resource type="Texture2D" uid="uid://cb7ka3ckam73t" path="res://Assets/Monsters/1/1_enemies_1_walk_016.png" id="17_7dt0v"]
[ext_resource type="Texture2D" uid="uid://daotm1cxaqd85" path="res://Assets/Monsters/1/1_enemies_1_walk_017.png" id="18_fxffo"]
[ext_resource type="Texture2D" uid="uid://cqvx47l53s1vc" path="res://Assets/Monsters/1/1_enemies_1_walk_018.png" id="19_lbdce"]
[ext_resource type="Texture2D" uid="uid://bi4gdl6ovax2j" path="res://Assets/Monsters/1/1_enemies_1_walk_019.png" id="20_garh6"]
[sub_resource type="SpriteFrames" id="SpriteFrames_gxpsl"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("1_ra45u")
}, {
"duration": 1.0,
"texture": ExtResource("2_pq2md")
}, {
"duration": 1.0,
"texture": ExtResource("3_gxpsl")
}, {
"duration": 1.0,
"texture": ExtResource("4_vb2u0")
}, {
"duration": 1.0,
"texture": ExtResource("5_1x0wp")
}, {
"duration": 1.0,
"texture": ExtResource("6_tgrc0")
}, {
"duration": 1.0,
"texture": ExtResource("7_nt07g")
}, {
"duration": 1.0,
"texture": ExtResource("8_yjyl6")
}, {
"duration": 1.0,
"texture": ExtResource("9_mpc1o")
}, {
"duration": 1.0,
"texture": ExtResource("10_q6pl0")
}, {
"duration": 1.0,
"texture": ExtResource("11_r662y")
}, {
"duration": 1.0,
"texture": ExtResource("12_ika66")
}, {
"duration": 1.0,
"texture": ExtResource("13_5lf1w")
}, {
"duration": 1.0,
"texture": ExtResource("14_u3sot")
}, {
"duration": 1.0,
"texture": ExtResource("15_0wrvp")
}, {
"duration": 1.0,
"texture": ExtResource("16_ipe57")
}, {
"duration": 1.0,
"texture": ExtResource("17_7dt0v")
}, {
"duration": 1.0,
"texture": ExtResource("18_fxffo")
}, {
"duration": 1.0,
"texture": ExtResource("19_lbdce")
}, {
"duration": 1.0,
"texture": ExtResource("20_garh6")
}],
"loop": true,
"name": &"walk",
"speed": 20.0
}]
[sub_resource type="CircleShape2D" id="CircleShape2D_ra45u"]
radius = 32.0
[node name="Forkman" type="Node2D"]
script = ExtResource("1_pq2md")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(1.625, 0)
scale = Vector2(0.206633, 0.191818)
sprite_frames = SubResource("SpriteFrames_gxpsl")
animation = &"walk"
autoplay = "walk"
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
position = Vector2(-5, 0)
scale = Vector2(0.5, 0.5)
shape = SubResource("CircleShape2D_ra45u")

10
Game/main.tscn Normal file
View File

@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://drjcsrjs6uobn"]
[ext_resource type="PackedScene" uid="uid://bgme05i7taycc" path="res://Game/Maps/map_1.tscn" id="1_xb63x"]
[node name="Main" type="Node2D"]
[node name="Map1" parent="." instance=ExtResource("1_xb63x")]
[node name="Camera2D" type="Camera2D" parent="."]
position = Vector2(576, 320)

View File

@ -11,9 +11,6 @@ config_version=5
[application]
config/name="Defensaria"
run/main_scene="uid://drjcsrjs6uobn"
config/features=PackedStringArray("4.4", "Mobile")
config/icon="res://icon.svg"
[rendering]
renderer/rendering_method="mobile"