Fine-tuning the game: adding educational content in .NET Integrated Code128 in .NET Fine-tuning the game: adding educational content

1. use .net vs 2010 ansi/aim code 128 generating toassign code-128c with .net iPhone Fine-tuning the game: adding educational content At the begi nning of this chapter I said this was going to be an educational game. It"s time to fine-tune the game and add educational content..

Polishing y .net vs 2010 barcode code 128 our game is a critical process, as it makes the difference between a great game and "just another game". Once you have a playable prototype like our Concentration game, it"s time to fuel up your creativity and try to distinguish it from the masses.

. What if the re were no more duplicate tiles with the same shape but, for instance, a tile with a green circle and a tile with a "Green Circle" text Children would need to remember both tiles" positions and their meaning. How can we add this feature without rewriting too much code In two simple steps: 1. Create 20 distinct tiles with values from 0 to 19.

2. Let the script know matching tiles are 0 and 1, 2 and 3, 4 and 5, and so on. This is the final code, stripped of all comments and trace() outputs.

There isn"t any new concept, so you should be able to understand what it does by yourself.. Main function:. public func tion Main() { const TILES_PER_ROW:uint=5; var tiles:Array=new Array(); var tile:tile_movieclip; for (var i:uint=0; i<NUMBER_OF_TILES; i++) { tiles.push(i); } var swap,tmp:uint; for (i=NUMBER_OF_TILES-1; i>0; i--) { swap=Math.floor(Math.

random()*i); tmp=tiles[i]; tiles[i]=tiles[swap]; tiles[swap]=tmp; } for (i=0; i<NUMBER_OF_TILES; i++) { tile=new tile_movieclip(); addChild(tile); tile.cardType=tiles[i]; tile.x=5+(tile.

width+5)*(i%TILES_PER_ROW); tile.y=5+(tile.height+5)*(Math.

floor(i/TILES_PER_ROW)); [ 39 ]. Concentrati Code 128 Code Set B for .NET on tile.gotoAndStop(NUMBER_OF_TILES+1); tile.

buttonMode=true; tile.addEventListener(MouseEvent.CLICK,onTileClicked); } }.

This is onTileClicked function private fun .net vs 2010 USS Code 128 ction onTileClicked(e:MouseEvent) { if(canPick){ var picked:tile_movieclip=e.currentTarget as tile_movieclip; if (pickedTiles.

indexOf(picked)==-1) { pickedTiles.push(picked); picked.gotoAndStop(picked.

cardType+1); } if (pickedTiles.length==2) { canPick=false; pauseGame=new Timer(1000,1); pauseGame.start(); if (Math.

floor(pickedTiles[0].cardType/2)== Math.floor(pickedTiles[1].

cardType/2)) { pauseGame.addEventListener(TimerEvent. TIMER_COMPLETE,removeTiles); } else { pauseGame.

addEventListener(TimerEvent. TIMER_COMPLETE,resetTiles); } } } }. and this is resetTiles function private fun .net framework Code 128B ction resetTiles(e:TimerEvent) { pauseGame.removeEventListener(TimerEvent.

TIMER_COMPLETE,resetTiles); pickedTiles[0].gotoAndStop(NUMBER_OF_TILES+1); pickedTiles[1].gotoAndStop(NUMBER_OF_TILES+1); pickedTiles = new Array(); canPick = true; }.

The other functions and declarations remain unchanged. [ 40 ]. 1 . And this is .net vs 2010 Code 128C an example of a matching pair:. Purple squa re picture is tile 18 and "purple square" text is tile 19. They match. Your Concentration game is now complete and ready to be played.

. Summary. Concentrati on, while being an easy game to make and play, opened the path to the world of programming games. Now you are able to set up a Flash project to make a game, work with DisplayObjects, interact with basic data types such as variables and arrays and manage mouse and timer listeners..

Where to go now Test your A S3 skills adding new features to the game. I am giving you two suggestions: 1. Detect when the player completed the game.

You can easily do it by creating a new instance variable that counts the successful matches and checks if they are equal to the total number of tiles / 2. 2. Count how many tries the player is making using another instance variable that you"ll increment every time the player picks the second tile.

Print these values in the Output window.. [ 41 ]. Minesweeper Minesweeper .NET code128b is a single player turn-based game whose goal is to clear a mine field without being killed by a mine. The mine field is represented by a grid of covered tiles, some of them hiding a mine.

Grid size and number of mined tiles vary according to difficulty level. At each turn, the player must pick a tile with a mouse click. If he clicks on a tile without a mine, a digit with the amount of adjacent tiles containing a mine will appear.

Using logic, the player must click all free tiles. If he hits a mine, the game is over. With a right-click on the tile, the player can "flag" that tile, to help him remember where he thinks there is a mine.

In some versions, the player must flag all mines. In this chapter you will learn how to make a complete Minesweeper game, using these main techniques: Multidimensional arrays Loops with an unknown (yet not infinite) number of iterations Functions with return values Logical AND and OR operators Recursive functions Dynamic text fields DisplayObjects hierarchy and DisplayObjectContainers Adding custom variables to objects.
Copyright © . All rights reserved.