Kamis, 11 Agustus 2011

12-Pas-12-Pas-an

// Eksekusi 12 Pas
002// A game by: F4154LMAN
003 
004mulai();
005 
006function mulai()
007{
008    var tenaga:Number = new Number();
009    var posisiPemain:Number = new Number();
010    var PosisiGerakKiper:Number = new Number();
011    var PosisiBolaSemula:Number = new Number();
012    var listenerKey:Object = new Object();
013 
014    attachSetScaleDanXY("kiperID", "kiper", 70, 330, 160, this.getNextHighestDepth());
015    attachSetScaleDanXY("bolaID", "bola", 100, 150, 315, this.getNextHighestDepth());
016    attachSetScaleDanXY("pemainID", "pemain", 100, 85, 300, this.getNextHighestDepth());
017 
018    bola.gotoAndStop("frameBiasa");
019    keterangan.gotoAndStop("frameAwal");
020 
021    keterangan.onRelease = function()
022    {
023        removeMovieClip("pemain");
024        removeMovieClip("bola");
025        removeMovieClip("kiper");
026        mulai();
027    }
028 
029    listenerKey.onKeyDown = function()
030    {
031            posisiPemain = pemain._x;
032 
033            if(((kiper._x - 200) - posisiPemain) > 50)
034            {
035                posisiGerakKiper = -5;
036            }
037            else if(((kiper._x - 200) - posisiPemain) < -50)
038            {
039                posisiGerakKiper = 5;
040            }
041            else
042            {
043                posisiGerakKiper = 0;
044            }
045 
046            kiper._x += posisiGerakKiper;
047 
048            if(Key.isDown(Key.LEFT))
049            {
050                pemain._x -= 10;
051            }
052 
053            if(Key.isDown(Key.RIGHT))
054            {
055                pemain._x += 10;
056            }
057 
058            if(pemain._x < 50 || pemain._x > 200)
059            {
060                pemain._x = posisiPemain;
061            }
062 
063            if(Key.isDown(Key.SPACE))
064            {
065                tenaga = (Math.floor(Math.random() * (9)) + 6) * 10;
066                bolaDitendang();
067            }
068    }
069    Key.addListener(listenerKey);
070 
071    function attachSetScaleDanXY(id:String, namaBaru:String, skala:Number, xx:Number, yy:Number, depth:Number)
072    {
073        attachMovie(id, namaBaru, depth);
074        setProperty(namaBaru, _xscale, skala)
075        setProperty(namaBaru, _yscale, skala)
076        setProperty(namaBaru, _x, xx);
077        setProperty(namaBaru, _y, yy);
078    }
079 
080    function bolaDitendang()
081    {
082        delete listenerKey.onKeyDown;
083        posisiBolaSemula = bola._y;
084 
085        bola.onEnterFrame = function()
086        {
087            if(kiper._x - bola._x > 10)
088            {
089                posisiGerakKiper = -20;
090            }
091            else if(kiper._x - bola._x < -10)
092            {
093                posisiGerakKiper = 20;
094            }
095            else
096            {
097                posisiGerakKiper = 0;
098            }
099 
100            kiper._x += posisiGerakKiper;
101            kiper._rotation += posisiGerakKiper / 2;
102 
103            if(tenaga > 90)
104            {
105                kiper._y -= 1;
106            }
107 
108            bola._y -= tenaga / 10;
109            bola._x += (tenaga / 10) - ((posisiPemain - 150) / 10);
110 
111            setProperty(bola, _xscale, getProperty(bola, _y) / posisiBolaSemula * 100);
112            setProperty(bola, _yscale, getProperty(bola, _y) / posisiBolaSemula * 100);
113 
114            if((posisiBolaSemula - bola._y) > (tenaga * 2))
115            {
116                delete bola.onEnterFrame;
117                if(bola.hitTest(kiper.tangkapan))
118                {
119                    keterangan.gotoAndStop("frameBlocked");
120                    bola.gotoAndStop("frameKena");
121                }
122                else if((bola._x > 200) && (bola._x < 500) && (bola._y > 60) && (bola._y < 200))
123                {
124                    keterangan.gotoAndStop("frameGol");
125                }
126                else
127                {
128                    keterangan.gotoAndStop("frameOut");
129                }
130            }
131        }
132    }
133}

Tidak ada komentar:

Posting Komentar