Changeset 5515

Show
Ignore:
Timestamp:
01/25/08 23:00:37 (5 years ago)
Author:
mokehehe
Message:

描画を共通化
画面の左右をループさせてみる

Location:
lang/actionscript/misc/mario
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/misc/mario/Actor.as

    r5472 r5515  
    11package { 
    22//============================================================================= 
     3import The; 
     4 
    35public class Actor { 
    46        public var x: int; 
     
    68        public var vx: int; 
    79        public var vy: int; 
     10 
     11        public var chr: int;                            ///< キャラ 
    812 
    913        public var hitofsx: int;                        ///< 当たり判定開始左上座標 
     
    1923        } 
    2024 
     25        // 更新処理 
    2126        public function update(): Boolean { return false; } 
    22         public function render(g: JGraphics): void { } 
     27 
     28        // 描画 
     29        public function render(g: JGraphics): void { 
     30                g.drawImage(The.resmgr.img[chr], x/The.ONE, y/The.ONE); 
     31        } 
    2332} 
    2433//============================================================================= 
  • lang/actionscript/misc/mario/Bar.as

    r5472 r5515  
    88 
    99public class Bar extends Actor { 
    10         private var chr: int; 
    11  
    1210        public function Bar(_x: int, _y: int) { 
    1311                x = _x * The.ONE; 
     
    2826                return true; 
    2927        } 
    30  
    31         // 描画 
    32         override public function render(g: JGraphics): void { 
    33                 g.drawImage(The.resmgr.img[chr], x/The.ONE, y/The.ONE); 
    34         } 
    3528} 
    3629//============================================================================= 
  • lang/actionscript/misc/mario/KeyState.as

    r5237 r5515  
    4747                                code = D; 
    4848                                break; 
    49                         case 0x5a:                              // 'Z' 
     49                        case 0x5a: case 32:     // 'Z', ' ' 
    5050                                code = A; 
    5151                                break; 
  • lang/actionscript/misc/mario/Makefile

    r5237 r5515  
    22PROJECT=Mario 
    33 
    4 all: 
     4SRCS =  $(wildcard *.as) 
     5 
     6all:    $(PROJECT).swf 
     7 
     8$(PROJECT).swf: $(SRCS) 
    59        mxmlc -incremental=true -default-size 256 240 -default-frame-rate=60 -default-background-color=0x000000 $(PROJECT).as 
    610 
  • lang/actionscript/misc/mario/Map.as

    r5472 r5515  
    11package { 
    22//============================================================================= 
     3import The; 
     4 
    35public class Map { 
     6        private static const MX: int = The.SCREEN_WIDTH / The.BLOCKW; 
     7        private static const MY: int = The.SCREEN_HEIGHT / The.BLOCKH; 
     8 
    49        public var map: Array   = [ 
    510                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     
    1419                 0, 0, 0, 0, 0, 0, 2, 4, 2, 4, 2, 0, 0, 0, 0, 0, 
    1520                 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    16                  0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 
    17                  0, 7, 8,10, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 
    18                  1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 
    19                  1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 
     21                 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     22                 0, 7, 8,10, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     23                 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 
     24                 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 
    2025        ]; 
    2126 
    2227        /// マップのキャラ取得 
    2328        public function get_chr(x: int , y: int): int { 
    24                 return map[x + y * 16]; 
     29                if (x < 0)              x = 0; 
     30                if (x >= MX)    x = MX - 1; 
     31                return map[x + y * MX]; 
    2532        } 
    2633 
    2734        /// マップにキャラセット 
    2835        public function set_chr(x: int , y: int, c: int): void { 
    29                 map[x + y * 16] = c; 
     36                map[x + y * MX] = c; 
    3037        } 
    3138 
     
    3340        public function render(g: JGraphics): void { 
    3441                var resmgr: ResourceManager = The.resmgr; 
    35                 for (var i: Number = 0; i < 16; ++i) { 
    36                         var y: int = i * 16; 
    37                         for (var j: Number = 0; j < 16; ++j) { 
     42                for (var i: Number = 0; i < MY; ++i) { 
     43                        var y: int = i * The.BLOCKH; 
     44                        for (var j: Number = 0; j < MX; ++j) { 
    3845                                var c: int = get_chr(j, i); 
    3946                                if (c != The.eChrEmpty && c != The.eChrEmptyBlock) { 
    40                                         var x: int = j * 16; 
     47                                        var x: int = j * The.BLOCKW; 
    4148                                        g.drawImage(resmgr.img[c], x, y); 
    4249                                } 
  • lang/actionscript/misc/mario/Mario.as

    r5472 r5515  
    8585        private function render(): void { 
    8686                //背景の描画 
    87                 g.setColor(RGB(0, 0, 0)); 
     87                g.setColor(RGB(40,145,255)); 
    8888                g.fillRect(0, 0, The.SCREEN_WIDTH, The.SCREEN_HEIGHT); 
    8989 
  • lang/actionscript/misc/mario/Player.as

    r5472 r5515  
    88 
    99public class Player extends Actor { 
    10         private var chr: int;                                   ///< キャラ 
    1110        private var dir: int;                                   ///< 向き 
    1211        private var step: int;                                  ///< アニメカウンタ 
     
    9695                        if (vy > 0) { 
    9796                                if (is_ground(0)) { 
    98 //                                      y = The.SCREEN_HEIGHT * The.ONE; 
    9997                                        vy = 0; 
    10098                                        stand = true; 
     
    124122                } 
    125123 
    126                 if (x < (The.ChrW/2)*The.ONE) { 
    127                         x = (The.ChrW/2)*The.ONE; 
    128                         if (!stand) { 
    129                                 vx = 0; 
    130                         } 
    131                 } 
    132                 if (x > (The.SCREEN_WIDTH-The.ChrW/2)*The.ONE) { 
    133                         x = (The.SCREEN_WIDTH-The.ChrW/2)*The.ONE; 
    134                         if (!stand) { 
    135                                 vx = 0; 
     124                if (false) { 
     125                        if (x < (The.ChrW/2)*The.ONE) { 
     126                                x = (The.ChrW/2)*The.ONE; 
     127                                if (!stand) { 
     128                                        vx = 0; 
     129                                } 
     130                        } 
     131                        if (x > (The.SCREEN_WIDTH-The.ChrW/2)*The.ONE) { 
     132                                x = (The.SCREEN_WIDTH-The.ChrW/2)*The.ONE; 
     133                                if (!stand) { 
     134                                        vx = 0; 
     135                                } 
     136                        } 
     137                } else { 
     138                                // 左右ループ 
     139                        if (x < -(The.ChrW/2)*The.ONE) { 
     140                                x = (The.SCREEN_WIDTH+The.ChrW/2-1)*The.ONE; 
     141                        } 
     142                        if (x > (The.SCREEN_WIDTH+The.ChrW/2)*The.ONE) { 
     143                                x = (-The.ChrW/2+1)*The.ONE; 
    136144                        } 
    137145                } 
  • lang/actionscript/misc/mario/ResourceManager.as

    r5472 r5515  
    99        [Embed(source='data/block3.png')]       private static const ImgBlock3: Class; 
    1010        [Embed(source='data/block4.png')]       private static const ImgBlock4: Class; 
    11         [Embed(source='data/block5.gif')]       private static const ImgBlock5: Class; 
     11        [Embed(source='data/block5.png')]       private static const ImgBlock5: Class; 
    1212 
    1313        [Embed(source='data/mountain02.png')]   private static const ImgMountain02: Class; 
     
    3535        [Embed(source='data/image_14.png')]     private static const ImgPanel14: Class; 
    3636 
    37         [Embed(source='data/bar.gif')]          private static const ImgBar: Class; 
     37        [Embed(source='data/bar.png')]          private static const ImgBar: Class; 
    3838 
    3939        public var b_complete: String; 
     
    7676        ]; 
    7777 
    78         [Embed(source='data/main.mp3')]                 private static const SoundBgm: Class; 
     78//      [Embed(source='data/main.mp3')]                 private static const SoundBgm: Class; 
    7979//      [Embed(source='data/jump.wav')]                 private static const SoundJump: Class; 
    8080 
    8181        private var snd_tbl: Array = [ 
    82                 SoundBgm, 
     82//              SoundBgm, 
    8383        ]; 
    8484 
  • lang/actionscript/misc/mario/UnbrokenBlock.as

    r5472 r5515  
    1010 
    1111public class UnbrokenBlock extends Actor { 
    12         private var chr: int; 
    1312        private var mx: int; 
    1413        private var my: int; 
     
    3635                return true; 
    3736        } 
    38  
    39         // 描画 
    40         override public function render(g: JGraphics): void { 
    41                 g.drawImage(The.resmgr.img[chr], x/The.ONE, y/The.ONE); 
    42         } 
    4337} 
    4438//=============================================================================