02.02.2013 Views

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Flash</strong> <strong>MX</strong> <strong>2004</strong> <strong>Games</strong><br />

75 function spinAround(){<br />

76 if (paths & SOUTH){<br />

77 //Only allowed if a SOUTH movement is available<br />

78 switch (dir){<br />

79 case NORTH:<br />

80 dir = SOUTH;<br />

81 row++;<br />

82 break;<br />

83 case SOUTH:<br />

84 dir = NORTH;<br />

85 row--;<br />

86 break;<br />

87 case EAST:<br />

88 dir = WEST;<br />

89 col--;<br />

90 break;<br />

91 case WEST:<br />

92 dir = EAST;<br />

93 col++;<br />

94 break;<br />

95 }<br />

96 Tunnel.mode = Tunnel.EXITING;<br />

97 Tunnel.anim.go<strong>to</strong>AndPlay("Spin");<br />

98 }<br />

99 }<br />

Listing 15.9<br />

Each exit sequence completes by setting the mode variable <strong>to</strong> ‘EXITED’; this is used by the<br />

onClipEvent <strong>to</strong> trigger an ‘In<strong>to</strong>’ sequence. This in turn completes by setting the mode variable<br />

<strong>to</strong> STATIONARY. Using this code you can move around any maze at will. Try creating a new<br />

maze using the mazeMaker and then saving this as ‘maze.txt’ in the same folder as ‘maze.swf ’.<br />

Running the ‘maze.swf ’ movie will load the new maze.<br />

Suggestions for enhancement<br />

The example is only the basis for a program; you can improve it by randomly blocking an exit,<br />

or having a timer so that the user must move quickly. Maybe the map is usually hidden with<br />

just a quick glance every now and then. Maybe you are being chased and have <strong>to</strong> avoid the cells<br />

that contain baddies. You could work out a value for every cell as a distance <strong>to</strong> exit value. By<br />

comparing this with the previous cell you could provide a ‘getting warmer’ or ‘getting colder’ bar<br />

<strong>to</strong> help find the way out of the maze without a map. There are so many additions <strong>to</strong> the basic idea<br />

that I leave it <strong>to</strong> the interested reader <strong>to</strong> add some excitement <strong>to</strong> the basic game.<br />

242

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!