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

Godot 4 port and overhaul #9

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

c08oprkiua
Copy link

@c08oprkiua c08oprkiua commented May 5, 2024

Hi! So, I stumbled across flow engine when I was beginning work on a game, and I noticed it was not ported to Godot 4, which my team wanted to use. So, I ported Flow Engine to Godot 4. But then, I also started finding bugs/code oddities, and started fixing them all, so this ended up being not only a port but also a major bugfix/overhaul endeavor.

It's difficult to list what all I have done, but I will attempt to list most of the things I did:

Features (gameplay side):

  • Un-janked the spindash. It now charges and such exactly how you would expect, along with new exported variables to control how it works from outside the code.
  • Removed a bunch of speed caps, allowing for the possibility of more momentum based gameplay benefits. This may make it behave in a not-very-Rush like way, but personally, I found the results to be very fun.
  • Changed it so that Sonic can boost straight up and down in midair, and will just fall back down like in the Rush games (unless holding a direction ofc)
    • Though there's currently a glitch where holding forward long enough in midair will cause Sonic to pass the trigger threshold to instead begin a forward arch, causing a pseudo double jump type thing to happen.
  • Edited the levels a bit, both because I changed the tilesets and also just to make the level design a little more fair /shrug
  • Fixed an oversight that allowed Sonic to exceed his top speed through horizontal acceleration. (Though, maybe this doesn't matter, since I removed the caps that made it so noticeable in the first place.)
  • Added a free-falling animation.
  • Added a toggle that makes Sonic launch back at a pre-set speed instead of the opposite of whatever speed he was traveling at when hurt.
  • Fixed several animations, making animation playback overall a lot more consistent

Optimizations

  • Optimized several bits of math in the code to use less operations, use Godot native functions to achieve the intended effects. Idk if this has provided any tangible improvement in performance, but it also makes the code cleaner to read, so...
  • Changed several functions that were running _process, to _physics_process, which will make them run consistently at different framerates and also not overload the _process callback in the engine, as it is already under a lot of load.
  • Changed the GUI to be signal based, which likely gave a performance boost (but I wasn't actively looking at the before and after) by nature of the aforementioned not overloading _process
  • Implemented proper use of Godot's collision layer/masking system, allowing for the removal of several previous "area.name == 'player'" type checks, since the nodes are set to only look for nodes on the player collision layer, and etc.

Code/codebase changes:

  • Idr what all I added, but I exposed a bunch more of Sonic's variables to the editor (including things I added), and also grouped variables together in a couple cases to make UX a bit nicer with less scrolling through the inspector.

  • I started an experimental version of Sonic with the goals of using CharacterBody2D physics, though I have not got that working in anything besides a very broken, basically unusable (for a Sonic game, at least) manner. But those files are in the codebase, so I figured I'd mention it.

  • Begun (and got decently far) on redoing all the sprite/tile based things graphically, to make better uses of atlases, TileSets, etc. End goal is to have just a small few atlas files in the code (eg. Sonic's source atlas) and then have AtlasTextures and such set up to use them properly, saving system resources and storage space.

  • Made the whole codebase staticly typed. This makes it more readable, and in the case of Godot 4, actually brings better performance.

  • Defined the engine objects, entities, etc. as "Flow*", so that they can be interacted with as types and have in engine documentation...

  • Changed all the applicable code comments into engine-documentation detected comments, so that they natively show up in the engine's docs.

  • Switched to using Tweens for some scaling/value changing based animations.

  • Began implementing a singleton for tracking player stats, so that 1. Split-screen multiplayer would be achievable natively, and 2. To remove SceneTree location based dependencies.

Also, I unfortunately did not notice Sslaxx's fork until I was way into developing this, so this does not include any of the changes from that fork, though I do think they are good changes and could/should be added to this (my) version in the future.

Collision is still semi-broken
* Fixed boosting up off a wall sending Sonic directly into the sky for as long as he could hold boost, by applying a little forward velocity so he enters a boost arch
* Fixed one of the rings launching Sonic too weakly
* Begun work on an exprimental "player v3", which is intended to integrate with Godot's physics more natively
* Removed the Sonic 1 esque speed cap
* Removed the oversight in air acceleration allowing Sonic to gain speed over max speed
* Technically implemented analog acceleration for Sonic's x movement
* Fixed rings not animating correctly
* Fixed boost not animating at all
* Changed the GUI elements to be event based, likely improving performance (before, they were using up precious idle frames)
*
* Added static damage launching, which makes it so Sonic is launched at the same velocity no matter how fast he was going.
* Implemented the boost cooldown, so that it can't be spammed (if the programmer so chooses)
* Fixed a couple of animations, so spindashing and etc. should play now
* Properly cap spindash launching so the negavtive velocity is also capped
* Spindashing now counts as attacking, so Sonic can't get damaged while spindashing
* Also changed the grind animation to the one from Advance 2 (it's better)
* Added a neutral air animation
* Fixed boosting causing an unintentional speed cap
* Fixed a glitch where Sonic would mistakenly freeze in midair when falling next to a wall
* split off grinding into its own function, like groundProcess and airProcess
* Fixed the crouch animation looping when crouch was held
* Fixed a couple of things that were harmless but causing editor warnings
* Removed some checks that are now unnecessary because of the utilization of collision masks
* Begun implementing a singleton for managing player stats, with the intent of removing scene tree positioning dependencies
* Begun modifying BounceRing to also optionally act like a regular ring to hopefully merge the two in the future
* Added a new chunk of level to ChaosFestival
* Fixed Sonic clipping through the rails when on them (oops, disabled a line of code)
I attempted to scrape information I could find online and in the codebase to add here, though I still think it's fairly bare bones.
Implemented an input remapping API for Sonic. Eventually, this will allow for runtime input remapping.

Also added tricking in midair (not jumping), and with that, refactored how tricking is registered to be more animation based than sprite frame based
* Completely reorganized the codebase to make Flow Engine more template friendly.
* Fixed an oversight where tricking in midair was possible while stomping
* Attempting to rewrite the boost bar while not entirely changing how it works (eg. switching it to be a TextureProgressBar). Currently it does not change colors like it should, but otherwise displays properly.
* Fixed how rolling affects boosting, so it now behaves like it does in the DS games.
I figure, if these are for some reason ever needed again, they can be redownloaded from The Spriter's Resource. But for now, they're not used and add to the codebase size, so I removed them.
* Completed implementation of the stat singleton
* Implemented stomping being related to tricking in mapping (see the comments in Player_v2.gd)
* Added more specific crediting to the various sprite rippers in the readme, to which this project owes the sprites used
* Added a WIP tutorial on using the engine in the readme
* Deleted an unused music file
Collision now centers around Node2D, not Area2D, and RushPlayer2D has been changed to inherit from CharacterBody2D
@coderman64
Copy link
Owner

Thanks for all your work here! I'll take a look at this soon, life's been pretty busy for me recently.

@coderman64
Copy link
Owner

Ah, I was going to ask about the boost bar.
Not sure why you got rid of the old one, but as long as it works.

@coderman64
Copy link
Owner

Hey, I added this to a new godot-4 branch.

@coderman64
Copy link
Owner

Hey, @c08oprkiua, what is your thought process behind the new boost bar? Was there any problem with the old one?

If not, I may try porting the old boost bar myself.

@c08oprkiua
Copy link
Author

Ngl, I was trying to get the old one to work properly, but it was lagging the game something fierce and the textures weren't swapping like they should have been, so I just said "screw it" and threw in the new one. Old files are still in the repo if you wanna try and get the old one working

@coderman64
Copy link
Owner

coderman64 commented May 11, 2024

Haha, that makes sense. I'll see what I can do with porting the old one.

Oh, also, do note that I made a few changes on the godot-4 branch of this repository that are not in your fork yet. Mostly fixes to particle systems, audio problems, etc.

@c08oprkiua
Copy link
Author

c08oprkiua commented May 11, 2024

and the textures weren't swapping like they should have been

So, initially, the old boost bar worked, but graphically, was clipped, which looked kind of odd. So, I attempted to implement Atlas Textures and having it switch textures on the unit (basically what you were doing, but using Godot's systems), and while that did fix the clipping, the textures weren't swapping.

@c08oprkiua
Copy link
Author

Oh, also, do note that I made a few changes on the godot-4 branch of this repository that are not in your fork yet. Mostly fixes to particle systems, audio problems, etc.

Alright

coderman64 and others added 10 commits May 11, 2024 16:59
* Added STATE_GRINDING to CharStates, which is something I did in the player v3 script that I put off carrying over.
* Implemented max boost properly, as an export var. Because of how the new boost bar works, variations in the max boost will Just Work:tm:, but idk about the old bar.
* Implemented air boosting, finally. This toggle locks the ability to initiate a boost in midair.
* Implemented the animations API, finally. This means you can now externally map animations, allowing easier changes to animations.
* Deleted some old versions of code bits, since the new ones have been proven to work
* Changed the export API to be a little more descriptive
* Changed some typos and odd phrasing in the docs
* I changed player v2 to use the move_and_slide function of CharacterBody2D for actual movement, which hopefully should fix several clipping glitches because Godot itself will handle would-be clipping situations in the background.
* With that said, I scrapped player v3, both because it is outdated, and because its purpose was to do what player v2 now does in the above
* Implemented the previously added but unused INITIAL_SPINDASH_CHARGE value, which starts a spindash off at that charge value.
* Implemented the old numerical-lerp based boost lag cam, since the Tween method isn't properly implemented yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants