FlixelCommunity / flixel

Community fork of Adam “Atomic” Saltsman's popular game engine Flixel. Distilled from a variety of Flash games he worked on over the last couple years, including Gravity Hook, Fathom and Canabalt, its primary function is to provide some useful base classes that you can extend to make your own game objects.
http://flixelcommunity.org/
Other
84 stars 17 forks source link

Reorganize `FlxU` #208

Closed IQAndreas closed 10 years ago

IQAndreas commented 10 years ago

Move several methods to new locations (as per the FlxMath planning spreadsheet)

FlxU.rotatePoint() -> FlxPoint.rotate()
FlxU.getAngle()    -> FlxPoint.angleBetween()
FlxU.getDistance() -> FlxPoint.distance()

FlxU.abs()   -> FlxMath.abs()
FlxU.floor() -> FlxMath.floor()
FlxU.ceil()  -> FlxMath.ceil()
FlxU.round() -> FlxMath.round()
FlxU.min()   -> FlxMath.min()
FlxU.max()   -> FlxMath.max()
FlxU.bound() -> FlxMath.clamp()

FlxU.getTicks() -> FlxG.getTicks()
IQAndreas commented 10 years ago

The only method I wasn't sure where to move was computeVelocity(), but I'm guessing you want that one in your FlxVector class, right @Dovyski?

I also left the FlxColor methods for later since the class is non-essential at this point, and the methods are not used internally by Flixel (and are therefore much less likely to cause merge conflicts when moved).

I have tested the code and made sure it compiles, but I haven't actually tested the resulting binary to make sure everything runs as expected. However, the changes are so "slight" that it should work just fine.

Merge the pull request if everything looks good, and I'll finish the last of the "reorganization" when I tackle FlxG tomorrow (might be Tuesday morning if I'm stuck at work all day; I expect tomorrow will be a long work day).

Dovyski commented 10 years ago

The only method I wasn't sure where to move was computeVelocity(), but I'm guessing you want that one in your FlxVector class, right @Dovyski?

I comment in the spreadsheet about that, but will comment here as well. That method might be a good fit for FlxVector, but technically it has no vector in it (just Number). Maybe we could move it to FlxMath (if the method is used internally by Flixel) or to FlxMotion in Flixel Power Tools (if the method is not used internally by Flixel).

IQAndreas commented 10 years ago

Maybe we could move it to FlxMath (if the method is used internally by Flixel)

It was being used internally (by FlxObject) so I moved it to FlxMath. I also adjusted the arguments a bit, including a change which lets you pass a TimeElapsed value, rather than Flixel automatically retrieving it from FlxG.elapsed. (I just feel that FlxMath should be encapsulated in such a way that it doesn't actually know what is going on around it in Flixel, and should instead be self-contained)

IQAndreas commented 10 years ago

Is the code verified, and are we good to merge?

I'll be opening a separate issue for "Organizing FlxG" rather than lump it into this one, since I will be taking a different approach.

Dovyski commented 10 years ago

I also adjusted the arguments a bit, including a change which lets you pass a TimeElapsed value, rather than Flixel automatically retrieving it from FlxG.elapsed.

Great!

About the rest, everything is verified and good to go. You can merge it anytime you want.