Flash Multiplayer Virtual Worlds

Book description

Build immersive, full-featured interactive worlds for games, online communities, and more

  • Build virtual worlds in Flash and enhance them with avatars, non player characters, quests, and by adding social network community

  • Design, present, and integrate the quests to the virtual worlds

  • Create a whiteboard that every connected user can draw on

  • A practical guide filled with real-world examples of building virtual worlds

  • In Detail

    Flash virtual worlds are some of the most exciting—and profitable—online business being built today. Using Flash, developers can build interactive environments where users can interact with the virtual world and one another, compete, and have fun. Creating a playful environment on an electronic network presents unique challenges as you combine a fun, upbeat frontend with some serious and complex server logic.

    This handy book assists you in building amazing virtual worlds in no time by implementing ActionScripts in a Flash IDE. With this book in hand, you will build virtual worlds that have avatars walking around and interacting with non playing characters, completing challenging quests, and allowing users to link with real-world friends.

    The fun begins with first exploring existing virtual world games such as Club Penguin, Mole, Dofus, and World of Warcraft. We will then design our virtual environment. Then we will create avatars and move the avatars in the virtual world. We will add some triggers to add amusement and life to the virtual world. We will allow the avatars to interact with other players and create a buddy list for each user. Then we will integrate buildings and other environment to the virtual world. We will also let the players interact with non-player characters to complete some tasks. Finally, we move on to add interesting quests to the virtual world, which need to be accomplished by the player to gear up to the next level of the game.

    This example-rich, hands-on guide sequentially develops a multiplayer virtual world—the platform, the environment, quests, avatars, non-playing characters, and interaction between them.

    A hands-on guide to building multiplayer virtual worlds in Flash

    Table of contents

    1. Flash Multiplayer Virtual Worlds
      1. Flash Multiplayer Virtual Worlds
      2. Credits
      3. About the Author
      4. About the Reviewers
      5. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      6. 1. Developing Flash Virtual World
        1. What is a virtual world?
          1. Using virtual world for business
          2. Using virtual world for education
          3. Using virtual world for game
        2. Background
        3. Benefit of using Flash to build virtual world
        4. Connecting players in a virtual world
          1. A brief introduction to transport protocols
          2. Peer-to-peer
          3. Client-server network
            1. Polling
            2. Socket-based connection
        5. Socket server
        6. Available socket servers for Flash
          1. SmartFoxServer
          2. ElectroServer
          3. Flash Media Interactive Server
          4. Red5
          5. Writing your own socket server
          6. Choosing the right server
        7. Application architecture of a virtual world
        8. The whole picture of virtual worlds
        9. Common features in virtual world
          1. Avatar
          2. World to explore
          3. Home
          4. Items
          5. Quests
          6. Non-player characters
          7. Social features
        10. Casual game design versus MMOG
        11. Existing virtual world games
          1. Club Penguin
          2. Mole
          3. Dofus
          4. World of Warcraft
        12. Summary
      7. 2. Installing the Servers
        1. Comparing SmartFoxServer Lite, Basic, and Pro
          1. SmartFoxServer Lite
          2. SmartFoxServer Basic
          3. SmartFoxServer Pro
            1. Modifying the behavior of server
            2. JSON/Raw data protocol
            3. Accessing the database directly
          4. Comparing different package options
        2. Developing and deploying virtual world environment
          1. Adjusting server setting for the deployment environment
            1. Hosting SmartFoxServer, web server, and database in one server
            2. Hosting SmartFoxServer in dedicated standalone server
            3. Benefiting from setting up SmartFoxServer, web server, and database in different machines
          2. Setting up the development environment
        3. Installing Java Development Kit
          1. Installing JDK On Windows
          2. Installing JDK on Mac OSX
          3. Installing JDK on Linux
            1. Installing for General Linux
            2. Installing for Ubuntu Linux
        4. Downloading SmartFoxServer Pro
        5. Installing SmartFoxServer Pro
          1. Installing on Windows
          2. Installing on Mac OSX
          3. Installing on Linux
        6. Running the SmartFoxServer
          1. Starting SmartFoxServer on Windows
          2. Starting SmartFoxServer on Mac OS
          3. Starting SmartFoxServer on Linux
        7. Using embedded web server and database
          1. Running the embedded web server
          2. Running the embedded database server
        8. Downloading third-party HTTP and database server package
          1. Installing WAMP on Windows
          2. Installing MAMP on Mac OSX
          3. Installing LAMP on Linux
        9. Connecting SmartFoxServer and MySQL server
          1. Downloading JDBC Driver for MySQL
          2. Setting up the JDBC driver
        10. Configuring the server settings
        11. Configuring MySQL server connection in SmartFoxServer
          1. Restarting the server
        12. Running examples
          1. Loading a simple chat application
        13. Setting up the administration panel
        14. Logging in to administration panel
        15. Locating the Flash Client API
        16. Summary
      8. 3. Getting Familiar with SmartFoxServer
        1. Configuring a basic SmartFoxServer
          1. Overview of the configuration file structure
          2. Configuring the server
            1. Automatically binding all available IP addresses to server
            2. Listening port for connections
            3. Setting policy load data from machines in other domains
            4. Setting timers for idle user logouts
            5. Blocking bots connections
            6. Setting administrator login and password
            7. Limiting access of the administration panel to specific IP addresses
            8. Displaying zone information before connecting to the server
            9. Defining the information separator in raw protocol
          3. Configuring the Zones and Rooms
            1. Configuring a zone
              1. Naming your zone
              2. Assigning default names to users
              3. Broadcasting the user count
              4. Limiting the users that can connect to a zone
              5. Limiting numbers of rooms in a zone
              6. Limiting the number of rooms a user can create
              7. Getting all room variables along with room list requests
            2. Setting moderators for the zone
            3. Creating rooms
              1. Regular room
              2. Game room
              3. Limbo room
            4. Properties of a room
              1. Comparing the available properties of each room type
        2. Introducing the events of rooms
          1. Comparing the available events of each room type
        3. Debugging in local machine
          1. Downloading the latest debugger version of Flash player
          2. Creating the mm.cfg file
          3. Testing the debugger log
          4. Locating the Flash log output file
          5. Reading the Flash logfile
            1. Open the flashlog.txt in web browser
            2. Using a Firefox add-on to read the Flash logfile
              1. Reading the log with FlashTracer
              2. Reading the log with FlashBug
            3. "Tail" the trace log file in terminal
        4. Flash Security Sandbox
          1. Configuring master socket policy server
          2. Configuring SmartFoxServer to send socket policy
          3. Loading policy file from Flash client
          4. Enabling the network access for the Flash document
          5. Keeping updates to Flash player security policy
        5. Creating a Flash document to connect to the server
          1. Logging into a zone
        6. Creating a cooperative drawing whiteboard
          1. Testing the cooperative whiteboard
        7. Summary
      9. 4. Creating Map and Ground in Isometric View
        1. Comparing different game views
          1. Top-down perspective
          2. Side-scrolling view
          3. 3D view
          4. Isometric game view
        2. Getting an isometric projection view
          1. Isometric coordination
        3. Making an isometric map
          1. Creating the base tile of an isometric map
          2. Creating a basic isometric tile map
          3. Drawing seamless shore border
          4. Texturing an isometric map
          5. Texturing a big map
        4. Converting between screen coordination and isometric map coordination
        5. Building a map editor
        6. Summary
      10. 5. Creating Avatars
        1. Designing an avatar
          1. Determining the direction numbers of avatars' views
          2. Rendering avatars in Flash virtual world
            1. Drawing an avatar using vector animation
            2. Rendering avatars using bitmap sprite sheet
            3. Rendering avatars using real-time 3D engine
            4. Rendering avatars using 2D bone skeleton
          3. Drawing an avatar in Flash
            1. Drawing the idle and walking animation
          4. Creating an avatar class
          5. Logging in SmartFoxServer with avatar
          6. Using user variables in virtual world
          7. Adding name to the avatar
        2. Customizing your avatar
          1. Customizing different styles
          2. Customizing the color
          3. Adding customization to avatar class
          4. Designing a customization panel
          5. Making our customization panel
          6. Integrating the customization into SmartFoxServer
        3. Summary
      11. 6. Walking Around the World
        1. Creating the world
        2. Holding states of the player
        3. Moving the avatar
          1. Movement synchronization
          2. Making avatar able to walk
          3. Walking by keyboard
        4. Introducing path finding
          1. Implementing A* search
          2. Understanding the heuristic function
          3. Balancing between accuracy and speed
        5. Walking by mouse click
        6. Broadcasting where you walked
        7. Scrolling the world
        8. Saving the position for next time
          1. Creating an avatar database table
          2. Creating a new zone in config.xml
          3. Programming our first server-side extension
          4. Saving and loading last position
        9. Summary
      12. 7. Creating Buildings and Environments in the Virtual World
        1. Placing buildings on the map
          1. Outputting building from 3D software
          2. Loading the building map data
        2. Ordering the buildings
          1. Ordering the movie clips in Flash
          2. Determining an object's location and view
          3. Shaping the buildings
            1. Rendering z-order for l-shaped buildings
            2. Rendering z-order for rectangle buildings
            3. Rendering z-order for square buildings
          4. Creating a loop to sort the z-order
        3. Designing a big virtual world
          1. Dividing the big world
            1. The pros and cons of the seamless world
          2. Partitioning the world into rooms
          3. Connecting rooms with portals
        4. Adding sound to the virtual world
          1. Mixing art-based background with tile-based map
        5. Building map editor for buildings
        6. Summary
      13. 8. Creating an Inventory System
        1. Classifying items in the virtual world
          1. Different types of items
            1. Items for avatar
            2. Weapon
            3. Tools
            4. Riding
            5. Entertainment
            6. Material item
        2. Collecting items
          1. Collecting items that appear in the open
          2. Collecting items that are hidden
          3. Getting items after archiving some quests
          4. Buying items in virtual shop
          5. Trading items with other players
          6. Buying from real shop
        3. Displaying items in different forms
        4. Defining the data structure of inventory items
          1. Setting the item ID
        5. Implementing inventory in the SmartFoxServer
          1. Coding the server-side extension
        6. Implementing the item panel
          1. Loading the item definition
          2. Loading the items list from the server
          3. Moving items
          4. Implementing the item operation in RAM
          5. Creating items
        7. Exchanging items with other players
        8. Introducing the economy in virtual world
          1. Balancing the items virtual economy
            1. Setting the price of the items
            2. Preventing the inflation
            3. Hosting special event
            4. Adding fatigue to items
            5. Limiting the total amount of high-level items
          2. Preventing the virtual economy from affecting the real world
            1. Trading with real money
            2. Government policy on virtual items
          3. The responsibility to maintain a good economy system
        9. Summary
      14. 9. Communicating with Other Players
        1. Communicating using several methods
          1. Sending public messages
          2. Sending private messages
          3. Sending group messages
          4. Communicating in real-time voice
            1. Potential problems of using voice communication
              1. Consumes a lot of server bandwidth
              2. Message filtering problem
              3. Number of users limitation
              4. Logging and revisit problem
        2. Chatting with public messages
          1. Showing chat bubble
            1. Scaling the chat bubble
        3. Implementing the buddy list
          1. Creating buddy list panel
          2. Knowing others with profile panel
          3. Dispatching custom event in ActionScript 3
          4. Creating an advanced buddy list
            1. Adding buddy mutually
            2. Introducing the buddy variables
              1. Offline buddy variables
          5. Creating custom buddy list persistence class
          6. Summarizing buddy list configuration setting
        4. Sending private messages
          1. Capturing private message in server-side with internal event
        5. Sharing object data between players
          1. Making the trading items system
        6. Summary
      15. 10. Interacting with NPC
        1. Running virtual world smoothly with NPCs
          1. Classifying different roles of NPC
        2. Placing NPC in virtual world
          1. Putting our first NPC in the virtual world
          2. Preventing the NPC from disconnecting
          3. Resolving a potential problem of using provided NPC feature
        3. Advanced SmartFoxServer extension technique
        4. Controlling NPC movement
          1. Controlling NPC to walk in predefined path
          2. Directing NPC to walk using path finding algorithm
        5. Talking with NPC
          1. Communicating with NPC using text parsing
            1. The advantages of text parsing conversation
            2. The disadvantages of text parsing conversation
          2. Menu-driven conversation
            1. The advantages of the menu-driven conversation
            2. The disadvantages of the menu-driven conversation system
          3. Keyword-based conversation
          4. Choosing the right conversation system
          5. Designing the characteristic of the NPC
        6. Trading with NPC
          1. Buying items from NPC
          2. Selling items to NPC
        7. Summary
      16. 11. Designing Quests
        1. Introducing quests
        2. Triggering quests
          1. Getting quests from NPC
          2. Getting quests from reading documents
          3. Getting quests from collecting items
          4. Getting quests from the last quest
        3. Setting up server environment for quests
          1. Setting up database
        4. Designing the quest panels
          1. Displaying available quests
            1. Getting available quests in server-side extension
            2. Displaying the quests in different statuses
          2. Displaying quests for the avatar
        5. Running daemons for quests
          1. Managing quest daemons
          2. Creating our first quest — Tom's Question
        6. Introducing achievement
        7. Completing quests
        8. Rewarding the players when finishing the quests
          1. Rewarding gold
          2. Rewarding items
          3. Rewarding avatars advancement or experience
        9. Extending the quests with mini games
          1. Creating the duck shooting game
          2. Implementing the duck shooting quest daemon
        10. Making the quest system better
          1. Avoiding linear quests
          2. Indicating the availability of quests
        11. Summary
      17. 12. Social Community
        1. The benefit of using social network features in virtual world
        2. The complicated data flow
        3. Integrating Facebook platform
          1. Setting up Flash Facebook API
          2. Registering the virtual world in Facebook
          3. Putting the virtual world as a Facebook application
            1. Using FBML rendering
            2. Using iFrame rendering inside Facebook
        4. Authorizing a Facebook account
          1. Getting the profile name and picture from Facebook
        5. Getting friends list from Facebook
        6. Update the Facebook status
        7. Sending news feed to Facebook
        8. Reading news feed into the virtual world
        9. Capture a screenshot and share to a Facebook album
        10. Integrating the Twitter platform
          1. Publish latest virtual world news in Twitter
        11. Choosing the right social network service
        12. Summary
      18. 13. Deploying and Maintaining Flash Virtual World
        1. Hosting the virtual world
          1. Hosting that supports SmartFoxServer
          2. Hosting SmartFoxServer in dedicated server
          3. Hosting SmartFoxServer in cloud service
          4. Comparing the hosting solution
        2. Scaling up the virtual world
        3. Earning money from the virtual world
          1. Google AdSense
          2. In-game advertisement
          3. Monthly subscription
          4. Point-based subscription
          5. Selling virtual items and virtual currency
        4. Operating the virtual world
          1. Tracking the cost of maintaining a Flash virtual world
            1. Paying the hosting fee
            2. Licensing the Socket server
            3. Hiring customer service
          2. Losing players
            1. Losing players at sign up process
            2. Losing players at a certain level
            3. Losing players after updates
            4. Losing players due to the low quality
          3. Product lining
        5. Analyzing players actions on a virtual world
          1. Tracking players actions with funnel analysis
          2. Data mining
            1. Gathering useful information
            2. Logging the data
        6. Rapid development with OpenSpace
          1. Editing with advanced map editor
          2. Raising the avatars from the flat platform
          3. Creating custom tile events
        7. Updating and patching the virtual world
        8. Keeping an eye on the virtual world industry
        9. Putting our virtual world in mobile
          1. Small screen size
          2. Low RAM
          3. Relatively slow CPU
          4. Limited network bandwidth
          5. Benefit of porting virtual world into mobile
        10. Extending the virtual world to other platforms
          1. Apple iOS
          2. .Net and Unity
          3. Java and Android
          4. Ajax
        11. Summary

    Product information

    • Title: Flash Multiplayer Virtual Worlds
    • Author(s):
    • Release date: August 2010
    • Publisher(s): Packt Publishing
    • ISBN: 9781849690362