I'm a Programming Teacher. I've played games my whole life. I like supporting games that are multiplattform. I'm trying to become a Indie Game Developer. I love the old SNES RPG's and pixel art so my game is going to be a Secret of Mana 2 like game :)

Report content RSS feed Refactoring Time!

Posted by Khazrak on May 10th, 2013

After some time some classes get bloated with code.

My Player-class is a good example.
It handles most of the combat (combat movement, attack-logic, attack-hittest) the movement, the animation of the character, the logic of the character.
Frankly, it gets messy.

So I started to refracture it. It's always good to refactor after some time to see if you can solve it better with less code. Many may argue that it takes time, time that they may not have.
But I see it as I have time, and it will save me time in the future if everything is at good place.

Why not make it good from the start? Because I don't know how it will work before I've done the whole thing.

So I dished out the combat-logic to a seperate class and tried to have the Java-cross-reference problem to a minimum. If you don't know what that is:
It's when a class that is an object inside another object needs to change or reach its "parent" (the object that the new object resides in). Kind of like the chicken or the egg....but not really...
C# doesnt even let you do it.

A also made a class for the dash-movement, I'll try to make the regular movement to a class to.
Then every class will have a specific goal, and the Player-class will be the mediator for it :)

Refactoring continues...

Post a comment

You are not logged in, your comment will be anonymous unless you join the community. Or sign in with your social account:

Last Online
Jan 13 2014
Sweden Sweden
Become friends
Member watch
Start tracking
43 (1 today)