Beauty in the details

I’ve skimped on some of the finer details of this project and I want to rectify that by adding a new category to this blog: Detail. Here’s a fun detail from the gun element.

When a player picks up a gun, selects it and then hits the action button, the firing method runs. The firing method creates a new bullet object in the projectiles div, which is already styled to look like a bullet. Then the method calculates which direction to fire the bullet and puts all that information into an jQuery animate() call.

The problem initially was the speed. Because the animation was not a fixed distance (always between the player and the edge of the room), bullets took the same amount of time to travel to any edge. I fixed this by making a speed variable that took the distance between the player and the wall as a factor, adding it to the time delay on the animation. The final result is that the bullet seems to travel the same speed no matter where you fire it. FUN!

Leave a Comment

Name: (Required)

E-mail: (Required)