Home Game Development Flash Multiplayer Virtual Worlds

Flash Multiplayer Virtual Worlds

By Makzan Makzan (Mak Seng Hin) , Seng Hin Mak
books-svg-icon Book
eBook $32.99 $22.99
Print $54.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $32.99 $22.99
Print $54.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Developing Flash Virtual World
About this book
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.
Publication date:
August 2010
Publisher
Packt
Pages
412
ISBN
9781849690362

 

Chapter 1. Developing Flash Virtual World

Online game community has been popular for years. Recently many virtual worlds are Flash-based and can run directly in web browser. The latest Flash player 10 and ActionScript 3 gain a performance leap from older Flash player and ActionScript 2. The memory consumption is around 50 percent more and the script performance is around 10 times faster than ActionScript 2.

Thanks to the performance enhancement and the binary socket connectivity support of the latest ActionScript, building Flash virtual world is possible for even independent Flash developers.

In this chapter, we will discuss the benefit of developing Flash virtual world. We will also discuss different connection methods between Flash clients and compare different server solutions.

 

What is a virtual world?


A virtual world is a digital environment that is similar to real world. Many users can log in to the virtual world and walk around in a virtual city or interact with each other. They can interact with others in different ways such as collaborating, chatting, or playing together.

Let's see how virtual world is used in different areas.

Using virtual world for business

Virtual world connects users in real time so that they can socialize in this virtual environment. They can collaborate with others in an online meeting or virtual workspace. Users can even share their thoughts by Voice-over-IP chatting or whiteboarding.

