GDevelop-extensions icon indicating copy to clipboard operation
GDevelop-extensions copied to clipboard

New extension: Hedgehog platformer

Open github-actions[bot] opened this issue 1 year ago • 97 comments

Description

A platform(er) extension akin to the built-in platformer but with independent physics made out with events that try to replicate momentum physics from Sonic The Hedgehog games in GDevelop.

How to use the extension

Give "Hedgehog platformer character" behavior to your player object and "Hedgehog platform" to your floor and obstacle objects.

Then in your player object, run an action called "Execute hedgehog movement" with the hedgehog platform object in the parameters, run in an event with no conditions.

Checklist

  • [X] I've followed all of the best practices.
  • [X] I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
  • [X] I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.

What tier of review do you aim for your extension?

Community (Unreviewed)

Example file

HedGD.zip

Extension file

HedgehogPlatformer.zip

github-actions[bot] avatar Jun 11 '24 17:06 github-actions[bot]

Thank you for submitting an extension.

The following suggestions imply a lot of repetitive work. Make sure to create a backup of your extension at every step and keep them all. This way you can compare your events to find mistake more easily.

There is a lot of formulas in the extension, using the new syntax for properties will make the events easier to read.

  • For instance, Object.Behavior::PropertySpeed() can be replaced by Speed.

The new release allows extensions to use local variables and declare scene variables.

  • This command line should be run on the extension to replace the variable actions and conditions.
    • I can run it for you when you're done with the properties changes.
    sed -i 's/"VarScene"\|"VarGlobal"/"NumberVariable"/g ; s/"VarSceneTxt"\|"VarGlobalTxt"/"StringVariable"/g ; s/"SceneVariableAsBoolean"\|"GlobalVariableAsBoolean"/"BooleanVariable"/g ; s/"ModVarScene"\|"ModVarGlobal"/"SetNumberVariable"/g ; s/"ModVarSceneTxt"\|"ModVarGlobalTxt"/"SetStringVariable"/g ; s/"SetSceneVariableAsBoolean"\|"SetGlobalVariableAsBoolean"/"SetBooleanVariable"/g ; s/"SceneVariableChildCount"\|"GlobalVariableChildCount"/"VariableChildCount"/g ; s/"VariableChildExists"\|"GlobalVariableChildExists"/"VariableChildExists2"/g ; s/"VariableRemoveChild"\|"GlobalVariableRemoveChild"/"RemoveVariableChild"/g ; s/"VariableClearChildren"\|"GlobalVariableClearChildren"/"ClearVariableChildren"/g ; s/"SceneVariablePush"\|"GlobalVariablePush"/"PushVariable"/g ; s/"SceneVariablePushNumber"\|"GlobalVariablePushNumber"/"PushNumber"/g ; s/"SceneVariablePushString"\|"GlobalVariablePushString"/"PushString"/g ; s/"SceneVariablePushBool"\|"GlobalVariablePushBool"/"PushBoolean"/g ; s/"SceneVariableRemoveAt"\|"GlobalVariableRemoveAt"/"RemoveVariableAt"/g ; s/"VarObjet"/"NumberObjectVariable"/g ; s/"VarObjetTxt"/"StringObjectVariable"/g ; s/"ObjectVariableAsBoolean"/"BooleanObjectVariable"/g ; s/"ModVarObjet"/"SetNumberObjectVariable"/g ; s/"ModVarObjetTxt"/"SetStringObjectVariable"/g ; s/"SetObjectVariableAsBoolean"/"SetBooleanObjectVariable"/g ; s/"ObjectVariablePushNumber"/"PushNumberToObjectVariable"/g ; s/"ObjectVariablePushString"/"PushStringToObjectVariable"/g ; s/"ObjectVariablePushBool"/"PushBooleanToObjectVariable"/g' project.json
    
  • You need to do some changes to make the extension work again.
    • Keep object variables as they are as extensions can declare them.
    • Replace scene variable access like Variable(HedExt.Speed) with Speed.
      • Make sure the name is not already used by a property or a parameter.
    • Declare local variables if the value is only used 1 frame.
    • Declare scene variables in the other cases.
  • Now, your extension should work again.
  • Rename the variables to use full words instead of abbreviations.
    • The events will update automatically.
    • This is important because people who read the extension will have a hard time understanding how it works so asking them to also guess and memorize the meaning of variables won't help them.
  • Try to make a quick prototype of a 2-players mode.
    • It probably won't work because you used scene variables.
    • Replace all remaining scene variables by hidden property.

D8H avatar Jun 15 '24 09:06 D8H

Thank you for submitting an extension.

The following suggestions imply a lot of repetitive work. Make sure to create a backup of your extension at every step and keep them all. This way you can compare your events to find mistake more easily.

There is a lot of formulas in the extension, using the new syntax for properties will make the events easier to read.

  • For instance, Object.Behavior::PropertySpeed() can be replaced by Speed.

The new release allows extensions to use local variables and declare scene variables.

  • This command line should be run on the extension to replace the variable actions and conditions.

    • I can run it for you when you're done with the properties changes.
    sed -i 's/"VarScene"\|"VarGlobal"/"NumberVariable"/g ; s/"VarSceneTxt"\|"VarGlobalTxt"/"StringVariable"/g ; s/"SceneVariableAsBoolean"\|"GlobalVariableAsBoolean"/"BooleanVariable"/g ; s/"ModVarScene"\|"ModVarGlobal"/"SetNumberVariable"/g ; s/"ModVarSceneTxt"\|"ModVarGlobalTxt"/"SetStringVariable"/g ; s/"SetSceneVariableAsBoolean"\|"SetGlobalVariableAsBoolean"/"SetBooleanVariable"/g ; s/"SceneVariableChildCount"\|"GlobalVariableChildCount"/"VariableChildCount"/g ; s/"VariableChildExists"\|"GlobalVariableChildExists"/"VariableChildExists2"/g ; s/"VariableRemoveChild"\|"GlobalVariableRemoveChild"/"RemoveVariableChild"/g ; s/"VariableClearChildren"\|"GlobalVariableClearChildren"/"ClearVariableChildren"/g ; s/"SceneVariablePush"\|"GlobalVariablePush"/"PushVariable"/g ; s/"SceneVariablePushNumber"\|"GlobalVariablePushNumber"/"PushNumber"/g ; s/"SceneVariablePushString"\|"GlobalVariablePushString"/"PushString"/g ; s/"SceneVariablePushBool"\|"GlobalVariablePushBool"/"PushBoolean"/g ; s/"SceneVariableRemoveAt"\|"GlobalVariableRemoveAt"/"RemoveVariableAt"/g ; s/"VarObjet"/"NumberObjectVariable"/g ; s/"VarObjetTxt"/"StringObjectVariable"/g ; s/"ObjectVariableAsBoolean"/"BooleanObjectVariable"/g ; s/"ModVarObjet"/"SetNumberObjectVariable"/g ; s/"ModVarObjetTxt"/"SetStringObjectVariable"/g ; s/"SetObjectVariableAsBoolean"/"SetBooleanObjectVariable"/g ; s/"ObjectVariablePushNumber"/"PushNumberToObjectVariable"/g ; s/"ObjectVariablePushString"/"PushStringToObjectVariable"/g ; s/"ObjectVariablePushBool"/"PushBooleanToObjectVariable"/g' project.json
    
  • You need to do some changes to make the extension work again.

    • Keep object variables as they are as extensions can declare them.

    • Replace scene variable access like Variable(HedExt.Speed) with Speed.

      • Make sure the name is not already used by a property or a parameter.
    • Declare local variables if the value is only used 1 frame.

    • Declare scene variables in the other cases.

  • Now, your extension should work again.

  • Rename the variables to use full words instead of abbreviations.

    • The events will update automatically.
    • This is important because people who read the extension will have a hard time understanding how it works so asking them to also guess and memorize the meaning of variables won't help them.
  • Try to make a quick prototype of a 2-players mode.

    • It probably won't work because you used scene variables.
    • Replace all remaining scene variables by hidden property.

HedgehogPlatformer.zip

Most changes are done and works, only thing is that the object won't move along slopes until the raycasts actions are completed for the new update

Kennoir avatar Jun 17 '24 11:06 Kennoir

Most changes are done and works, only thing is that the object won't move along slopes until the raycasts actions are completed for the new update

For the raycast variables as they are not extension variables, you need to keep Variable() to access their value. If you want to keep the formula clear, you can set their values to local variables and then use these local variables in expressions.

D8H avatar Jun 17 '24 12:06 D8H

Most changes are done and works, only thing is that the object won't move along slopes until the raycasts actions are completed for the new update

