Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Community] [Hedgehog platformer] A platformer engine for Sonic-like games #1318

Merged
merged 27 commits into from
Oct 27, 2024

Conversation

github-actions[bot]
Copy link
Contributor

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

  • I've followed all of the best practices.
  • I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
  • 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 github-actions bot requested a review from a team as a code owner June 11, 2024 17:04
@github-actions github-actions bot added the ✨ New extension A new extension label Jun 11, 2024
@github-actions github-actions bot mentioned this pull request Jun 11, 2024
3 tasks
@D8H
Copy link
Contributor

D8H commented Jun 15, 2024

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.

@Kennoir
Copy link
Contributor

Kennoir commented Jun 17, 2024

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

@D8H
Copy link
Contributor

D8H commented Jun 17, 2024

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.

@Kennoir
Copy link
Contributor

Kennoir commented Jun 17, 2024

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!

@D8H
Copy link
Contributor

D8H commented Jun 17, 2024

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.

@Kennoir
Copy link
Contributor

Kennoir commented Jun 17, 2024

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

@D8H
Copy link
Contributor

D8H commented Jun 17, 2024

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)

@4ian
Copy link
Collaborator

4ian commented Jun 17, 2024

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

@Kennoir
Copy link
Contributor

Kennoir commented Jun 17, 2024

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
Copy link
Contributor

Kennoir commented Jun 17, 2024

The extension needs a new icon if i recall

@Kennoir
Copy link
Contributor

Kennoir commented Jun 19, 2024

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
Copy link
Contributor

Kennoir commented Jun 20, 2024

!update
HedgehogPlatformer.zip

Copy link
Contributor Author

✅ Successfully updated the extension.

@Kennoir
Copy link
Contributor

Kennoir commented Jun 20, 2024

!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.

Copy link
Contributor Author

❗ No updates found. Please check your file.

@Kennoir
Copy link
Contributor

Kennoir commented Jun 20, 2024

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

@D8H
Copy link
Contributor

D8H commented Jun 20, 2024

  • 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?

@Kennoir
Copy link
Contributor

Kennoir commented Jun 20, 2024

  • 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

@D8H
Copy link
Contributor

D8H commented Jun 20, 2024

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.

@Kennoir
Copy link
Contributor

Kennoir commented Jun 21, 2024

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
Copy link
Contributor

Kennoir commented Jun 21, 2024

!update
HedgehogPlatformer.zip

Copy link
Contributor Author

✅ Successfully updated the extension.

@Kennoir
Copy link
Contributor

Kennoir commented Jun 21, 2024

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

@Kennoir
Copy link
Contributor

Kennoir commented Jun 21, 2024

!update
HedgehogPlatformer.zip

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

Copy link
Contributor Author

✅ Successfully updated the extension.

@D8H
Copy link
Contributor

D8H commented Jun 21, 2024

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.

@GDevelopApp GDevelopApp deleted a comment from github-actions bot Oct 27, 2024
@D8H D8H changed the title New extension: Hedgehog platformer [Community] [Hedgehog platformer] A platformer engine for Sonic-like games Oct 27, 2024
@D8H D8H added the 👨‍👩‍👧‍👦 Community extension An extension submission to be merged ASAP with a lightweight review. label Oct 27, 2024
Copy link
Contributor

@D8H D8H left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kennoir Thanks for this huge extension!

@D8H D8H merged commit 6d9dd36 into main Oct 27, 2024
4 checks passed
@D8H D8H deleted the extension/Kennoir/1317 branch October 27, 2024 19:06
@Kennoir
Copy link
Contributor

Kennoir commented Oct 28, 2024

@Kennoir I guess the extension is ready for a release. Please give it a review if you want.

YEAH THIS IS HAPPENING!

  • Sonic T. Hedgehog.

Davy, thank you soo much on helping me with this extension! i can't express how much i appreciate it, i'll try it out on my free day and make an example out of it!

@UnknownUney
Copy link

I can too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👨‍👩‍👧‍👦 Community extension An extension submission to be merged ASAP with a lightweight review. ✨ New extension A new extension
Projects
Status: Added to GDevelop
Development

Successfully merging this pull request may close these issues.

4 participants