Skip to content

Commit

Permalink
Added some cool stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxyOfJungle committed May 18, 2024
1 parent 4122c08 commit 4068815
Show file tree
Hide file tree
Showing 14 changed files with 245 additions and 80 deletions.
6 changes: 3 additions & 3 deletions RollbackStateMachines/RollbackStateMachines.resource_order
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"FolderOrderSettings":[
{"name":"Example","order":5,"path":"folders/Example.yy",},
{"name":"RollbackStateMachines","order":1,"path":"folders/KazanGames/RollbackStateMachines.yy",},
{"name":"Core","order":2,"path":"folders/KazanGames/RollbackStateMachines/Core.yy",},
{"name":"Objects","order":3,"path":"folders/Objects.yy",},
{"name":"Rooms","order":4,"path":"folders/Rooms.yy",},
{"name":"Sprites","order":1,"path":"folders/Sprites.yy",},
{"name":"Objects","order":1,"path":"folders/Example/Objects.yy",},
{"name":"Rooms","order":2,"path":"folders/Example/Rooms.yy",},
],
"ResourceOrderSettings":[
{"name":"objPlayer","order":2,"path":"objects/objPlayer/objPlayer.yy",},
Expand Down
7 changes: 4 additions & 3 deletions RollbackStateMachines/RollbackStateMachines.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 33 additions & 2 deletions RollbackStateMachines/objects/objPlayer/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dashAngle = 0;
enableMovement = true;


// ===============================
// ===============================================
// Create State Machine
fsmChar = new StateMachine("Idle");
characterState = 0; // trackable state variable (for rollback netcode sync)
Expand Down Expand Up @@ -82,12 +82,16 @@ fsmChar.AddFreeState(function() {
// Idle
fsmChar.AddState("Idle", {
onStep : function() {

//show_debug_message("calling Idle onStep");
},
onEnter : function() {
sprite_index = sprPlayerIdle;
image_speed = 0.25;

},
onExit : function() {

}
});

// Walk
Expand Down Expand Up @@ -137,6 +141,7 @@ fsmChar.AddState("Dash", {
}
});


// Create Transitions
fsmChar.AddTransition("Idle", "Walk", function() {
return (inputH != 0);
Expand All @@ -161,3 +166,29 @@ fsmChar.AddTransition("Dash", "Idle", function() {
});


// --------------------------
// add trigger states [optional / test]
/*fsmChar.AddState("IdleTrigger1", {
onStep : function() {
//show_debug_message("calling IdleTrigger1 onStep");
},
onEnter : function() {
show_debug_message("Idle Tg Enter");
},
onExit : function() {
show_debug_message("Idle Tg Exit");
},
});
fsmChar.AddState("IdleTrigger2", {
onEnter : function() {
show_debug_message("Idle Tg2 Enter");
},
});
fsmChar.AddTrigger("Idle", "IdleTrigger1");
//fsmChar.AddTrigger("Idle", "IdleTrigger2");
//fsmChar.OverrideState("IdleTrigger1", "Walk");
//fsmChar.OverrideStateFunction("Walk", fsmChar.GetState("IdleTrigger1").onStep);
*/

13 changes: 5 additions & 8 deletions RollbackStateMachines/objects/objPlayer/Step_0.gml
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@

// run state machine behaviour
fsmChar.Update(id, "characterState");

// ===================================


// ----------------------------
/*
if keyboard_check_pressed(ord("N")) {
characterState = 0;
}
if keyboard_check_pressed(ord("M")) {
characterState = 1;
}
if keyboard_check_pressed(ord("J")) {
fsmChar.SetState(0);
fsmChar.SetState(0); // does not work here if you are using transitions!!!
}
if keyboard_check_pressed(ord("K")) {
fsmChar.SetState(1);
}
*/
if keyboard_check_pressed(ord("K")) {

if keyboard_check_pressed(ord("P")) {
fsmChar.SetStateFromHistory(1);
}
2 changes: 1 addition & 1 deletion RollbackStateMachines/objects/objPlayer/objPlayer.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion RollbackStateMachines/objects/objSolid/objSolid.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion RollbackStateMachines/rooms/rmGame/rmGame.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4068815

Please sign in to comment.