I don't use C#, but I see some things that bug me about this code that should be relatively language-agnostic:
- It feels strange that some of your information is coming from static PlayerControl variables and other information is coming from casting(?) the SceneNode to an Entity or a Mack. That's an "architecture smell" to me.
- Having to frequently cast(?) the SceneNode to what I assume are some of its derived classes also seems like a code smell. I would either expect the interface to have a handleInput() method you can call that's just blank for non-player objects, or one of the update methods to have a single line that says "If this node is a Player, call handleInput() on it" so the downcasting(?) is kept to a bare minimum. Maybe this is different in C#.
- About these two lines...
if (playerPosY > PlayerControl.maxJumpHeight)
// Is the actual player height lower then the maximum jump height (Remember Cart System goes downwards with positive values)
else if (playerPosY <= PlayerControl.maxJumpHeight)
// Is the players height higher or equal as the maximum jump height...
It seems like the comparison operators you're using are the opposite of what you intended to use.
- This comment here...
if(!Keyboard.IsKeyPressed(Keyboard.Key.Down))
// Watch out if the Crouching buttin isn't in use - would bring in some TextureChanging artifacts if not watched.
tells me you would benefit from implementing a state machine for your player character, as described at
http://gameprogrammingpatterns.com/state.html.
- This pair of conditions didn't make any sense to me the first few times I looked at it:
if (PlayerControl.isJumping && PlayerControl.isMaxHeightReached)
// Is the player still in a jump and has already reached its maximum point
if (playerPosY == PlayerControl.oldHeight)
// annnnd is the actualy players height equal to the oldHeight when he started jumpin'
At first it looks like this is saying "if the player is jumping, is at the maximum possible jump height, and is also at the height where he started his jump" which is obviously impossible unless the max jump height is zero. I think it might be clearer if isMaxHeightReached was renamed to something more like isDoneAcceleratingUpward, since I think that's what it's actually being used as. I'm guessing the comparison to oldHeight is meant to test if the player has "landed" on solid ground or not, but unless all of your platforms are at exactly the same height, that doesn't seem right.
- In general, if you feel the need to comment your code that much, then your code probably isn't as self-explanatory or readable as it should be. You'll notice in some of the things I just pointed out that a few comments contradict the code (like the PosY to maxJumpHeight comparisons), a few others restate the code instead of explaining it (like the == oldHeight comment), and a few others literally say the code's not readable enough.