add state machine and have player use it

This commit is contained in:
2022-04-11 13:30:51 -04:00
parent 6d2d1178a7
commit ecd6fe45b2
28 changed files with 1303 additions and 416 deletions

View File

@@ -1,6 +1,6 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative/libalai.tres" type="GDNativeLibrary" id=1]
[ext_resource path="res://gdnative/alai.tres" type="GDNativeLibrary" id=1]
[resource]
resource_name = "Main"

View File

@@ -7,9 +7,3 @@
script = ExtResource( 1 )
[node name="Level1" parent="." instance=ExtResource( 2 )]
[node name="StateMachine" type="Node" parent="."]
[node name="Walk" type="Node" parent="StateMachine"]
[node name="Run" type="Node" parent="StateMachine"]

View File

@@ -1,8 +1,13 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative/libalai.tres" type="GDNativeLibrary" id=1]
[sub_resource type="GDNativeLibrary" id=1]
symbol_prefix = "godot_player"
entry/Windows.64 = "res://gdnative/windows.64/libalai.dll"
entry/X11.64 = "res://gdnative/linux.64/libalai.so"
dependency/Windows.64 = [ ]
dependency/X11.64 = [ ]
[resource]
resource_name = "Player"
class_name = "Player"
library = ExtResource( 1 )
library = SubResource( 1 )

View File

@@ -1,13 +1,18 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=9 format=2]
[ext_resource path="res://characters/player/sprites/green.tres" type="SpriteFrames" id=1]
[ext_resource path="res://characters/player/Player.gdns" type="Script" id=3]
[ext_resource path="res://characters/player/states/Idle.gdns" type="Script" id=2]
[ext_resource path="res://state_machine/StateMachine.gdns" type="Script" id=3]
[ext_resource path="res://characters/player/states/Move.gdns" type="Script" id=4]
[ext_resource path="res://characters/player/Player.gdns" type="Script" id=5]
[ext_resource path="res://characters/player/states/Jump.gdns" type="Script" id=6]
[ext_resource path="res://characters/player/states/Fall.gdns" type="Script" id=7]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 7, 11.5 )
extents = Vector2( 7, 12 )
[node name="Player" type="KinematicBody2D"]
script = ExtResource( 3 )
script = ExtResource( 5 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = ExtResource( 1 )
@@ -15,17 +20,21 @@ animation = "idle"
centered = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 12, 12.5 )
position = Vector2( 12, 12 )
shape = SubResource( 1 )
[node name="StateMachine" type="Node" parent="."]
script = ExtResource( 3 )
default_state = "Idle"
[node name="Idle" type="Node" parent="StateMachine"]
script = ExtResource( 2 )
[node name="Move" type="Node" parent="StateMachine"]
script = ExtResource( 4 )
[node name="Jump" type="Node" parent="StateMachine"]
[node name="DoubleJump" type="Node" parent="StateMachine"]
script = ExtResource( 6 )
[node name="Fall" type="Node" parent="StateMachine"]
script = ExtResource( 7 )

View File

@@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative/alai.tres" type="GDNativeLibrary" id=1]
[resource]
resource_name = "PlayerFall"
class_name = "PlayerFall"
library = ExtResource( 1 )

View File

@@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative/alai.tres" type="GDNativeLibrary" id=1]
[resource]
resource_name = "PlayerIdle"
class_name = "PlayerIdle"
library = ExtResource( 1 )

View File

@@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative/alai.tres" type="GDNativeLibrary" id=1]
[resource]
resource_name = "PlayerJump"
class_name = "PlayerJump"
library = ExtResource( 1 )

View File

@@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative/alai.tres" type="GDNativeLibrary" id=1]
[resource]
resource_name = "PlayerMove"
class_name = "PlayerMove"
library = ExtResource( 1 )

View File

@@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative/libalai.tres" type="GDNativeLibrary" id=1]
[resource]
resource_name = "State"
class_name = "State"
library = ExtResource( 1 )

View File

@@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative/alai.tres" type="GDNativeLibrary" id=1]
[resource]
resource_name = "StateMachine"
class_name = "StateMachine"
library = ExtResource( 1 )