Because of the rewind feature being pretty much figured out. I had to re-write a good chunk of the code to better fit the function. This was pretty much making specialized modules for each game element. Instead of handling all of Pod's and the crates movements in one file I've changed it so that each has their own. Before I had started work on the rewind most of the coding I was doing was a sort of prototypes. Getting the basic concept down and making sure it worked right. This is just one example of whats been done.
How movement is being handled has changed also. Before For a move function to activate a keystroke was required as part of the conditions. All four directions had their own functions, now there are only two functions one for the X and one for the Z. Up, down left and right are now handled using a velocity variable and a multiplier.
The multiplier is under the user input module depending on the direction pushed. For example to move left the multiplier is set to -1, for right it's just the opposite.
This is a bit of the code that is used to control the movement of Pod.
if(self.Falling == False) and (self.Moving == False):
self.var.PodNextX = self.var.Pod.PodModel.getX()+( self.velocityX * self.MultiplierX )
As you can if you change the multiplier you change the direction. To stop the model, a zero is simply dropped in for the multiplier. This is also useful in the condition that Pod or Rodney is on a conveyor belt, which automatically sets the velocity to the appropriate speed. But is the character or object collides with a wall while still on the conveyor, a zero would be applied, canceling the movement.
This is just one small snippet of code that I've changed to make the game not only smoother but also more optimized.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment