Home
HomeFlexible, Lightweight and Truly Skinnable Flash ComponentsPHPObject and other Flash ExtensionsForumsBlog JournalLinks
Buy Flash Components
  PHPObject - Opensource PHP Flash Remoting

redhand Using PHPObject to Save and Retrieve Simple Game Levels "Overview"

Author
Tor de Vries


Overview
Using a simple video game level editor in Flash as a foundation, this whitepaper/tutorial explains how to use ActionScript, PHP, and the PHPObject "Flash remoting" libraries to save and retrieve data to/from a server in XML format.

Introduction
Video games are frequently tile-based.  A “tile-based” game uses a library of preset graphical objects to display the game’s interface.  One tile might contain graphics for a patch of grass, while another could illustrate a square of cement sidewalk.  Tiles are designed to seamlessly mesh with surrounding tiles, so that a large and varied gamespace can be created from a handful of tiles.  Popular games like SimCity and Warcraft are good examples, though most side-scrollers and first-person-shooters are also usually tiled. Tile-based games also lend themselves to level editors, graphical interfaces that allow game designers to place game elements on an actual level, rather than trying to create the level arrays with hand-typed text. This also allows players to create their own levels. These levels need to be saved somewhere for designers to retrieve and edit.

This whitepaper introduces a simple game level editor in Flash, using Ghostwire's free PHPObject libraries to do "Flash remoting" to save and retrieve data to/from a server. The official definition of Flash remoting is that it enables "a powerful yet simple programming model and runtime enabling Macromedia Flash MX to connect to remote services exposed by application servers and web services". In other words, Flash can now talk to your server without having to encode and decode variables through loadVariables() or XML.sendAndLoad(); your ActionScript and your server-side language can simply refer to the same sets of objects. Specifically, PHPObject allows Flash and PHP to share the same object class as if it was native to the code.

You can play with this level editor on my web site. It is not for a particular game, but serves as a good vehicle for explaining Flash remoting. In this level editor, there are seven possible tile shapes:

These represent open space, treasure, obstacles, walls and the player. The level editor provides a grid of tiles, 20 on each side, for a total of 400 tiles. After choosing a shape from the toolbox, you can click on individual tiles to change them to that shape. You could end up with a level like this:

This level could then be read into a game engine and rendered onscreen as a birds-eye game (like Pac-man), an isometric game (like Warcraft) or something else, using far more detailed tiles than those represented in the editor.

Next:
Getting Started


About PHPObject

PHPObject is an opensource alternative to Flash Remoting for PHP developers. With PHPObject, you can call a method of a PHP class/library on your web server as if the class/library was defined in Flash itself. It takes care of your client-server connections and makes passing of variables (properties) between Flash MX and PHP easy, and thereby providing a convenient way to connect rich media clients with data and business logic residing on your server.

PHPObject is developed by GhostWire Studios and released under the GNU LGPL.


>> Documentation <<

 
Contact UsSite Map
Copyright © 2003-2006 GhostWire Studios