advanced multimedia development (ammd) : : : 2004
DESCRIPTION
Advanced Multimedia Development (AMMD) : : : 2004. ActionScript & Program Design. Review – past few weeks Flash ActionScript Conditional Statements Loops Variable Type Conversion Logical Operators Project 1 Marking Scheme Program Design Simple Game: Mouse Chaser. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/1.jpg)
AdvancedMultimediaDevelopment (AMMD):::2004
![Page 2: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/2.jpg)
• Review – past few weeks• Flash ActionScript
• Conditional Statements• Loops• Variable Type Conversion• Logical Operators
• Project 1 Marking Scheme• Program Design• Simple Game: Mouse Chaser
• Review – past few weeks• Flash ActionScript
• Conditional Statements• Loops• Variable Type Conversion• Logical Operators
• Project 1 Marking Scheme• Program Design• Simple Game: Mouse Chaser
ActionScript & Program Design
![Page 3: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/3.jpg)
• Flash Structure - Lecture
• Flash Animation Examples - Lecture• Basic ActionScript - Lecture• Storyboarding – Tutorial• Program Design – Tutorial• Lots of Flash Animation – Lab• Basic ActionScript – Lab
• Project 1 – Apply => Flash Environment• Start ActionScript Game Programming
• Flash Structure - Lecture
• Flash Animation Examples - Lecture• Basic ActionScript - Lecture• Storyboarding – Tutorial• Program Design – Tutorial• Lots of Flash Animation – Lab• Basic ActionScript – Lab
• Project 1 – Apply => Flash Environment• Start ActionScript Game Programming
Review – past few weeks
![Page 4: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/4.jpg)
Conditional Statements
The if.. else .. conditionalReal life (game) situation is full of if..else.. Situations (ask for example)
myNumber = 10;if (myNumber >20) { trace ("myNumber is greater than 20");}else{ trace("myNumber is less than or equal to 20");}
The if.. else .. conditionalReal life (game) situation is full of if..else.. Situations (ask for example)
myNumber = 10;if (myNumber >20) { trace ("myNumber is greater than 20");}else{ trace("myNumber is less than or equal to 20");}
![Page 5: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/5.jpg)
Nested Conditional
Put if statement inside a code block associated with another if statement
myNumber = 10;if (myNumber <20){ trace("myNumber is less than 20"); if (myNumber <10) { trace("myNumber is less than 10"); }}
Put if statement inside a code block associated with another if statement
myNumber = 10;if (myNumber <20){ trace("myNumber is less than 20"); if (myNumber <10) { trace("myNumber is less than 10"); }}
![Page 6: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/6.jpg)
Conditional - Switch
The switch statementA elegant way to string together a series of if ..
MyNumber = 2;switch (MyNumber) {case 1 :
trace("case 1 tested true");break;
case 2 :trace("case 2 tested true");break;
case 3 :trace("case 3 tested true");break;
default :trace("no case tested true");
}
The switch statementA elegant way to string together a series of if ..
MyNumber = 2;switch (MyNumber) {case 1 :
trace("case 1 tested true");break;
case 2 :trace("case 2 tested true");break;
case 3 :trace("case 3 tested true");break;
default :trace("no case tested true");
}
![Page 7: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/7.jpg)
Loops – while Loop
Real life (game) situation is full of while loops (ask for example)
myNumber = 1;while (myNumber<10) { trace(myNumber); myNumber++;}
Real life (game) situation is full of while loops (ask for example)
myNumber = 1;while (myNumber<10) { trace(myNumber); myNumber++;}
![Page 8: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/8.jpg)
Loops – for Loop
for loop is a variation on the while loop
for (myNumber=0; myNumber<10; myNumber=myNumber+1) {
trace(myNumber);}
for loop is a variation on the while loop
for (myNumber=0; myNumber<10; myNumber=myNumber+1) {
trace(myNumber);}
![Page 9: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/9.jpg)
Variable Type Conversion
When a variable of one type is used where a variable of a different type is expected, Flash does an automatic type conversion.
Example: non-zero = true, 0 to falseNumber to Boolean
if (-102.4) trace ("this will print");if (50326) trace ("this will print");if (0) trace ("this will NOT print");
When a variable of one type is used where a variable of a different type is expected, Flash does an automatic type conversion.
Example: non-zero = true, 0 to falseNumber to Boolean
if (-102.4) trace ("this will print");if (50326) trace ("this will print");if (0) trace ("this will NOT print");
![Page 10: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/10.jpg)
Variable Type Conversion
Flash does an automatic type conversion.
Number to String
myResult1="Hello" + 532.8;myResult2=-4982 + "hello" + 32.6;trace(myResult1);trace(myResult2);
Flash does an automatic type conversion.
Number to String
myResult1="Hello" + 532.8;myResult2=-4982 + "hello" + 32.6;trace(myResult1);trace(myResult2);
![Page 11: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/11.jpg)
Logical Operators
AND Operator => &&OR Operator => ||NOT Operator => !
myNumber = 25;if (myNumber >= 20 && myNumber <=30){ trace("in range");}
myNumber = 35;if (myNumber < 20 || myNumber >30){ trace("out of range");}
AND Operator => &&OR Operator => ||NOT Operator => !
myNumber = 25;if (myNumber >= 20 && myNumber <=30){ trace("in range");}
myNumber = 35;if (myNumber < 20 || myNumber >30){ trace("out of range");}
![Page 12: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/12.jpg)
Logical Operators Precedence
&& has higher precedence than ||, so all && will be evaluated first
trace (true && false || true && true);trace (true || false && true || true);trace (true && true && true || true);trace (true || false && false);
&& has higher precedence than ||, so all && will be evaluated first
trace (true && false || true && true);trace (true || false && true || true);trace (true && true && true || true);trace (true || false && false);
![Page 13: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/13.jpg)
Project 1
Submission will be next week lab session
Marking Scheme (minor changes)
Show example again
Submission will be next week lab session
Marking Scheme (minor changes)
Show example again
![Page 14: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/14.jpg)
Program Design
A program is a set of instructions written so the computer can follow them.
Program Development Cycle
It is about planning… Poor planning is damaging Planning saves time Good program design makes coding simple Cool…
A program is a set of instructions written so the computer can follow them.
Program Development Cycle
It is about planning… Poor planning is damaging Planning saves time Good program design makes coding simple Cool…
![Page 15: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/15.jpg)
Program Development Cycle
Review the specificationInformal Design
List major tasksList subtasks, sub-subtasks, so on
Formal DesignCreate formal design from tasks listDesk check design
Code and compile programTest and Debug the programUse and maintain the program
Review the specificationInformal Design
List major tasksList subtasks, sub-subtasks, so on
Formal DesignCreate formal design from tasks listDesk check design
Code and compile programTest and Debug the programUse and maintain the program
![Page 16: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/16.jpg)
Mouse Chaser
Show game Mouse ChaserThe Coordinates SystemShow game Mouse ChaserThe Coordinates System
•0,0
•0, MaxY
•MaxX, 0
•MaxX, MaxY
•+ X
•+ Y
![Page 17: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/17.jpg)
Mouse Chaser
Review the specificationInformal Design
List major tasksList subtasks, sub-subtasks, so on
Formal DesignCreate formal design from tasks listDesk check design
Code and compile programTest and Debug the programUse and maintain the program
Review the specificationInformal Design
List major tasksList subtasks, sub-subtasks, so on
Formal DesignCreate formal design from tasks listDesk check design
Code and compile programTest and Debug the programUse and maintain the program
![Page 18: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/18.jpg)
Mouse Chaser
Review the specificationIdeaWrite design documentetc…
Not to cover for this lectureThis lecture shows…
List major tasksList subtasks, sub-subtasks, so on…Coding
Review the specificationIdeaWrite design documentetc…
Not to cover for this lectureThis lecture shows…
List major tasksList subtasks, sub-subtasks, so on…Coding
![Page 19: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/19.jpg)
Mouse Chaser
Major Tasks• Obtain Art• Script Organization• Bat chases (follows) the user’s mouse pointer, If Bat reaches pointer, ...• Target when clicked, move randomly …
Major Tasks• Obtain Art• Script Organization• Bat chases (follows) the user’s mouse pointer, If Bat reaches pointer, ...• Target when clicked, move randomly …
![Page 20: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/20.jpg)
Mouse Chaser
Major task: Obtain ArtSubtasks:
• The critter• The critter’s home• The mouse pointer• The target• The score display
Show “mouse chaser unfinished.fla”
Major task: Obtain ArtSubtasks:
• The critter• The critter’s home• The mouse pointer• The target• The score display
Show “mouse chaser unfinished.fla”
![Page 21: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/21.jpg)
Mouse Chaser
Major task: Script OrganizationSubtasks:
• Frame 1 Frame Script to control the game• Instance Scripts attached to instances• Develop line of communication between different pieces of scripts
Show “mouse chaser.fla” the finished file’s code structure
Major task: Script OrganizationSubtasks:
• Frame 1 Frame Script to control the game• Instance Scripts attached to instances• Develop line of communication between different pieces of scripts
Show “mouse chaser.fla” the finished file’s code structure
![Page 22: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/22.jpg)
Mouse Chaser
Major tasks: Bat chases the user’s mouse pointerSubtasks
• Move the bat• Test to see if the bat has caught the mouse• If the mouse has been caught,
• test for a high score• reset the score• reset the speed• move the bat home
Show “mouse chaser major 1.fla”
Major tasks: Bat chases the user’s mouse pointerSubtasks
• Move the bat• Test to see if the bat has caught the mouse• If the mouse has been caught,
• test for a high score• reset the score• reset the speed• move the bat home
Show “mouse chaser major 1.fla”
![Page 23: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/23.jpg)
Mouse Chaser
Major tasks: Target when clicked, move randomly Subtasks:
• Increase the score• Increase the speed• Move the bat home• Move the target randomly
Show “mouse chaser major 2.fla”
Major tasks: Target when clicked, move randomly Subtasks:
• Increase the score• Increase the speed• Move the bat home• Move the target randomly
Show “mouse chaser major 2.fla”
![Page 24: Advanced Multimedia Development (AMMD) : : : 2004](https://reader035.vdocuments.us/reader035/viewer/2022062807/56815086550346895dbe84ec/html5/thumbnails/24.jpg)
Conclusion
That’s how to start to code a gameThat’s how to start to code a game