spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column46


A DOM-Based Snakes Game, Part I (2)

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

The Game Architecture

The architecture of the game board is based on the DIV container (see sketch below). This container includes 299 HTML tags, numbered 0 to 298. The tag types are also shown in the sketch below. The board is divided into several areas. The right most column is the <BR> column. This column's tags simulate a "new line" at the end of every row. The other 286 tags are <IMG> tags and constitute the game's visible board. The visible board is surrounded by a border that includes its outer images. (See the hashed images in the sketch below.) The images inside the border constitute the core of the board and is where the action takes place. The core includes 220 images, arranged in 11 rows of 20 images each. Every image on the board can be found by its row and column numbers. There are 23 columns, numbered 0 to 22. Likewise, there are 13 rows, numbered 0 to 12. The border includes columns 0 and 21, and rows 0 and 12. Column 22 is the <BR> column. As you can see from the sketch below, each image is also accessible as an element of a single array that includes all the images, numbered 0 to 298. We'll show you later in this column how to convert a row-column coordinates to a single array indexing.

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Created: August 16, 1999
Revised: August 16, 1999

URL: http://www.webreference.com/js/column46/architect.html