Step 4 Programming:

 

Language: here we have chosen ActionScript and it is version 3.0 at the moment.

Have you got the storyboard and the pseudo code? If not, visit Step 3.

Now we start programming. First make a list of the variables. What is a variable? It is a container to hold changing values, such as the score, the time, the level and so on. They are derived from the storyboard and the pseudocode.

If you are afraid of missing some variables, then don't. You will miss some and eveyone would. Just add them on when you need to.

Algorithm - how are you going to tackle a problem such as finding out if the neighbouring cell is occupied - your solution, your method of doing that will be the algorithm for checking occupancy. Another example is how would you find out if a line of cells are connected without any gap? The algorithm would be your way of checking. Use pseudocode to start your algorithm - clarify things before coding starts. Using plain English to explain how the program structure would be like.

Skills audit (1, || 2, || 3, || 4, ...)- can you do this Yes (move on) - No - follow the exercises in Unit 22 or online tutorials

Variables and data type: (M1)

Basic program sturctures, IF statement for make decision (selections), Looping (Iteration) with FOR loop, WHILE loop, etc. (M2)

Coding - good practice includes - naming, indenting, modular, class, commenting, (D2) exerises, websites, loops, comparison, evidence of P4 (developing the game or implementing the designs)

Testing (P5, M3) - debugging tools, function testing, module testing, system testing, user testing (M4), white box testing and black box testing.

Test plan: The purpose of test plan is to ensure all important aspects of the game are tested and none is neglected.

Game title:  
Test type: Black box
Test # Date Test description Data Expected result Actual result Corrective action
1   move the board left and right mouse movement the board moves with the mouse    
2   the board will stay inside the window mouse moves outside the border. the board stays within the border half of the board is outside. change the parameter in the IF expression
3   ball flies and bounces of the walls and ceiling button press to start the game the ball will start to fly in one direction and bounces off the walls correctly and and the ceiling too These are used for actual testing record  
4            
             

(examples of testing tasks: start button works as designed; ball moves continuously; stays within the frame, bouncing off..; paddle moves; paddle stays inside the frame; bricks don't move; bricks disappear when hit; score displayed; score updated correctly; level 1 complete sign pops up correctly; level 2 start correctly; game over message pops up correctly; game stops properly;.....)

Test results (see the table above) and corrective actions if needed.

You need to test as you code along. There are several tools at your disposal: Debug tool, Output error message, compiler error message, trace() function etc. Compiler error message is produced at compilation stage. At this stage, the spelling, the grammar (syntax) and reference linking are checked before converting the program into machine readable language. This is the first hurdle for program testing. Debug tool allows the programmer to examine every single line of statement (code). One can walk through the entire program to pin point the error. But this takes much longer time to complete. Output error message appears at runtime when the code at runtime encounters problems, such as it could not find the object. This is the second hurdle for the prgrammer. Trace() function can be used to output the variable's value on screen, to assisst inspection.

Debugging Tools

In every IDE, there are usually debugging tools to help the programmer to identify bugs - the errors in the code. Usually you need to set up break points, where the program will stop and wait for your inspection when running in debugging mode. The debugging tools will report back various parameters of the running game.

In Flash, it is under Debug!

Another debugging device - trace()

trace () function will print in the output window of Flash in testing mode. This can be used to check the status of running.

Use the Compiler Error messages

This is usually the first set of error messages you will see.

In this type of errors, you will encounter frequently "undefined", "duplicate", "coercion" etc. Explain what they mean and show how you corrected them.

undefined - means you are using something that is supposed to be on the stage or have been defined, while you have not done it!

duplicate - you haev used the same thing twice - causing confusion to the CPU

conflict - interfering with the keywords of the software system,

coercion - trying to force two different types of data to be the same.

Use the output messages

 

This is an error caused at runtime - during the running of the code, there is something missing - null object. From the code below you can see the reason.

Function Testing

Is to test the code if it functions properly. This applies to even a few lines of code. The programmer needs to make sure it works before moving on. This is usually a white box testing, walk through the code if necessary to ensure it works.

 

Module testing

When a entire module or function or class is completed, test to see if it works as intedned. This is usually a black box testing, just give the module some input and then check if the output is correct.

 

System testing

When the whole system is completed, it needs to be tested. Again usually a black box testing. Alpha test is the system test done internally inside the company. Beta test is a system test done externally, usually selected customers.

Player comments and suggestions for improvement

Ask someone in the class to test your game for you. Here is a sampel feedback form:

Name of the game   Date:  
Designer: Student A Tester Student B
Good points
1  
2  
Could be improved or Must be improved
1  
2  
3  

 

Consider the feedback from testers and your own refelction, write down five suggestions for improvement. (No need to carry them out.)

 

 

Good Naming Habbit

not to break the rules - not to start a variable name with a number, dash, or other symbols. No space in between. May use underscore.

use meaningful names: "numOfLivesLeft", "numLives", etc. Not just "num", or even "life"

use CamelHumps: lower case to start, then CapitalLetterToStartEachWordAfterwards,

Indenting the code

This will make reading the code less troublesome! You will know what I mean when you have to read a whole page of code to find out where the missing"}" should go.indenting

Commenting

Create a line of comment using "//" (see the image above)

Create a block of comment using "/* ...... */"

commenting

Gather all global variables together (M1, D2)

By placing them together, the code is easier to maintain.

A variable is a container that holds the values of something that changes. You use it keep track of things going on in the game, such as score, remaining life and the number of bricks left or removed.

You need to declare it first before using in ActionScript 3.0 as in many other languages. For example, var score : Number = 0;

A global variable is one that can be used by any part of the program, therefore it must declared outside any functions. For example,

var score :Number = 0; //global variable

//go and collect all the GLOBAL variables and place them in one area
function calculateScore( ) {
		var score2 :Number = 0; //a local variable
		score2 =100;
		score =100;
}
function displayScore( ){
		scoreDisplay.text =String(score); //this will work
		scoreDisplay.text =String(score2); //this will NOT work, an error message will pop up
}

Why is it necessary to declare and initialise variables?

Modular

Place code into different functions, if necessary in different classes. This way they can be called from different places. They can be reused easily.

 

Evidence of P4

This is to prove that you have designed the game. The graphics (screenshots) should be annotated and the code should be commented thoroughly before listing.

Part 1

The above is for the first frame's graphics and relevant code.

 

 

M1 Using Selection and Iteration methdos

When the ball is placed around y=360, the following code produces a funny problem. deltaD =5; Explain why.

function startAnimation(evt:Event){
         myFootball.y += deltaD;
         // myFootball.x+=deltaD;
         if(myFootball.y<=0){
         	deltaD=-deltaD;
		  }else if(myFootball.y>=320){
         	deltaD=-deltaD;
		  }
         trace(myFootball.y);
}

//change 320 into 370 and see what happens

Here, the use of selection method IF is the evidence of meeting M1 criterion.