First commit
Add simple player movement with a finite state machine. Add enemy that can move to target point. Add ground through a tilemap and wall that player and enemy cannot cross.
This commit is contained in:
commit
7038d29d87
34 changed files with 883 additions and 0 deletions
47
scenes/enemy.tscn
Normal file
47
scenes/enemy.tscn
Normal file
|
@ -0,0 +1,47 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://bktg1ypaav3q3"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bbwsdd0jddmck" path="res://art/Pink_Monster_Walk_6.png" id="1_e5603"]
|
||||
[ext_resource type="Script" path="res://scripts/enemy.gd" id="1_l5lyv"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_etqki"]
|
||||
resource_name = "walk"
|
||||
length = 0.6
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 3, 4, 5]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_gnukq"]
|
||||
_data = {
|
||||
"walk": SubResource("Animation_etqki")
|
||||
}
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rlijp"]
|
||||
size = Vector2(17, 10)
|
||||
|
||||
[node name="Enemy" type="CharacterBody2D"]
|
||||
script = ExtResource("1_l5lyv")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(0, -16)
|
||||
texture = ExtResource("1_e5603")
|
||||
flip_h = true
|
||||
hframes = 6
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_gnukq")
|
||||
}
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(-0.5, -5)
|
||||
shape = SubResource("RectangleShape2D_rlijp")
|
21
scenes/main.tscn
Normal file
21
scenes/main.tscn
Normal file
|
@ -0,0 +1,21 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cdwgmtyq2y8sm"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://m8uyi35gr3qd" path="res://scenes/tile_map.tscn" id="2_c6bkg"]
|
||||
[ext_resource type="PackedScene" uid="uid://ba1t35yyot4jl" path="res://scenes/player.tscn" id="2_idv37"]
|
||||
[ext_resource type="PackedScene" uid="uid://bktg1ypaav3q3" path="res://scenes/enemy.tscn" id="3_2xcd4"]
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="TileMap" parent="." instance=ExtResource("2_c6bkg")]
|
||||
position = Vector2(324, 82)
|
||||
|
||||
[node name="Enemy" parent="TileMap" instance=ExtResource("3_2xcd4")]
|
||||
z_index = 1
|
||||
y_sort_enabled = true
|
||||
position = Vector2(0, 40)
|
||||
|
||||
[node name="Player" parent="TileMap" instance=ExtResource("2_idv37")]
|
||||
z_index = 1
|
||||
z_as_relative = false
|
||||
y_sort_enabled = true
|
217
scenes/player.tscn
Normal file
217
scenes/player.tscn
Normal file
|
@ -0,0 +1,217 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://ba1t35yyot4jl"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bqkvmyqo86dtj" path="res://art/Owlet_Monster_Walk_6.png" id="1_e23l4"]
|
||||
[ext_resource type="Script" path="res://scripts/player.gd" id="1_fmx2p"]
|
||||
[ext_resource type="Texture2D" uid="uid://cjxkidkeka7yp" path="res://art/Owlet_Monster_Run_6.png" id="2_qq5i7"]
|
||||
[ext_resource type="Texture2D" uid="uid://bi7ceeuwhg5mp" path="res://art/Owlet_Monster_Idle_4.png" id="4_orj3a"]
|
||||
[ext_resource type="Texture2D" uid="uid://dbrr63tv6i2ek" path="res://art/Owlet_Monster_Throw_4.png" id="5_2s1mg"]
|
||||
[ext_resource type="Script" path="res://scripts/state_machine.gd" id="6_hl63m"]
|
||||
[ext_resource type="Script" path="res://scripts/player_idle_state.gd" id="7_0nfrc"]
|
||||
[ext_resource type="Script" path="res://scripts/player_walk_state.gd" id="7_gcd3q"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_rh7n7"]
|
||||
length = 0.001
|
||||
|
||||
[sub_resource type="Animation" id="Animation_7igie"]
|
||||
resource_name = "idle"
|
||||
length = 0.4
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:texture")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("4_orj3a")]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprite2D:hframes")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [4]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Sprite2D:frame")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 3]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_xfiuh"]
|
||||
resource_name = "run"
|
||||
length = 0.6
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:texture")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("2_qq5i7")]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprite2D:hframes")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [6]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Sprite2D:frame")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 3, 4, 5]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_gswgu"]
|
||||
resource_name = "throw"
|
||||
length = 0.4
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:texture")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("5_2s1mg")]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprite2D:hframes")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [4]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Sprite2D:frame")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 3]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_pjkea"]
|
||||
resource_name = "walk"
|
||||
length = 0.6
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:texture")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("1_e23l4")]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprite2D:hframes")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [6]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Sprite2D:frame")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 3, 4, 5]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ldfyt"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_rh7n7"),
|
||||
"idle": SubResource("Animation_7igie"),
|
||||
"run": SubResource("Animation_xfiuh"),
|
||||
"throw": SubResource("Animation_gswgu"),
|
||||
"walk": SubResource("Animation_pjkea")
|
||||
}
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_hocsq"]
|
||||
size = Vector2(21, 7.5)
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
script = ExtResource("1_fmx2p")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(0, -16)
|
||||
texture = ExtResource("4_orj3a")
|
||||
hframes = 4
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_ldfyt")
|
||||
}
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
y_sort_enabled = true
|
||||
position = Vector2(-2.5, -3.75)
|
||||
shape = SubResource("RectangleShape2D_hocsq")
|
||||
|
||||
[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("state")]
|
||||
script = ExtResource("6_hl63m")
|
||||
state = NodePath("Idle")
|
||||
|
||||
[node name="Idle" type="Node" parent="StateMachine"]
|
||||
script = ExtResource("7_0nfrc")
|
||||
|
||||
[node name="Walk" type="Node" parent="StateMachine"]
|
||||
script = ExtResource("7_gcd3q")
|
43
scenes/tile_map.tscn
Normal file
43
scenes/tile_map.tscn
Normal file
|
@ -0,0 +1,43 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://m8uyi35gr3qd"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cm58s70te836m" path="res://art/tile.png" id="1_2goti"]
|
||||
[ext_resource type="Texture2D" uid="uid://lnt0clkwms52" path="res://art/wall.png" id="2_xllgf"]
|
||||
[ext_resource type="Script" path="res://scripts/tile_map.gd" id="3_067ya"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_wq1n0"]
|
||||
texture = ExtResource("1_2goti")
|
||||
texture_region_size = Vector2i(32, 32)
|
||||
0:0/0 = 0
|
||||
0:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||
0:0/0/physics_layer_0/angular_velocity = 0.0
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_u0t08"]
|
||||
texture = ExtResource("2_xllgf")
|
||||
texture_region_size = Vector2i(32, 32)
|
||||
0:0/0 = 0
|
||||
0:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||
0:0/0/physics_layer_0/angular_velocity = 0.0
|
||||
0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, 8.5, 0, 1.5, 15.5, 9, 0, 16)
|
||||
|
||||
[sub_resource type="TileSet" id="TileSet_kwgeq"]
|
||||
tile_shape = 1
|
||||
tile_layout = 5
|
||||
tile_size = Vector2i(32, 16)
|
||||
physics_layer_0/collision_layer = 1
|
||||
sources/0 = SubResource("TileSetAtlasSource_wq1n0")
|
||||
sources/1 = SubResource("TileSetAtlasSource_u0t08")
|
||||
|
||||
[node name="TileMap" type="TileMap"]
|
||||
y_sort_enabled = true
|
||||
tile_set = SubResource("TileSet_kwgeq")
|
||||
format = 2
|
||||
layer_0/name = "ground"
|
||||
layer_0/y_sort_enabled = true
|
||||
layer_1/name = "wall"
|
||||
layer_1/enabled = true
|
||||
layer_1/modulate = Color(1, 1, 1, 1)
|
||||
layer_1/y_sort_enabled = true
|
||||
layer_1/y_sort_origin = 0
|
||||
layer_1/z_index = 1
|
||||
layer_1/tile_data = PackedInt32Array()
|
||||
script = ExtResource("3_067ya")
|
Loading…
Add table
Add a link
Reference in a new issue