In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

次々出題される掛け算を3カウント以内に淡々ととくゲーム

Get Adobe Flash player
by kuma360 02 Aug 2010
    Embed
/**
 * Copyright kuma360 ( http://wonderfl.net/user/kuma360 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bVSR
 */

package  
{
    import com.bit101.components.*;
    import flash.display.*;
    import flash.events.*;
    import flash.filters.*;
    import net.wonderfl.score.basic.*;
    
    
    
    [SWF ( backgroundColor= "0xFFFFFF") ];
    public class Main extends Sprite
    {
        public static var _ANS:int = 0 ;
        public static var _RES:int = 0 ;
        
        public function Main() 
        {
            /////////////////////
            Component.initStage ( stage ) ;    
            
            
            //ぼかし用
            var C:BitmapData = new BitmapData ( 465 , 465 , false , 0xFFFFFF ) ;
            var B:Bitmap = new Bitmap ( C ) ;
            addChild ( B ) ;
            
            
            //問題とか選択肢とか
            var OO:Sprite = new Sprite ;
            var O1:Message = new Message ( ) ;
            var O2:Button = new Button ( 20 , 300 ) ;
            var O3:Button = new Button ( 170 , 300 ) ;
            var O4:Button = new Button ( 320 , 300 ) ;
            var O5:Count = new Count ( ) ;
            var O6:Judge = new Judge ( ) ;
            var O7:Gametimer = new Gametimer ( ) ;
            OO.addChild ( O1 ) ;
            OO.addChild ( O2 ) ;
            OO.addChild ( O3 ) ;
            OO.addChild ( O4 ) ;
            OO.addChild ( O5 ) ;
            OO.addChild ( O6 ) ;
            OO.addChild ( O7 ) ;
            addChild ( OO ) ;
            
            
            //メインループ
            var SCORE:int = 0 ;
            var SCENE:int = 0 ;
            var NEXT:Boolean = false ;
            addEventListener (
                Event.ENTER_FRAME ,
                function ():void 
                {
                    //タイトル画面
                    if ( SCENE == 0 ) {
                        O1.title ( ) ;
                        addEventListener (
                            MouseEvent.CLICK ,
                            function ( e:MouseEvent ) :void {
                                removeEventListener ( MouseEvent.CLICK , arguments.callee ) ;
                                SCENE = 1 ;
                                SCORE = 0 ;
                                O5.init ( ) ;
                            }
                        );
                    }
                    
                    //スタート待ち
                    if ( SCENE == 1 ) {
                        
                        O5.update ( ) ;
                        
                        if ( O5.chk ( ) == false ) {
                            SCENE = 2 ;
                            NEXT = true ;
                            O7.init ( ) ;
                        }
                        
                    }
                    
                    //ゲーム中
                    if ( SCENE == 2 ) {
                        
                        O5.update ( ) ;
                        
                        O7.update ( ) ;
                        if ( O7.chk ( ) ) {
                            
                            NEXT = false ;
                            SCENE = 3 ;
                            
                        }
                        
                        //正答、誤答
                        if ( NEXT == false ) {
                            
                            if ( _ANS == _RES ) {
                                
                                ++ SCORE ;
                                O6.update ( true ) ;
                                NEXT = true ;
                                
                            } else if ( O5.chk ( ) == false ) {
                                
                                O6.update ( false ) ;
                                NEXT = true ;
                                
                            }
                            
                        }
                        
                    }
                    
                    //スコアランキング
                    if ( SCENE == 3 ) {
                        
                        SCENE = 4 ;
                        
                        var FORM:BasicScoreForm = new BasicScoreForm (
                            stage,
                            100,
                            100,
                            SCORE ,
                            "SAVE SCORE" ,
                            function ( $didSavedScore:Boolean ) :void {
                                stage.removeChild ( FORM ) ;
                                var FORM2:BasicScoreRecordViewer = new BasicScoreRecordViewer (
                                    stage,
                                    100,
                                    100 ,
                                    "RANKING" ,
                                    50 ,
                                    true ,
                                    function ( ) :void {
                                        stage.removeChild ( FORM2 ) ;
                                        SCENE = 0 ;
                                        O1.end ( ) ;
                                        O2.end ( ) ;
                                        O3.end ( ) ;
                                        O4.end ( ) ;
                                        O5.end ( ) ;
                                        O6.end ( ) ;
                                        O7.end ( ) ;
                                    }
                                ) ;
                            }
                        );
                        
                    }
                    
                    //ランキング入力待ち
                    if ( SCENE == 4 ) {
                    }
                    
                    //次の問題
                    if ( NEXT ) {
                        
                        NEXT = false ;
                        
                        var Q1:int = 0 ;
                        var Q2:int = 0 ;
                        var A1:int = 0 ;
                        var A2:int = 0 ;
                        var A3:int = 0 ;
                            
                        do {
                            
                            Q1 = Math.floor ( Math.random ( ) * 9 ) + 1 ;
                            Q2 = Math.floor ( Math.random ( ) * 9 ) + 1 ;
                            
                            _ANS = Q1 * Q2 ;
                            A1 = _ANS + Math.random ( ) * 20 - 10 ;
                            A2 = _ANS + Math.random ( ) * 20 - 10 ;
                            A3 = _ANS + Math.random ( ) * 20 - 10 ;
                            
                            switch ( Math.floor ( Math.random ( ) * 3 ) ) {
                                case 0 : A1 = _ANS ; break ;
                                case 1 : A2 = _ANS ; break ;
                                case 2 : A3 = _ANS ; break ;
                            }
                            
                        } while ( A1 == A2 || A2 == A3 || A3 == A1 ) ;
                            
                        O1.update ( Q1 , Q2 ) ;
                        O2.update ( A1 ) ;
                        O3.update ( A2 ) ;
                        O4.update ( A3 ) ;
                        _RES = 0 ;
                        
                        O5.init ( ) ;
                        
                    }
                    
                    //ぼかす
                    C.fillRect ( C.rect , 0xFFFFFF ) ;
                    C.draw ( OO ) ;
                    B.filters = [ new BlurFilter ( 60 , 60 , 4 ) ] ;
                    
                }
            ) ;
            
        }
        
    }

}
import caurina.transitions.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;

