• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 18. 9-Ball > Points to Remember

Points to Remember

  • Don't let a player make a move until both he and his opponent are ready to receive a move. Otherwise, the game's synchronization will be affected.

  • Given the same input on two SWF instances of the same game, Flash may not calculate the exact same result twice, although the numbers will be very close to each other. In some cases, like 9-ball, rounding will help you avoid synchronization issues.

  • All of the possible collisions during a frame are calculated, stored, and sorted from earliest time to latest time . Then the script goes back and calculates the reaction for the first collision (lowest time). We run the collision-detection script again to see if there are any more collisions. This is done until there are no more collisions, or ten times—whichever comes first.

  • For speed optimization, we use two arrays to store the state of the balls—a moving array and a notMoving array. We then perform collision detection between every ball in the moving array and then between every ball in the moving array with the balls in the notMoving array. We do not check for collisions between balls in the notMoving array.

  • When the moving array is empty, the turn is over.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint