aLLVAr

Kamis, 08 April 2010

TUGAS Pengantar Teknologi Game MINGGU KE-8 dan KE-9

coding :
//asdfaf
var solution:Number;
var problems:Number;
var starreset:Number=0;
var problem:String;
var questions:Number=15;
var games:Number=0;
var cumul:Number=0;
var skilltitle:String="Welcome.";

var alevel1points:Number=0;
var alevel2points:Number=0;
var alevel3points:Number=0;
var alevel4points:Number=0;


var mlevel1points:Number=0;
var mlevel2points:Number=0;
var mlevel3points:Number=0;
var mlevel4points:Number=0;

var pracpoints:Number=0;

var alevel1best:Array=new Array();
var alevel2best:Array=new Array();
var alevel3best:Array=new Array();
var alevel4best:Array=new Array();

var mlevel1best:Array=new Array();
var mlevel2best:Array=new Array();
var mlevel3best:Array=new Array();
var mlevel4best:Array=new Array();

//lol
var tick:Number=0;


var startgame:Number=0;
var ack:Number=0;

var thetimes:Array=new Array();

//statistics
var totaltime:Number=0;
var totalquestions:Number=0;
var totalmissed:Number=0;
var totalcorrect:Number=0;
var score:Number=0;
var averagetime:Number=0;
var readtime:Number=0;
var readgoal:String;
var automiss:Number=0;

//problem array
var record:Array = new Array();
var stats:String;
var invert:String;


function makenum(max,min){
num1=(Math.round(Math.random()*(max-min)))+min;
num2=(Math.round(Math.random()*(max-min)))+min;
if (operator=="Addition"){
solution=num1+num2;
problem=num1+" + "+num2+" = ";
}
if (operator=="Substraction"){
solution=num1-num2;
problem=num1+" - "+num2+" = ";
}
if (operator=="Multiplication"){
solution=num1*num2;
problem=num1+" x "+num2+" = ";
}
if (operator=="Division"){
solution=Math.floor((num1/num2)*1000)/1000;
problem=num1+"/"+num2+" = ";
}
}


function makeblackness(){
var blackness:MovieClip = this.createEmptyMovieClip("blackness", this.getNextHighestDepth());
blackness.beginFill(0xFFCC99, 100);
blackness.lineStyle(0, 0xFFCC99, 100);
blackness.moveTo(0, 0);
blackness.lineTo(1000, 0);
blackness.lineTo(1000, 1000);
blackness.lineTo(0,1000);
blackness.lineTo(0, 0);
blackness.endFill();
}
makeblackness();

blackness._x=161;
blackness._y=0
this.attachMovie("intro","intro1",this.getNextHighestDepth());
intro1._x=200;
intro1._y=20;




function restart(){
removeMovieClip(blackness);
removeMovieClip(intro1);
problems1.text=problems2.text;
totalquestions=problems2.text;
problems=problems2.text;
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0x000000;
my_fmt.size = 40;
my_fmt.bold = true;
problems1.setTextFormat(my_fmt);
answer.text="";
stats="";
invert="";
methread=0;
problems=totalquestions;
totaltime=0;
totalmissed=0;
totalcorrect=0;
meter._width=2;
score=0;
best="";
this[varname1+"best"].sortOn("time", Array.ASCENDING | Array.NUMERIC);
for(i=0; ibest+=this[varname1+"best"][i].avgtime+" | "+this[varname1+"best"][i].time+"\n";
}
ack=0;
startgame=1;
averagetime=0;
readtime=0;
record=new Array();
Selection.setFocus(answer);
}

function game(thetitle,varname,times,min1,max1){
thetimes=times;
startgame=1;
thetitle1=thetitle;
problems=questions;
varname1=varname;
blah=this[varname+"points"];
timelimit=thetimes[blah]*1000;
readgoal=thetimes[blah]+" S";
min=min1;
max=max1;
totalquestions=problems;
//clear
restart();
}