MPK20 (http://research.sun.com/projects/mc/mpk20.html) is one of the virtual workspaces from Oracle, previously Sun. It facilitates several features to target business users. Users in MPK20 can join a briefing with a PDF presenting, join a group meeting or even drag in documents from a computer to share between users for discussion. The following screenshot shows the virtual workspace from MPK20:

Using virtual world for education

Students can play in a simulated reality environment in virtual world. In this environment, students are given some tasks to complete. They can collaborate with other students to complete the tasks assigned by teachers. The students may learn things by immersive learning when solving different missions inside the virtual world.

Using virtual world for game

People can play games with others in virtual world. They can play against other players in real-time battle or team up to play against the missions from the online game. They may also exchange items and establish relationships like in the real world.

The following screenshot is from an online game called Mini Fighter (http://global.netmarble.com/minifighter/). It is a virtual world where players can fight against a lot of players at the same time in a 2D horizontal environment.

 

Background


In the 70s, there was MUD. MUD stands for Multi-User Dungeon and it is a text-based virtual world that players connect to through Telnet. Players connect to the MUD and interact with others or the world by inputting commands. They get feedback and information from text description. Later in the 80s, some graphical virtual worlds based on MUD were released. They were actually MUD which changed the present method from text to graphic and from command input to GUI input.

Later, Ultima Online (http://www.uoherald.com/) and EverQuest (http://www.everquest.com/) brought multiplayer virtual worlds to a new level. World of Warcraft (http://www.worldofwarcraft.com) and Second Life (http://secondlife.com/) followed EverQuest and they all made the trend of online games and virtual worlds.

In recent years, Flash virtual world is becoming more popular. Many new virtual world communities released Flash-based instead of traditional installer-based. In the beginning, Flash virtual world is not mature due to the performance issue of Actionscript 1 and old Flash player. After the introduction of ActionScript 2 and ActionScript 3, the programming language has been enhanced and the performance of Flash player boosts to support better network connections and better graphics. This makes the spring of Flash virtual world.

 

Benefit of using Flash to build virtual world


Traditional installer-based games require users download an installer or they may even need to buy an installer disk in game shop in order to play the game. And the requirement of installing software means that users may not be able to play it wherever they want. For example, they may not have the privilege to install the software on a friend's computer or public computers.

A Flash player-based virtual world does not require downloading an installer. As long as the web browsers have the Flash player plugin that fulfills the required version, users can log in and play the whole game inside the web browser directly. Traditionally users go to the game website, download the game, install it, log in, and play it. Now with Flash player-based game, users go to the game website, log in, and play it. This simplifies the flow to start playing the game.

Moreover this will attract those first-time players. When someone is landing on the game website and finds the game quiet interesting, they are willing to give it a try. At this time, it will be much better if they can log in through the guest account and try the virtual world immediately instead of downloading a big installer and waiting half an hour before starting the game, as shown in the following screenshot (these are the screenshots of the welcome page of Club Penguin and MMOG):

Another benefit of using Flash is the seamless update of the client application. It is common that updates and patches ship to the existing users after releasing the virtual world. In traditional installer-based virtual worlds, users have to download an update client before launching the virtual world.

On the other hand, updates and patches usually mean a recompile of some SWF files on the web server. When users connect and load the virtual world, the web browser downloads the updated SWF files in the background and even without users' notice. This seamless update advantage lets developers deliver patches more easily and blur the whole update flow in users' view. The following screenshot shows virtual world data update loads automatically when a player logs in:

 

Connecting players in a virtual world


The core of a virtual world is multiplayer. Multiplayer means players need to connect to each other in order to interact in the virtual world. There are two main transport protocols in the Internet — TCP and UDP. We will have a brief discussion on them and then discuss the network model that connects computers.

A brief introduction to transport protocols

There are two main transport protocols that the computers use to deliver data from applications to the network and vice versa. They are Transmission Control Protocol (TCP) and User Datagram Protocol (UDP).

There are some main differences between TCP and UDP:

TCP provides reliable communication with error detection and recovery. The data delivered by TCP is in segments that are in order. TCP is used in most applications that require accurate data delivery such as WWW, e-mail, and file transfer. Except the latest Flash Real-Time Media Flow Protocol, all Flash connections used the TCP protocol.

UDP, on the other hand, does not have error recovery and does not guarantee the data is delivered and the order may not be in sequence. However, UDP is so simple that the header size is much smaller than TCP. The small header size and missing error recovery lets UDP give shorter latency and higher throughput. Thus UDP is often used in multimedia broadcasting applications that require faster delivery and allow transfer error.

Peer-to-peer

Peer-to-peer network means every machine connects to the other machine in the same network. In this network, every peer node listens to the requests and provides results to each other.

Recently in the Flash player 10.1, Adobe introduced the Real-Time Media Flow Protocol (RTMFP) that supports peer-to-peer connections between Flash clients on top of the UDP protocol. The Flash clients can rely on the Adobe status server, which is in Beta now, to locate and authoricate the peers or directly locate peers in the same local network.

One advantage of peer-to-peer network is that there is not a master computer. Every machine in the network does the same task and thus there is no single point of failure in the network. The network application keeps working when any machine downs.

Another advantage of the peer-to-peer network is that the latency between two computers is half compared to the client-server model of communication. The computers are communicating to each other directly instead of delivering the message by another computer in middle.

Peer-to-peer network is useful for multiplayer applications or games that divide the users into small groups. They can benefit from the peer-to-peer approach that computers in group are communicating directly to their targets and the network bandwidth used in each group will not affect the others.

However, there are some disadvantages that make it not suitable to use in a virtual world with massive multiplayer.

As there is not an administrative machine, every machine is the same and they all need to have a copy of all logic and data in local. Users will have access to all critical data and can easily modify the data without validation. Hacked clients can send out altered messages to other peers to cheat them. This raises the security problem that the hacked clients can claim to have unlimited health points or claim that all attacks are missed.

Moreover, every machine establishes connection with each other. This make the number of connections grow quadratically with the increasing number of nodes. There are a total of 5050 connections when there are 100 machines in the network. What if there are 1000 machines and 50,000 connections? Imagine that there are 100 players now in the virtual world and all 100 players are doing different tasks and then broadcasting to each other in every second. The whole network will be overloaded.

Another disadvantage is that the connectionless characteristics of UDP may make peer-to-peer connections fail on computers that are behind a firewall or NAT. The following diagram shows the peer-to-peer architecture:

Client-server network

Client-server network means there is a centralized server and every machine connects to this server. The server computes requests from client machines and provides results to client machines that need the results. What clients do is just send a request to the server and display the results. There can be few or even no logic in client side.

This network is usually used in virtual world because there are only N connections between N clients and the security is enhanced as most critical logic and data is in the server so that users cannot modify it themselves.

Take the previous 100 machines in Peer-to-peer section as an example. There are 100 players in the virtual world with the server-client machine now. When one player sends a broadcast message to tell others, the message was sent to the server and the server distributes the messages to all other 99 machines. The following diagram shows client-server architecture:

Clients need to keep communicating with the server to keep the whole virtual world synchronized among clients. There are two methods to keep the communication with the server — polling and socket-based.

Polling

Polling refers to the activity wherein the clients keep asking the server for updated status in an interval. It is usually used in multiplayer applications that do not have persistence connections. It could be a PHP chat application or chess game played by two players.

The implementation of this method is easy and thus may be used by developers who are new to multiplayer applications. However, we should not use this approach in Flash. Instead we should use the socket connection from Flash to establish persistent connections to the server.

In the polling approach, clients need to keep asking the server for an update even when there are no updates most of the time. This wastes a lot of bandwidth and greatly increases the server loading. It is a bad practice to use polling in massive multiplayer applications and we should avoid it throughout the development of the virtual world.

Take an example of how a turn-based Tic-Tac-Toe with polling performs poorly.

When two players connect to the server and are ready to start playing tic-tac-toe together, player A is thinking where to put an "X" on the board. When player B is waiting, his machine asks the server if there are any updates from other players per second. After a while, player A put an "X" in the middle of the board. Next when client B is asking the server, the server tells client B that there is an "X" in the middle now. Client B renders the "X" and now it is the turn of player B. The following figure shows polling in Tic-Tac-Toe:

During this process, client B keeps sending messages to the server and the server keeps responding to client B just to tell it that nothing happened. This dramatically increases the network loading and server loading. And this is just a two-players example. What if there are eight other players watching this game as spectators? Every player sends a message to the server and get a response message from the server in every second. Imagine there are 100 rooms and 10 players in each room. Now we are talking about 1000 messages per second just for asking the server if there is any update.

Moreover, there is an update latency problem in polling. When player A updates the board, player B knows the update from player A next time when his machine asks the server. This latency depends on the polling interval. A short interval improves the latency problem while putting more load on the server and network. A long interval with large latency makes it unacceptable for real-time interaction between players.

Another disadvantage of polling is the bad scalability. A server needs to keep responding to the polling clients that use relatively lots of system resources. This results in the server only being capable for a few concurrent connections. Usually a polling server supports up to 300 concurrent connections. I had an experience on creating a Flash multiplayer virtual world with .Net web service backend. Due to the limitation of the server, I had to use the polling approach and it would end up supporting less than 200 concurrent players.

The low concurrent players capacity of a server means it needs many servers to handle massive players' connections at the same time and makes it difficult to manage.

Therefore, polling may be suitable for very small-scale networks and it should be avoided in Flash virtual world.

Socket-based connection

In contrast to polling, a socket-based connection establishes persistent connections to the server. The server sends messages to clients only when it needs and vice versa. There are no more redundant messages such as a client asking the server if there is any update because server will push updates to clients without clients initializing the requests. This is also known as asynchronous socket or event-driven socket.

Take the same Tic-Tac-Toe example with the socket-based implementation. The following diagram illustrates the data flow between player A, B, and the server. There are only three messages in the whole process, player A communicates to the server to put an "X" on the board, player B renders the "X", and a successful acknowledgment of the server to player A. If there are eight spectators in the game, only around 11 messages will be sent to the network in this period instead of 18 messages per second. The following diagram shows event-driven Tic-Tac-Toe:

The event-driven socket-based connection eliminates the polling interval latency. The very low server loading enables almost real-time communication between players for which the latency only depends on the client's and server's Internet connections.

It also allows more concurrent players than the polling architecture and is therefore easier to scale. Normally a socket server can handle thousands of concurrent connections.

 

Socket server


Socket server for virtual world is an event-driven server application that handles clients' connections and manages the communication between clients.

When a user starts up and connects to the virtual world, the machine that the user uses is a client. The place where the client machine connects to is the server. The server can be one single powerful computer or a cluster of networked computers interconnected within a high-speed local network. The purpose of the socket server is to manage all client's connections and provide centralized logic and control to clients. It may also respond to provide and store persistent information for the virtual world such as user profiles or world state.

Unlike developing an offline single player game where all logic and data are placed in a SWF file, logic and data are distributed into different places in a virtual world.

Most critical game logic, such as business logic that handles virtual money transaction, is located in the server to enhance the security. The server is also responsible to handle all users' actions and behavior, and provides each user the information they need.

On the other hand, clients are in-charge to display the virtual world according to the client-side data and latest data that updates from server-side. Client-side data includes terrain, map, UI, and basic logic.

For example, imagine that there is a player standing in front of a fountain and you can see him in the virtual world. It is the client that renders the fountain sight according to your current position. And the client gets an updated message from the server that there is another player standing in front of the fountain and renders this player. The clients also gets the appearance of that player from the server in order to render it.

 

Available socket servers for Flash


There are several socket servers on the market that fit the development of Flash virtual world. Some are good at media streaming while some are powerful on user management.

SmartFoxServer

SmartFoxServer (http://smartfoxserver.com/) was developed by gotoAndPlay(). It is a socket server for Flash that provides powerful tools and resource management to enable highly productive development of virtual worlds and multiplayer games.

It was designed for Flash originally and now it also provides a set of API for iPhone, .Net, Java, Silverlight, and even Ajax. It also supports media streaming function by embedded open source Flash media server called Red5.

It also supports clustering through terracotta, an open source clustering software. The logic is distributed into clustered servers and enables the ability to extend the scalability and enhances the failure resiliency. The server comes with fully-documented resources with lots of tutorials for beginners. There is also an active forum to get support.

SmartFoxServer provides different licenses and connection options for developers. It provides Lite, Basic, and Pro options with maximum connections from 100 to unlimited. The Lite version is free with maximum 50 concurrent connections and Basic or Pro version are free for up to 20 concurrent connections. Also the Pro version provides an add-on module called BlueBox (http://smartfoxserver.com/products/blueBox.php) to allow connection behind firewalls and proxies via HTTP-tunneling.

However, it will be a little expensive as the server costs $2000 Euros for SmartFoxServer Pro and $400 Euros for the BlueBox add-on with unlimited connections.

ElectroServer

ElectroServer (http://www.electro-server.com/) is another mature virtual world server for Flash that was developed by Electrotank in 2001. Similar to SmartFoxServer, ElectroServer provides powerful tools and fits the development of Flash virtual world server.

ElectroServer also provides scalability by load balancing with multiple gateway servers. The gateway servers are used to handle the clients' connections I/O and the logic is kept in one server. ElectroServer also provides media streaming features.

There are two packages with different media connections and concurrent player options available. The costs of ElectroServer can be expensive. Prices start from $700 to $72K depending on the package option. The professional version is free up to 25 concurrent connections.

Flash Media Interactive Server

Flash Media Interactive Server (http://www.adobe.com/products/flashmediainteractive/) was developed by Adobe and aims to provide video streaming and real-time communication between different Flash player clients. Flash Media Interactive Server mainly targets real-time streaming and communicating technology that can stream videos with different popular codec and live stream. It supports features such as server-side ActionScript extension and server-side shared objects to make it possible for virtual world development.

This server provides clustering by edge/origin load balancing. Logic is kept in the origin server and clients connect to different edge servers, then edge servers connect to the origin server. It is like the gateway approach from ElectroServer.

However, the lack of game room management and game-related features means that developers have to write their own game management scripts.

Flash Media Interactive Server costs $4500 for unlimited connections.

Red5

Red5 (http://red5.org/) is one of the open source Flash socket servers that provides basic server-side features such as real-time protocol and shared memory. It aims to become an open source alternative of Flash Media Interactive Server and thus it is more powerful on video streaming than virtual world resources management.

Red5 uses edge/origin clustering that is similar to the Flash Media Interactive Server while using the open source Terracotta solution.

As an alternative of Flash Media Server, it also lacks server-side game management features. However, as it is open source, you can extend the functionality of Red5 to fit your idea of the virtual world.

Writing your own socket server

Most Flash servers in the market provide extensibility for developers. However, available servers may not fit your budget or design ideas. As an alternative solution, you can program your own socket server to handle Flash connections. The socket server is usually written in C++ or Java. What a virtual world server does is handle all connections and manage all zone, room, and user resources via a predefined protocol. There are some resources from Internet that discuss how to develop a socket server. There is an old article (http://gotoandplay.it/_articles/2003/12/xmlSocket.php) from gotoAndPlay() that introduced the basic concept of implementing a socket server that connects Flash. Although the article used an old version of Flash and the XML socket instead of the binary socket, it is a good starting point to learn the concept before developing the socket server. In a real case, two friends of mine implemented a Flash server in Java for one year and now they are working on several multiplayer games in it.

Choosing the right server

 

SmartFox Server 1.6

ElectroServer 4

Flash Media Server 3.5

Red5 0.9

Virtual world architecture (Zoon/Room)

Very good

Very good

Bad

Bad

Media Streaming

Good

Good

Very good

Good

Supports Client

Flash, iPhone, JAVA, Unity, .Net

Flash

Flash

Flash

Connections for development

20

25

10

Unlimited

Maximum Connections

Unlimited

200,000

Unlimited

Unlimited

Clustering

Logic distributed without single-point failure clustering

Gateway approach with logic in one server

Gateway approach with logic in one server

Gateway approach with logic in one server

Firewall Traversal

BlueBox HTTP-tunneling

HTTP-tunneling

RTMPT HTTP-tunneling

RTMPT HTTP-tunneling

Cost

Average

Average to expensive

Expensive

Free

Either SmartfoxServer or ElectroServer fits the development of virtual world the most. They all provide solid zone, room, and user managements, and they are ready for extension and can scale big when the virtual world grows.

Note

Throughout this book, all examples will be based on SmartFoxServer. We choose SmartFoxServer because it supports not only Flash but also iPhone, Unity, Java, and .Net. This keeps the flexibility to extend and spread the virtual world to other platforms with less effort.

 

Application architecture of a virtual world


There are two fundamental entities at the base of the SmartFoxServer architecture: Zones and Rooms.

SmartFoxServer can run multiple applications at the same time. Each zone represents a different application. A developer can configure different zones to host different virtual worlds or games in the same server instance. The activity, messages, and events are totally isolated among zones.

Room can be created within zones to logically group users. Users in the same room can chat, interact, or play games together. For example, I can send a message to all users in Room A when I'm in Room A. And those users in Room B would not receive this message because I'm only interacting with users in the same room. The following diagram shows the Zone, Room, and User relationship:

Rooms can also be used as a tool to organize the virtual world's areas into different connected parts. Depending on the virtual world design, a room could represent an entire city, a street, or just a physical room inside a building. These rooms are connected so that when a user walks from one street into another street, he is leaving the old room and joining a new room that represents the street he is walking to.

Most user interactions are limited within a room. Therefore, the resolution of the room that is representing affects how players can interact with others. For instance, users can interact with others within the same street if each street is represented by one room or they can interact with others within the same city if the entire city is represented by one room. The following diagram shows a virtual world in which each city is a room:

The following diagram shows a virtual world in which several streets compose a room:

 

The whole picture of virtual worlds


We have brief ideas on the socket server, client-server concept, and the application architecture now. It is time to put them together to get whole concept of how a virtual world works. The following figure shows the components for a virtual world:

The socket server is the core part. There is a database to store permanent data such as user account info. A server-side extension lets developers program server-side logic, which is related to the virtual world, such as a virtual items exchange or virtual money transaction.

A server-side management component is in charge of following tasks:

  • Handles and manages all socket connections

  • Manages the memory of zones, rooms, and users

  • Dispatches events and messages to appropriate clients, such as send messages when someone left the room

  • Calls server-side functions when client requests, such as create room or send public message

  • Calls server-side extension by clients requests

Flash client will have some static data of the virtual world, for example, map terrain. It also contains an API for connection to server-side functions.

Usually, there is an admin panel for the virtual world moderator to monitor the whole server. The admin panel can access the server via API and query statistics from the server or perform some admin actions such as server configuration or kick-users.

 

Common features in virtual world


There are some common features that often appears in a Flash virtual world.

Avatar

An avatar is an identity to represent the user when interacting in a virtual world. The avatar often means a character in Flash virtual world. Users can choose different appearances of the avatar and may even be able to customize the color and detail style.

The following screenshot is from the NuYu avatar editor from Data Design Interactive (http://217.199.176.105/ddigames/). It allows avatar customization on every part of the face and the players can use these avatars in the games.

World to explore

In a virtual world, there are different places that users can explore. There is usually a starting city that every new player arrives to. Then players start their own journey in the virtual world by exploring different cities, places, and making game progress or interacting with others in different places in the world.

Home

Players may have their own private place called home. They can buy different things to decorate their home. They may invite friends to their home for private group chat.

The following screenshot is a home of a member in Fantage virtual world (http://www.fantage.com/). Players can customize their home with decorations that are available at the game store. They can also create party events that invite others to come and get special party items.

Items

Items are another key feature of a virtual world. Letting players collect items can be a good motivation to make them active in a virtual world. Some players will even put rare items in their home to show off how powerful they are. Items can also be mounted on avatars to enhance appearance and properties such as hats or magic ward.

Quests

Quests are some tasks that players have to accomplish in order to gain rewards. Quests may require players to explore to a certain place, find certain rare items, perform social activity, or combat with some enemy creatures. The rewards are often virtual money, experience, or special items.

Non-player characters

Non-player characters are characters that are controlled by the virtual world instead of by users. They often provide services to users such as selling items, providing quests, and giving introductions to new players. Some enemies or creatures may also be a non-player character.

Social features

It is important to enhance the social features to keep a virtual world live. A successful virtual world let players know what others are doing, discuss the world with each other, and spread the news and progress to others.

 

Casual game design versus MMOG


Games in virtual worlds can be divided into two types — casual games or massive multiplayer online games. In virtual worlds with casual games, there are many types of mini multiplayer games that players can join from the lobby. Every mini game takes minutes to play with several competitors together. Players may continue to play different types of mini games after each round ends.

In contrast to casual game types, virtual worlds with massive multiplayer game design requires players to play in the same world. It is much like traditional role playing games in which players keep finishing quests in the world to make the story progress.

There can also be a mix between them. Some virtual worlds provide a bunch of light-weight mini games that players can play with each other for fun while at the same time, helping players to keep finishing quests and exploring the world.

 

Existing virtual world games


There are several existing virtual worlds running successfully. Some of them are Flash-based and some are not. We will introduce them here so that we can give them a try and get some inspiration before starting our virtual world design and development.

Club Penguin

Club penguin (http://www.clubpenguin.com/) is a successful story of Flash multiplayer virtual world with SmartFoxServer as backend. It is a kind of casual game virtual world where players explore in a small town and play multiplayer mini games with each other. It can be a good example of what Flash with socket server can do.

Mole

Mole (http://www.51mole.com/) is one of the largest Flash online virtual worlds in China now. It is a casual virtual world game in which players play mini games and some casual quests inside the world. It targets children whose age ranges from 6 to 14. According to a 2010 document, the mole virtual world has a record of 450K peak concurrent players.

Dofus

Dofus (http://www.dofus.com/) is a Flash massive multiplayer online role playing game developed by Ankama from France. Players play against monsters in the virtual world to gain experiences to level up and earn points to buy equipment. Dofus in one of the most successful Flash virtual worlds and has 30 million registered players and 250K peak concurrent connections in 2010.

World of Warcraft

As one of the best-selling virtual world communities, it is worth taking a trial at this game. World of Warcraft (http://www.worldofwarcraft.com/), also referred as WoW, is a kind of serious game play virtual world that contains a huge worldview and complicated story.

Club Penguin, Mole, and Dofus are Flash virtual worlds but World of Warcraft is not. It is developed in LUA, a scripting language, and C++. WoW is a very huge 3D virtual world that contains over 7000 quests and 40,000 non-player characters. The 3D environment with large graphic assets exceeds the limit that Flash player can handle. According to a document from Blizzard, the company behind WoW, in 2009, the World of Warcraft ran on over 13,000 server instances.

 

Summary


In this chapter, we have a brief introduction to Flash multiplayer virtual world. We also get a rough idea on the architecture and features of a Flash virtual world and some common designs of virtual worlds. In the coming chapters, we will start by installing the socket server and will build a Flash virtual world step-by-step.

About the Authors
  • Makzan Makzan (Mak Seng Hin)

    Makzan focuses on the fields of web development and game design. He has over 14 years of experience in building digital products. He has worked on real-time multiplayer interaction games, iOS applications, and rich interactive websites. He has written three books, on building a Flash virtual world, and creating games with HTML5 and the latest web standards and developed a video course as well. He currently teaches courses in Hong Kong and Macao SAR. He writes tutorials and shares his know-how on makzan.net.

    Browse publications by this author
  • Seng Hin Mak

    Makzan focuses on the fields of web development and game design. He has over 14 years of experience in building digital products. He has worked on real-time multiplayer interaction games, iOS applications, and rich interactive websites. He has written three books, on building a Flash virtual world, and creating games with HTML5 and the latest web standards and developed a video course as well. He currently teaches courses in Hong Kong and Macao SAR. He writes tutorials and shares his know-how on makzan.net.

    Browse publications by this author
Flash Multiplayer Virtual Worlds
Unlock this book and the full library FREE for 7 days
Start now