AtomicGameEngine / AtomicExamples

Examples for the Atomic Game Engine
https://www.AtomicGameEngine.com
95 stars 58 forks source link

Racer example vehicle class is not good #110

Closed troll-kadabra closed 7 years ago

troll-kadabra commented 7 years ago

the vehicle class in the racer example has too many parametres and createchassis returns the vehicle what doesnt make sense, it should use vehicle not chassis in the name. https://github.com/AtomicGameEngine/AtomicExamples/blob/master/Racer2D/CSharp/Resources/Scripts/AtomicMain.cs#L95 why not use a factory that also creates the node and returns it?

ghost commented 7 years ago

Thank you for your analysis of the code, but is the Racer example not functioning in some way? Everything can be improved, if you like, you have the option to improve this program https://github.com/AtomicGameEngine/AtomicGameEngine/wiki/How-to-help-make-Atomic-better

Alan-FGR commented 7 years ago

sigh I know this is closed, but lemme address those points anyway: While it's true CreateChassis has a lot of parameters, what's the alternative? Configuration objects would require a lot more code and since it's an example it's better to keep it minimal. Perhaps using kw args would improve readability but I find that unnecessary if you're using a decent code editor. I decided to go with Chassis so it's more descriptive in the sense that the user shouldn't expect the wheels to be created, or at least won't be surprised when CreateChassis doesn't create the entire vehicle. Read this comment: https://github.com/AtomicGameEngine/AtomicExamples/blob/master/Racer2D/CSharp/Resources/Scripts/AtomicMain.cs#L94 (especially the "Convenience" part) I decided to go with that architecture so it's easier to reuse the components and also to make it easier to eventually add an inspector for it so you could use it in the editor, what wouldn't be easy if the vehicle class had ownership of the other classes and was responsible for creating the nodes.