onEnterFrame=function(){


if (tick==1){
mySound = new Sound();
mySound.attachSound("tick");
mySound.start(0, 1);
tick=0;
}

if (answer.text=="e"){
restart();
startgame=1;
ack=1;
answer.text="";
makenum(min,max);
startTime=getTimer();
}

if ((startgame==1) && (ack==0)){
problem="Type 1 to Start";
if (int(answer.text)==1){
ack=1;
makenum(min,max);
startTime=getTimer();
answer.text="";
}
}

function nextquestion(){
totaltime+=meth;
readtime=totaltime/1000;
score=Math.round(100*(totalcorrect/(totalcorrect+totalmissed)));
recore=Math.round(meth/100);
recore=recore/10;
prob=totalquestions-problems+1;
record.push({num:prob,time:recore,problem:problem+solution});
stats1.text="";
invert="";
averagetime=Math.round((totaltime/totalquestions)/10);
averagetime=averagetime/100;
record.sortOn("time", Array.ASCENDING | Array.NUMERIC);
for(i=0; istats1.text+="#"+record[i].num+". "+record[i].time + " Seconds\n(" + record[i].problem+")\n";
}
//record.sortOn("time", Array.DESCENDING | Array.NUMERIC);
record.reverse();
for(i=0; iinvert+="#"+record[i].num+". "+record[i].time + " Seconds\n(" + record[i].problem+")\n";
}
answer.text="";
problems--;
makenum(min,max);
problems1.text=problems;
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0x000000;
my_fmt.size = 40;
my_fmt.bold = true;
problems1.setTextFormat(my_fmt);
}

if ((startgame==1) && (ack==1)){
meth=getTimer()-startTime;
methread=Math.round(meth/100);
methread=methread/10;
if (methread<.25){
answer.text="";
}

meter._width=131*(meth/timelimit);
if (meter._width>129){
meter._width=130;
}


if (answer.text==solution){
totalcorrect++;
nextquestion();
startTime=getTimer();
tick=1;
}





if ((automiss==1) && (meter._width==130)){
totalmissed++;;
nextquestion();
startTime=getTimer();
tick=1;
}








if ((startgame==1) && (problems==0)){



//real end
games++;
problem="End";
startgame=0;
totaltime=totaltime/1000;
best="";
if (totalmissed==0){
averagetime1=averagetime;
this[varname1+"best"].push({time:totaltime,avgtime:averagetime});
this[varname1+"best"].sortOn("time", Array.ASCENDING | Array.NUMERIC);
for(i=0; ibest+=this[varname1+"best"][i].avgtime+" Avg "+this[varname1+"best"][i].time+" T\n";

if (starreset==0){
if (i==0){
if (this[varname1+"best"][i].avgtimeaveragetime1=this[varname1+"best"][i];
}
}
}
}

if (averagetime1this[varname1+"points"]=1;
}
if (averagetime1this[varname1+"points"]=2;
}
if (averagetime1this[varname1+"points"]=3;
}
if (averagetime1this[varname1+"points"]=4;
}
if (averagetime1this[varname1+"points"]=5;
}
if (averagetimethis[varname1+"points"]=6;
}
if (averagetime1this[varname1+"points"]=7;
}
if (averagetime1this[varname1+"points"]=8;
}
if (averagetime1this[varname1+"points"]=9;
}
if (averagetime1this[varname1+"points"]=10;
}
shape.gotoAndStop(3);
shape.gotoAndStop(1);

cumul=alevel1points+alevel2points+alevel3points+alevel4points+mlevel1points+mlevel2points+mlevel3points+mlevel4points;

if (cumul<7){
skilltitle="Average. 1/1 People";
}

if ((cumul>=7) && (cumul<20)){
skilltitle="Motivated. 1/50 People";
}

if ((cumul>=20) && (cumul<30)){
skilltitle="Metally Disciplined. 1/1,000 People";
}


if ((cumul>=30) && (cumul<45)){
skilltitle="Genius. 1/10,000 People";
}

if ((cumul>=45) && (cumul<60)){
skilltitle="Awesome Genius 1/100,000 People";
}

if ((cumul>=60) && (cumul<=80)){
skilltitle="Uber. 1/10,000,000 People";
}

}
}
}




};

Tidak ada komentar:

Posting Komentar