Sunday, February 17, 2008

TWO MAJOR CHANGES

Adam (one of my course mates) has really helped me out on the coding front. He has looked over and re-worked my script in several ways so now the whole game is looking a lot more… alive!

I’ve just spent the last few hours picking apart what’s been altered so I can fully understand the changes and how they benefit my game engine.

Apart from re-organising the script layout and generally scrapping the un-used code there are 2 major changes…

1. Getting rid of the trajectory of a projectile equation that mapped out the thrown items path. The main issue was that it constantly needed updating (looping code) to continue moving the thrown item along its path. Also this equation relied to heavily on velocity, trajectory and gravity, making the thrown item over hit or under hit the users clicked position 8 out of 10 times.

The thrown item now moves along a defined path using a Bézier curve, the Bezier code lays out four positions… initPos, EndPos, ContPos and perPos. The ContPos & perPos parts of the code can be altered numerically to increase or decrease the curved effect. The EndPos is determined by where the user has clicked the mouse, so this means the item travelling along the Bézier curve will STOP when it reaches the chosen EndPos… thus I can also loose the hidden platforms that I introduced a few posts back.
2 birds, 1 stone.

2. The problem of the duck suddenly taking flight and buggering off out of the game screen, never to be seen again, this has been a frustrating bug in my game since the very start of the project.

Every time the duck hit one of the invisible walls that was boxing him/her in, a new random direction was generated. Because I didn’t declare the numbers as integers (a number that has no decimal places) the game engine couldn’t calculate a random direction from numbers that had so many decimals in them, thus breaking the code and leaving the duck to break free and carry on travelling in its current direction. Now that the numbers generating the new directions are declared as integers, nice simple round, decimal free numbers, easy for the game engine to handle.

Big thanks Adam for helping me out. Your name has valiantly made its way into the game credits along side myself and others.

The following are issues that I am tending to next...

a. There can only be one item upon the water at any one time, so the player has to wait till the duck eats it and then the player can throw again. I’m looking into making it so multiple items can be thrown, say 3 or 4 at the most.

b. At the moment the user can click anywhere on the game screen and the item will be thrown to that mark, I am going to limit the ‘”click-able” area to just the water sector, where the duck swims about.

______________________________________________

Click HERE to play about with the current version.
Its still very minimal & flawed but its alive!

1 comment:

Adam said...

No probs mate, glad to help out!