For the raycast variables as they are not extension variables, you need to keep Variable() to access their value. If you want to keep the formula clear, you can set their values to local variables and then use these local variables in expressions.

HedgehogPlatformer.zip

Applied that and now it works again with no flaws!

Kennoir avatar Jun 17 '24 14:06 Kennoir

Cool! Let's continue with the next step. The HedExt. is no longer needed because extension variables can't be used outside of the extension.

D8H avatar Jun 17 '24 14:06 D8H

Cool! Let's continue with the next step. The HedExt. is no longer needed because extension variables can't be used outside of the extension.

Done! HedgehogPlatformer.zip

Kennoir avatar Jun 17 '24 14:06 Kennoir

You're fast 😅

Next step:

  • Expend every events (it's not practical to read otherwise).
  • Object variables Object.Variable(colCheckX) should be replaced with hidden properties (or local variable if it's only used in 1 function during 1 frame as Object is always 1 instance in behaviors)

D8H avatar Jun 17 '24 15:06 D8H

I'm just here to say that this is impressive and looks awesome. Great job!

4ian avatar Jun 17 '24 15:06 4ian

You're fast 😅

Next step:

  • Expend every events (it's not practical to read otherwise).
  • Object variables Object.Variable(colCheckX) should be replaced with hidden properties (or local variable if it's only used in 1 function during 1 frame as Object is always 1 instance in behaviors)

Done!

HedgehogPlatformer.zip

  • All events expanded to level 9.
  • colCheck variable and similar have been changed to local variables.
  • origin variable and similar have been changed to local variables.

Kennoir avatar Jun 17 '24 16:06 Kennoir

The extension needs a new icon if i recall

Kennoir avatar Jun 17 '24 19:06 Kennoir

You're fast 😅

Next step:

  • Expend every events (it's not practical to read otherwise).
  • Object variables Object.Variable(colCheckX) should be replaced with hidden properties (or local variable if it's only used in 1 function during 1 frame as Object is always 1 instance in behaviors)

HedgehogPlatformer.zip

  • Now most events have comments to understand whatever i did easier.
  • Ceil un attach section of physic execution now uses a local variable.
  • Replaced some variable actions for local variables.
  • Now using a 'saw blade' icon from GDevelop assets to resemble sonic roll.
  • Description reworked and now it has various usages of the extension.

Previous changes were:

  • All events have been expanded to level 9.
  • colCheck variable and similar have been changed to local variables.
  • origin variable and similar have been changed to local variables.

Kennoir avatar Jun 19 '24 18:06 Kennoir

!update HedgehogPlatformer.zip

Kennoir avatar Jun 20 '24 04:06 Kennoir

✅ Successfully updated the extension.

github-actions[bot] avatar Jun 20 '24 04:06 github-actions[bot]

!update HedgehogPlatformer.zip

This build has:

  • A bugfix for ceil attachment (it was caused by the new variables system).
  • More comments on some other events.
  • Bugfix for "Draw raycasts" action.
  • Description extended a little more.

Kennoir avatar Jun 20 '24 04:06 Kennoir

❗ No updates found. Please check your file.

github-actions[bot] avatar Jun 20 '24 04:06 github-actions[bot]

Now i am just going to be waiting for any request for the extension before making game examples of it.

Kennoir avatar Jun 20 '24 04:06 Kennoir

  • Object variables Object.Variable(colCheckX) should be replaced with hidden properties (or local variable if it's only used in 1 function during 1 frame as Object is always 1 instance in behaviors)

I see that you haven't declared any hidden property. Did you face any issue?

D8H avatar Jun 20 '24 10:06 D8H

  • Object variables Object.Variable(colCheckX) should be replaced with hidden properties (or local variable if it's only used in 1 function during 1 frame as Object is always 1 instance in behaviors)

I see that you haven't declared any hidden property. Did you face any issue?

you said i could replace them with local variables so i did

Kennoir avatar Jun 20 '24 13:06 Kennoir

Sorry, I meant "Object variables like Object.Variable(colCheckX) should be replaced with hidden properties (or local variable if it's only used in 1 function during 1 frame as Object is always 1 instance in behaviors)" Every object variable must be replaced.

D8H avatar Jun 20 '24 14:06 D8H

Sorry, I meant "Object variables like Object.Variable(colCheckX) should be replaced with hidden properties (or local variable if it's only used in 1 function during 1 frame as Object is always 1 instance in behaviors)" Every object variable must be replaced.

Changes are done!

Kennoir avatar Jun 21 '24 15:06 Kennoir

!update HedgehogPlatformer.zip

Kennoir avatar Jun 21 '24 15:06 Kennoir

✅ Successfully updated the extension.

github-actions[bot] avatar Jun 21 '24 15:06 github-actions[bot]

  • Most object variables were replaced with properties.
  • Local variables were replaced with properties for support on older versions of GDevelop.
  • Some issues solved

Kennoir avatar Jun 21 '24 15:06 Kennoir

!update HedgehogPlatformer.zip

  • Completely removed local variables.
  • Removed deactivated events.
  • Removed empty functions.

Kennoir avatar Jun 21 '24 16:06 Kennoir

✅ Successfully updated the extension.

github-actions[bot] avatar Jun 21 '24 16:06 github-actions[bot]

Very nice! The formulas look less scary to me.

Now, that variables and properties are declared, they can be renamed quickly: the events will automatically update.

I have some suggestions, for instance:

  • HSpeed can be SpeedX. It's easier to read formulas with everything ending with X or Y and it's less error prone.
  • LastXpos can just be LastX as it's implicitly a position.
  • OnFloor can be IsOnFloor. It's a good practice to start boolean names by either Is or Has. It forces to choose a name that is a true or false statement.
  • OriginalHval can be OriginalHeight. Abbreviations must be avoided because they may not be obvious for everyone.

It's very nice of you to think about compatibility with older GDevelop releases, but it's a matter of time before every extensions (4 of them are ready to be merged) and templates (all of them are ready to be merged) use the new system:

  • Every extensions that uses project scene variables will be migrated to extension scene variables because it allows lighter formulas.
  • Local variables allow readers to understand that the value won't be used over time and in other events. I can be of great help to understand advanced logic like in your extension.

About variables used for raycast:

  • Contrary to extension scene variables, project scenes variables used in an extension must be prefixed by MyExtension. to reduce the risk of modifying a variable with the same name used in the project or other extensions. To avoid ending up with Variable(MyExtension.MyVariable) in formulas, you can set their values in local variables and use these local variables in expressions.

D8H avatar Jun 21 '24 16:06 D8H

Very nice! The formulas look less scary to me.

Now, that variables and properties are declared, they can be renamed quickly: the events will automatically update.

I have some suggestions, for instance:

  • HSpeed can be SpeedX. It's easier to read formulas with everything ending with X or Y and it's less error prone.
  • LastXpos can just be LastX as it's implicitly a position.
  • OnFloor can be IsOnFloor. It's a good practice to start boolean names by either Is or Has. It forces to choose a name that is a true or false statement.
  • OriginalHval can be OriginalHeight. Abbreviations must be avoided because they may not be obvious for everyone.

It's very nice of you to think about compatibility with older GDevelop releases, but it's a matter of time before every extensions (4 of them are ready to be merged) and templates (all of them are ready to be merged) use the new system:

  • Every extensions that uses project scene variables will be migrated to extension scene variables because it allows lighter formulas.
  • Local variables allow readers to understand that the value won't be used over time and in other events. I can be of great help to understand advanced logic like in your extension.

About variables used for raycast:

  • Contrary to extension scene variables, project scenes variables used in an extension must be prefixed by MyExtension. to reduce the risk of modifying a variable with the same name used in the project or other extensions. To avoid ending up with Variable(MyExtension.MyVariable) in formulas, you can set their values in local variables and use these local variables in expressions.

got everything but after compatibility, so you're saying that i should keep local variables along with the new variable system?

Kennoir avatar Jun 21 '24 17:06 Kennoir

got everything but after compatibility, so you're saying that i should keep local variables along with the new variable system?

There is no reason not to use local variables because your extension already use extension scene variables that are not compatible with older releases and in a few months most extensions won't work with older releases.

D8H avatar Jun 21 '24 17:06 D8H

There is no reason not to use local variables because your extension already use extension scene variables that are not compatible with older releases and in a few months most extensions won't work with older releases.

Understood, so here's the change:

!update HedgehogPlatformer.zip

  • Most properties renamed.
  • Added HedgehogExtension. to the name of each scene variable used.

Kennoir avatar Jun 21 '24 17:06 Kennoir

✅ Successfully updated the extension.

github-actions[bot] avatar Jun 21 '24 17:06 github-actions[bot]