//問題
class Message extends Sprite {
    
    private var TF:TextField = new TextField ;
    
    public function Message ( ) :void {
        
        TF.width = 465 ;
        TF.height = 90 ;
        addChild ( TF ) ;
        
        this.x = 0 ;
        this.y = 50 ;
        
    }
    
    public function update ( val1:int , val2:int ):void {
        
        TF.htmlText = "<p align='center'><font face='_sans' size='90'>" + val1 + "×" + val2 + "</font></p>";
        
    }
    
    public function end ( ) :void {
        TF.htmlText = "" ;
    }
    
    public function title ():void {
        
        TF.htmlText = "<p align='center'><font face='_sans' size='10'>次々出題される掛け算を3カウント以内に淡々ととくゲーム</font></p>";
        
    }
}

//選択肢
class Button extends Sprite {
    
    private var TF:TextField = new TextField ;
    private var _RESVAL:int = 0 ;
    
    public function Button ( x:int , y:int ) :void {
        
        var G:Graphics = this.graphics ;
        G.lineStyle ( 1, 0xBBBBBB );
        G.beginFill ( 0xEEEEEE );
        G.drawRoundRect( 0, 0, 100, 40, 10, 10 );
        G.endFill();
        
        TF.width = 100 ;
        TF.height = 40 ;
        addChild ( TF ) ;
        
        this.x = x ;
        this.y = y ;
        this.mouseChildren = false;
        this.buttonMode = true;
        
        this.addEventListener (
            MouseEvent.CLICK ,
            function ( e:MouseEvent ):void {
                Main._RES = _RESVAL ;
            }
        );
        
    }
    
    public function update ( val:int ) :void {
        
        TF.htmlText = "<p align='center'><font face='_sans' size='30'>" + val + "</font></p>";
        _RESVAL = val ;
            
    }
    
    public function end ( ) :void {
        TF.htmlText = "" ;
        _RESVAL = 0 ;
    }
    
}

//時間
class Count extends Sprite {
    
    private var TF:TextField = new TextField ;
    private var _cnt:int = 0 ;
    private var _time:int = 0 ;
    
    
    public function Count ( ) :void {
        
        TF.width = 465 ;
        TF.height = 30 ;
        addChild ( TF ) ;
        
        this.x = 0 ;
        this.y = 150 ;
        
        init ( ) ;
        
    }
    
    public function init ( ) :void {
        
        _time = getTimer ( ) ;
        _cnt = 3 ;
        
    }
    
    public function update ( ):void {
        
        TF.htmlText = "<p align='center'><font face='_sans' size='20'>" + _cnt + "</font></p>";
        
        if ( 500 < getTimer ( ) - _time ) {
            _time = getTimer ( ) ;
            -- _cnt ;
        }
        
    }
    
    public function chk ( ) :Boolean {
        return ( 0 < _cnt ) ;
    }
    
    public function end ( ) :void {
        TF.htmlText = "" ;
        _cnt = 0 ;
        _time = 0 ;
    }
    
}

//○×
class Judge extends Sprite {
    
    private var TF:TextField = new TextField ;
    
    public function Judge ( ) :void {
        
        TF.width = 465 ;
        TF.height = 90 ;
        addChild ( TF ) ;
        
        this.x = 0 ;
        this.y = 200 ;
        
    }
    
    public function update ( type:Boolean ):void {
        
        if ( type ) {
            TF.htmlText = "<p align='center'><font face='_sans' size='90' color='#FF0000'>○</font></p>";
        } else {
            TF.htmlText = "<p align='center'><font face='_sans' size='90' color='#0000FF'>×</font></p>";
        }
        
        this.scaleY = 5 ;
        Tweener.addTween ( this , { scaleX:1 , scaleY:1 , time:.5 } ) ;
        
    }
    
    public function end ( ) :void {
        TF.htmlText = "" ;
    }
    
}

//総時間
class Gametimer extends Sprite {
    
    private var _time:uint = 0 ;
    
    public function init ( ) :void {
        _time = getTimer ( ) ;
    }
    
    public function update ( ) :void {
        
        var G:Graphics = graphics ;
        G.clear ( ) ;
        G.beginFill ( 0x00FF00 , 1 ) ;
        
        var V:int = 445 * ( 30000 - ( getTimer ( ) - _time ) ) / 30000 ;
        if ( V < 0 ) {
            V = 0 ;
        }
        
        G.drawRect ( 10 , 10 , V , 10 ) ;
        G.endFill ( ) ;
        
    }
    
    public function chk ( ) :Boolean {
        return ( 30000 <  getTimer ( ) - _time ) ;
    }
    
    public function end ( ) :void {
        _time = 0 ;
    }
    
}