diff --git a/godot/Main.tscn b/godot/Main.tscn index d264a5c..9d1190c 100644 --- a/godot/Main.tscn +++ b/godot/Main.tscn @@ -7,3 +7,9 @@ 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"] diff --git a/godot/characters/player/Player.tscn b/godot/characters/player/Player.tscn index dde73e1..b8ef56b 100644 --- a/godot/characters/player/Player.tscn +++ b/godot/characters/player/Player.tscn @@ -1,13 +1,14 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 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=2] +[ext_resource path="res://characters/player/states/Idle.gdns" type="Script" id=2] +[ext_resource path="res://characters/player/Player.gdns" type="Script" id=3] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 7, 11.5 ) [node name="Player" type="KinematicBody2D"] -script = ExtResource( 2 ) +script = ExtResource( 3 ) [node name="AnimatedSprite" type="AnimatedSprite" parent="."] frames = ExtResource( 1 ) @@ -18,4 +19,15 @@ centered = false position = Vector2( 12, 12.5 ) shape = SubResource( 1 ) -[connection signal="player_moved" from="." to="." method="_on_Player_player_moved"] +[node name="StateMachine" type="Node" parent="."] + +[node name="Idle" type="Node" parent="StateMachine"] +script = ExtResource( 2 ) + +[node name="Move" type="Node" parent="StateMachine"] + +[node name="Jump" type="Node" parent="StateMachine"] + +[node name="DoubleJump" type="Node" parent="StateMachine"] + +[node name="Fall" type="Node" parent="StateMachine"] diff --git a/src/godot.cpp b/src/godot.cpp index 4389706..d8f50b7 100644 --- a/src/godot.cpp +++ b/src/godot.cpp @@ -1,7 +1,12 @@ #include +#include "StateMachine.h" +#include "State.h" +#include "Walk.h" +#include "Run.h" #include "Main.h" #include "Player.h" +#include "PlayerIdle.h" using namespace godot; @@ -21,6 +26,11 @@ extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_opt extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) { Godot::nativescript_init(handle); + register_class(); + register_class(); + register_class(); + register_class(); register_class
(); register_class(); + register_class(); }