※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!

wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)

 notice: Flash editor updated! Join the development! Thanks to MiniBuilder


FORKED
  1. // forked from clockmaker's [Alternativa3D] Maze
  2. /**
  3. * Alternativa3D Maze Demo
  4. * W,S,A,D+Spaceで移動
  5. * ドラッグで方向回転
  6. * 参考: http://clockmaker.jp/blog/2008/10/alternativa3d_walkcontroller/
  7. */
  8. package
  9. {
  10.     import alternativa.engine3d.controllers.*;
  11.     import alternativa.engine3d.core.*;
  12.     import alternativa.engine3d.display.*;
  13.     import alternativa.engine3d.materials.*;
  14.     import alternativa.engine3d.primitives.*;
  15.     import alternativa.types.*;
  16.     import alternativa.utils.*;
  17.     
  18.     import flash.net.*;
  19.     import flash.display.*;
  20.     import flash.events.*;
  21.     import flash.geom.*;
  22.     [SWF(frameRate="60")]
  23.     
  24.     public class Main extends Sprite
  25.     {
  26.         private const WIDTH_NUM:int = 10;
  27.         private const HEIGHT_NUM:int = 10;
  28.         private const LINE_SIZE:int = 500;
  29.         
  30.         private const MAZE_ARR:Array = 
  31.         [
  32.             [1111111111],
  33.             [1010010001],
  34.             [1010010001],
  35.             [1011010111],
  36.             [1000000101],
  37.             [1000100101],
  38.             [1010000001],
  39.             [1010111101],
  40.             [1010000001],
  41.             [1111111111]
  42.         ]
  43.         
  44.         private var scene:Scene3D;
  45.         private var view:View;
  46.         private var camera:Camera3D;
  47.         
  48.         // The camera controller
  49.         private var controller:WalkController;
  50.         
  51.         public function Main()
  52.         {
  53.             stage.scaleMode = StageScaleMode.NO_SCALE;
  54.             stage.align = StageAlign.TOP_LEFT;
  55.             
  56.             // Creating scene
  57.             scene = new Scene3D();
  58.             scene.root = new Object3D();
  59.             
  60.             // create box
  61.             for (var i:int = 0; i < MAZE_ARR.length; i++ )
  62.             {
  63.                 for (var j:int = 0; j < MAZE_ARR[i].length; j++ )
  64.                 {
  65.                     if (MAZE_ARR[i][j] == 0continue;
  66.                     
  67.                     var box:Box = Box(scene.root.addChild(new Box(LINE_SIZE, LINE_SIZE, LINE_SIZE)));
  68.                     box.cloneMaterialToAllSurfaces(new DevMaterial(0,0xFF4422));
  69.                     box.x = LINE_SIZE * (i - WIDTH_NUM / 2);
  70.                     box.y = LINE_SIZE * (j - HEIGHT_NUM / 2);
  71.                 }
  72.             }
  73.             var plane:Plane = Plane(scene.root.addChild(new Plane(LINE_SIZE * MAZE_ARR.length, LINE_SIZE * MAZE_ARR.length)));
  74.             plane.cloneMaterialToAllSurfaces(new FillMaterial(0x221100));
  75.             
  76.             plane.z = -LINE_SIZE / 2;
  77.             plane.rotationX = 0 * Math.PI / 180;
  78.             
  79.             // Adding camera and view
  80.             camera = new Camera3D();
  81.             camera.rotationX = MathUtils.toRadian(-90)
  82.             camera.rotationZ = MathUtils.toRadian(120)
  83.             scene.root.addChild(camera);
  84.             view = new View();
  85.             addChild(view);
  86.             view.camera = camera;
  87.             
  88.             // 徒歩のコントローラーを作成
  89.             controller = new WalkController(stage);
  90.             
  91.             // キーボード操作を可能にする機能
  92.             controller.setDefaultBindings();
  93.             // キーボードショートカットの整理
  94.             controller.bindKey(KeyboardUtils.UP, ObjectController.ACTION_FORWARD);
  95.             controller.bindKey(KeyboardUtils.DOWN, ObjectController.ACTION_BACK);
  96.             controller.bindKey(KeyboardUtils.LEFT, ObjectController.ACTION_LEFT);
  97.             controller.bindKey(KeyboardUtils.RIGHT, ObjectController.ACTION_RIGHT);
  98.             
  99.             // WalkControllerの対象を設定
  100.             controller.object = camera;
  101.             // 障害物の衝突設定
  102.             controller.checkCollisions = true;
  103.             // 徒歩の速度
  104.             controller.speed = 500;
  105.             // ジャンプ(スペースでジャンプできます)の速度
  106.             controller.jumpSpeed = 750;
  107.             // 重力の速度
  108.             controller.gravity = 600;
  109.             // 視点(制御点)の高さ
  110.             controller.objectZPosition = 2;
  111.             
  112.             // FPS display launch
  113.             FPS.init(stage);
  114.             
  115.             stage.addEventListener(Event.RESIZE, onResize);
  116.             stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
  117.             onResize(null);
  118.         }
  119.         
  120.         private function onEnterFrame(e:Event):void
  121.         {
  122.             // interface
  123.             controller.processInput();
  124.             
  125.             // Scene calculating
  126.             scene.calculate();
  127.         }
  128.         
  129.         /**
  130.          * Resize Handler
  131.          */
  132.         private function onResize(e:Event):void
  133.         {
  134.             view.width = stage.stageWidth;
  135.             view.height = stage.stageHeight;
  136.             
  137.             // BackGround Color
  138.             var bgMatrix:Matrix = new Matrix();
  139.             bgMatrix.rotate(90 * Math.PI / 180);
  140.             graphics.clear()
  141.             graphics.beginGradientFill("linear", [0xFFFFFF, 0x001122], [100100], [0255], bgMatrix);
  142.             graphics.drawRect(00, stage.stageWidth, stage.stageHeight);
  143.         }
  144.         
  145.     }
  146. }
noswf
  1. // forked from clockmaker's [Alternativa3D] Maze
  2. /**
  3. * Alternativa3D Maze Demo
  4. * W,S,A,D+Spaceで移動
  5. * ドラッグで方向回転
  6. * 参考: http://clockmaker.jp/blog/2008/10/alternativa3d_walkcontroller/
  7. */
  8. package
  9. {
  10.     import alternativa.engine3d.controllers.*;
  11.     import alternativa.engine3d.core.*;
  12.     import alternativa.engine3d.display.*;
  13.     import alternativa.engine3d.materials.*;
  14.     import alternativa.engine3d.primitives.*;
  15.     import alternativa.types.*;
  16.     import alternativa.utils.*;
  17.     
  18.     import flash.net.*;
  19.     import flash.display.*;
  20.     import flash.events.*;
  21.     import flash.geom.*;
  22.     [SWF(frameRate="60")]
  23.     
  24.     public class Main extends Sprite
  25.     {
  26.         private const WIDTH_NUM:int = 10;
  27.         private const HEIGHT_NUM:int = 10;
  28.         private const LINE_SIZE:int = 500;
  29.         
  30.         private const MAZE_ARR:Array = 
  31.         [
  32.             [1111111111],
  33.             [1010010001],
  34.             [1010010001],
  35.             [1011010111],
  36.             [1000000101],
  37.             [1000100101],
  38.             [1010000001],
  39.             [1010111101],
  40.             [1010000001],
  41.             [1111111111]
  42.         ]
  43.         
  44.         private var scene:Scene3D;
  45.         private var view:View;
  46.         private var camera:Camera3D;
  47.         
  48.         // The camera controller
  49.         private var controller:WalkController;
  50.         
  51.         public function Main()
  52.         {
  53.             stage.scaleMode = StageScaleMode.NO_SCALE;
  54.             stage.align = StageAlign.TOP_LEFT;
  55.             
  56.             // Creating scene
  57.             scene = new Scene3D();
  58.             scene.root = new Object3D();
  59.             
  60.             // create box
  61.             for (var i:int = 0; i < MAZE_ARR.length; i++ )
  62.             {
  63.                 for (var j:int = 0; j < MAZE_ARR[i].length; j++ )
  64.                 {
  65.                     if (MAZE_ARR[i][j] == 0continue;
  66.                     
  67.                     var box:Box = Box(scene.root.addChild(new Box(LINE_SIZE, LINE_SIZE, LINE_SIZE)));
  68.                     box.cloneMaterialToAllSurfaces(new DevMaterial(0,0xFF4422));
  69.                     box.x = LINE_SIZE * (i - WIDTH_NUM / 2);
  70.                     box.y = LINE_SIZE * (j - HEIGHT_NUM / 2);
  71.                 }
  72.             }
  73.             var plane:Plane = Plane(scene.root.addChild(new Plane(LINE_SIZE * MAZE_ARR.length, LINE_SIZE * MAZE_ARR.length)));
  74.             plane.cloneMaterialToAllSurfaces(new FillMaterial(0x221100));
  75.             
  76.             plane.z = -LINE_SIZE / 2;
  77.             plane.rotationX = 0 * Math.PI / 180;
  78.             
  79.             // Adding camera and view
  80.             camera = new Camera3D();
  81.             camera.rotationX = MathUtils.toRadian(-90)
  82.             camera.rotationZ = MathUtils.toRadian(120)
  83.             scene.root.addChild(camera);
  84.             view = new View();
  85.             addChild(view);
  86.             view.camera = camera;
  87.             
  88.             // 徒歩のコントローラーを作成
  89.             controller = new WalkController(stage);
  90.             
  91.             // キーボード操作を可能にする機能
  92.             controller.setDefaultBindings();
  93.             // キーボードショートカットの整理
  94.             controller.bindKey(KeyboardUtils.UP, ObjectController.ACTION_FORWARD);
  95.             controller.bindKey(KeyboardUtils.DOWN, ObjectController.ACTION_BACK);
  96.             controller.bindKey(KeyboardUtils.LEFT, ObjectController.ACTION_LEFT);
  97.             controller.bindKey(KeyboardUtils.RIGHT, ObjectController.ACTION_RIGHT);
  98.             
  99.             // WalkControllerの対象を設定
  100.             controller.object = camera;
  101.             // 障害物の衝突設定
  102.             controller.checkCollisions = true;
  103.             // 徒歩の速度
  104.             controller.speed = 500;
  105.             // ジャンプ(スペースでジャンプできます)の速度
  106.             controller.jumpSpeed = 750;
  107.             // 重力の速度
  108.             controller.gravity = 600;
  109.             // 視点(制御点)の高さ
  110.             controller.objectZPosition = 2;
  111.             
  112.             // FPS display launch
  113.             FPS.init(stage);
  114.             
  115.             stage.addEventListener(Event.RESIZE, onResize);
  116.             stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
  117.             onResize(null);
  118.         }
  119.         
  120.         private function onEnterFrame(e:Event):void
  121.         {
  122.             // interface
  123.             controller.processInput();
  124.             
  125.             // Scene calculating
  126.             scene.calculate();
  127.         }
  128.         
  129.         /**
  130.          * Resize Handler
  131.          */
  132.         private function onResize(e:Event):void
  133.         {
  134.             view.width = stage.stageWidth;
  135.             view.height = stage.stageHeight;
  136.             
  137.             // BackGround Color
  138.             var bgMatrix:Matrix = new Matrix();
  139.             bgMatrix.rotate(90 * Math.PI / 180);
  140.             graphics.clear()
  141.             graphics.beginGradientFill("linear", [0xFFFFFF, 0x001122], [100100], [0255], bgMatrix);
  142.             graphics.drawRect(00, stage.stageWidth, stage.stageHeight);
  143.         }
  144.         
  145.     }
  146. }
noswf
  1. // forked from clockmaker's [Alternativa3D] Maze
  2. /**
  3. * Alternativa3D Maze Demo
  4. * W,S,A,D+Spaceで移動
  5. * ドラッグで方向回転
  6. * 参考: http://clockmaker.jp/blog/2008/10/alternativa3d_walkcontroller/
  7. */
  8. package
  9. {
  10.     import alternativa.engine3d.controllers.*;
  11.     import alternativa.engine3d.core.*;
  12.     import alternativa.engine3d.display.*;
  13.     import alternativa.engine3d.materials.*;
  14.     import alternativa.engine3d.primitives.*;
  15.     import alternativa.types.*;
  16.     import alternativa.utils.*;
  17.     
  18.     import flash.net.*;
  19.     import flash.display.*;
  20.     import flash.events.*;
  21.     import flash.geom.*;
  22.     [SWF(frameRate="60")]
  23.     
  24.     public class Main extends Sprite
  25.     {
  26.         private const WIDTH_NUM:int = 10;
  27.         private const HEIGHT_NUM:int = 10;
  28.         private const LINE_SIZE:int = 500;
  29.         
  30.         private const MAZE_ARR:Array = 
  31.         [
  32.             [1111111111],
  33.             [1000000001],
  34.             [1010010001],
  35.             [1011010111],
  36.             [1000000101],
  37.             [1000100101],
  38.             [1010000001],
  39.             [1010111101],
  40.             [1010000001],
  41.             [1111111111]
  42.         ]
  43.         
  44.         private var scene:Scene3D;
  45.         private var view:View;
  46.         private var camera:Camera3D;
  47.         
  48.         // The camera controller
  49.         private var controller:WalkController;
  50.         
  51.         public function Main()
  52.         {
  53.             stage.scaleMode = StageScaleMode.NO_SCALE;
  54.             stage.align = StageAlign.TOP_LEFT;
  55.             
  56.             // Creating scene
  57.             scene = new Scene3D();
  58.             scene.root = new Object3D();
  59.             
  60.             // create box
  61.             for (var i:int = 0; i < MAZE_ARR.length; i++ )
  62.             {
  63.                 for (var j:int = 0; j < MAZE_ARR[i].length; j++ )
  64.                 {
  65.                     if (MAZE_ARR[i][j] == 0continue;
  66.                     
  67.                     var box:Box = Box(scene.root.addChild(new Box(LINE_SIZE, LINE_SIZE, LINE_SIZE)));
  68.                     box.cloneMaterialToAllSurfaces(new DevMaterial(0,0xFF4422));
  69.                     box.x = LINE_SIZE * (i - WIDTH_NUM / 2);
  70.                     box.y = LINE_SIZE * (j - HEIGHT_NUM / 2);
  71.                 }
  72.             }
  73.             var plane:Plane = Plane(scene.root.addChild(new Plane(LINE_SIZE * MAZE_ARR.length, LINE_SIZE * MAZE_ARR.length)));
  74.             plane.cloneMaterialToAllSurfaces(new FillMaterial(0x221100));
  75.             
  76.             plane.z = -LINE_SIZE / 2;
  77.             plane.rotationX = 0 * Math.PI / 180;
  78.             
  79.             // Adding camera and view
  80.             camera = new Camera3D();
  81.             camera.rotationX = MathUtils.toRadian(-90)
  82.             camera.rotationZ = MathUtils.toRadian(120)
  83.             scene.root.addChild(camera);
  84.             view = new View();
  85.             addChild(view);
  86.             view.camera = camera;
  87.             
  88.             // 徒歩のコントローラーを作成
  89.             controller = new WalkController(stage);
  90.             
  91.             // キーボード操作を可能にする機能
  92.             controller.setDefaultBindings();
  93.             // キーボードショートカットの整理
  94.             controller.bindKey(KeyboardUtils.UP, ObjectController.ACTION_FORWARD);
  95.             controller.bindKey(KeyboardUtils.DOWN, ObjectController.ACTION_BACK);
  96.             controller.bindKey(KeyboardUtils.LEFT, ObjectController.ACTION_LEFT);
  97.             controller.bindKey(KeyboardUtils.RIGHT, ObjectController.ACTION_RIGHT);
  98.             
  99.             // WalkControllerの対象を設定
  100.             controller.object = camera;
  101.             // 障害物の衝突設定
  102.             controller.checkCollisions = true;
  103.             // 徒歩の速度
  104.             controller.speed = 500;
  105.             // ジャンプ(スペースでジャンプできます)の速度
  106.             controller.jumpSpeed = 750;
  107.             // 重力の速度
  108.             controller.gravity = 600;
  109.             // 視点(制御点)の高さ
  110.             controller.objectZPosition = 2;
  111.             
  112.             // FPS display launch
  113.             FPS.init(stage);
  114.             
  115.             stage.addEventListener(Event.RESIZE, onResize);
  116.             stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
  117.             onResize(null);
  118.         }
  119.         
  120.         private function onEnterFrame(e:Event):void
  121.         {
  122.             // interface
  123.             controller.processInput();
  124.             
  125.             // Scene calculating
  126.             scene.calculate();
  127.         }
  128.         
  129.         /**
  130.          * Resize Handler
  131.          */
  132.         private function onResize(e:Event):void
  133.         {
  134.             view.width = stage.stageWidth;
  135.             view.height = stage.stageHeight;
  136.             
  137.             // BackGround Color
  138.             var bgMatrix:Matrix = new Matrix();
  139.             bgMatrix.rotate(90 * Math.PI / 180);
  140.             graphics.clear()
  141.             graphics.beginGradientFill("linear", [0xFFFFFF, 0x001122], [100100], [0255], bgMatrix);
  142.             graphics.drawRect(00, stage.stageWidth, stage.stageHeight);
  143.         }
  144.         
  145.     }
  146. }
noswf
  1. // forked from clockmaker's [Alternativa3D] Maze
  2. /**
  3. * Alternativa3D Maze Demo
  4. * W,S,A,D+Spaceで移動
  5. * ドラッグで方向回転
  6. * 参考: http://clockmaker.jp/blog/2008/10/alternativa3d_walkcontroller/
  7. */
  8. package
  9. {
  10.     import alternativa.engine3d.controllers.*;
  11.     import alternativa.engine3d.core.*;
  12.     import alternativa.engine3d.display.*;
  13.     import alternativa.engine3d.materials.*;
  14.     import alternativa.engine3d.primitives.*;
  15.     import alternativa.types.*;
  16.     import alternativa.utils.*;
  17.     
  18.     import flash.net.*;
  19.     import flash.display.*;
  20.     import flash.events.*;
  21.     import flash.geom.*;
  22.     [SWF(frameRate="60")]
  23.     
  24.     public class Main extends Sprite
  25.     {
  26.         private const WIDTH_NUM:int = 10;
  27.         private const HEIGHT_NUM:int = 10;
  28.         private const LINE_SIZE:int = 500;
  29.         
  30.         private const MAZE_ARR:Array = 
  31.         [
  32.             [1111111111],
  33.             [1010010001],
  34.             [1010010001],
  35.             [1011010111],
  36.             [1000000101],
  37.             [1000100101],
  38.             [1010000001],
  39.             [1010111101],
  40.             [1010000001],
  41.             [1111111111],
  42.                         [1101111111]
  43.         ]
  44.         
  45.         private var scene:Scene3D;
  46.         private var view:View;
  47.         private var camera:Camera3D;
  48.         
  49.         // The camera controller
  50.         private var controller:WalkController;
  51.         
  52.         public function Main()
  53.         {
  54.             stage.scaleMode = StageScaleMode.NO_SCALE;
  55.             stage.align = StageAlign.TOP_LEFT;
  56.             
  57.             // Creating scene
  58.             scene = new Scene3D();
  59.             scene.root = new Object3D();
  60.             
  61.             // create box
  62.             for (var i:int = 0; i < MAZE_ARR.length; i++ )
  63.             {
  64.                 for (var j:int = 0; j < MAZE_ARR[i].length; j++ )
  65.                 {
  66.                     if (MAZE_ARR[i][j] == 0continue;
  67.                     
  68.                     var box:Box = Box(scene.root.addChild(new Box(LINE_SIZE, LINE_SIZE, LINE_SIZE)));
  69.                     box.cloneMaterialToAllSurfaces(new DevMaterial(0,0xFF4422));
  70.                     box.x = LINE_SIZE * (i - WIDTH_NUM / 2);
  71.                     box.y = LINE_SIZE * (j - HEIGHT_NUM / 2);
  72.                 }
  73.             }
  74.             var plane:Plane = Plane(scene.root.addChild(new Plane(LINE_SIZE * MAZE_ARR.length, LINE_SIZE * MAZE_ARR.length)));
  75.             plane.cloneMaterialToAllSurfaces(new FillMaterial(0x221100));
  76.             
  77.             plane.z = -LINE_SIZE / 2;
  78.             plane.rotationX = 0 * Math.PI / 180;
  79.             
  80.             // Adding camera and view
  81.             camera = new Camera3D();
  82.             camera.rotationX = MathUtils.toRadian(-90)
  83.             camera.rotationZ = MathUtils.toRadian(120)
  84.             scene.root.addChild(camera);
  85.             view = new View();
  86.             addChild(view);
  87.             view.camera = camera;
  88.             
  89.             // 徒歩のコントローラーを作成
  90.             controller = new WalkController(stage);
  91.             
  92.             // キーボード操作を可能にする機能
  93.             controller.setDefaultBindings();
  94.             // キーボードショートカットの整理
  95.             controller.bindKey(KeyboardUtils.UP, ObjectController.ACTION_FORWARD);
  96.             controller.bindKey(KeyboardUtils.DOWN, ObjectController.ACTION_BACK);
  97.             controller.bindKey(KeyboardUtils.LEFT, ObjectController.ACTION_LEFT);
  98.             controller.bindKey(KeyboardUtils.RIGHT, ObjectController.ACTION_RIGHT);
  99.             
  100.             // WalkControllerの対象を設定
  101.             controller.object = camera;
  102.             // 障害物の衝突設定
  103.             controller.checkCollisions = true;
  104.             // 徒歩の速度
  105.             controller.speed = 500;
  106.             // ジャンプ(スペースでジャンプできます)の速度
  107.             controller.jumpSpeed = 750;
  108.             // 重力の速度
  109.             controller.gravity = 600;
  110.             // 視点(制御点)の高さ
  111.             controller.objectZPosition = 2;
  112.             
  113.             // FPS display launch
  114.             FPS.init(stage);
  115.             
  116.             stage.addEventListener(Event.RESIZE, onResize);
  117.             stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
  118.             onResize(null);
  119.         }
  120.         
  121.         private function onEnterFrame(e:Event):void
  122.         {
  123.             // interface
  124.             controller.processInput();
  125.             
  126.             // Scene calculating
  127.             scene.calculate();
  128.         }
  129.         
  130.         /**
  131.          * Resize Handler
  132.          */
  133.         private function onResize(e:Event):void
  134.         {
  135.             view.width = stage.stageWidth;
  136.             view.height = stage.stageHeight;
  137.             
  138.             // BackGround Color
  139.             var bgMatrix:Matrix = new Matrix();
  140.             bgMatrix.rotate(90 * Math.PI / 180);
  141.             graphics.clear()
  142.             graphics.beginGradientFill("linear", [0xFFFFFF, 0x001122], [100100], [0255], bgMatrix);
  143.             graphics.drawRect(00, stage.stageWidth, stage.stageHeight);
  144.         }
  145.         
  146.     }
  147. }
noswf
  1. // forked from clockmaker's [Alternativa3D] Maze
  2. /*
  3. ※起動がすごく重いです
  4. */
  5. /**
  6. * Alternativa3D Maze Demo
  7. * W,S,A,D+Spaceで移動
  8. * ドラッグで方向回転
  9. * 参考: http://clockmaker.jp/blog/2008/10/alternativa3d_walkcontroller/
  10. */
  11. package
  12. {
  13.     import alternativa.engine3d.controllers.*;
  14.     import alternativa.engine3d.core.*;
  15.     import alternativa.engine3d.display.*;
  16.     import alternativa.engine3d.materials.*;
  17.     import alternativa.engine3d.primitives.*;
  18.     import alternativa.types.*;
  19.     import alternativa.utils.*;
  20.     
  21.     import flash.net.*;
  22.     import flash.display.*;
  23.     import flash.events.*;
  24.     import flash.geom.*;
  25.     [SWF(frameRate="30")]
  26.     
  27.     public class Main extends Sprite
  28.     {
  29.         private const COL_NUM:int = 20;
  30.         private const ROW_NUM:int = 20;
  31.         
  32.         private const CELL_WIDTH:Number = 1000;
  33.         private const CELL_HEIGHT:Number = 1200;
  34.         private const WALL_WIDTH:Number = 50;
  35.         private const FLOOR_HEIGHT:Number = 50;
  36.         
  37.         //cell
  38.         //0: null
  39.         //1: floor
  40.         //2: block
  41.         //4: elv
  42.         
  43.         private const CELL_FLOOR:uint = 1;
  44.         private const CELL_BLOCK:uint = 2;
  45.         
  46.         
  47.         
  48.         private const CELL_ARR:Array = 
  49.             [
  50.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  51.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  52.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  53.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  54.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  55.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  56.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  57.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  58.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  59.                 [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  60.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  61.                 [1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1],
  62.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  63.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  64.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  65.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  66.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  67.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  68.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
  69.                 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
  70.             ];
  71.         
  72.         
  73.         //walls
  74.         //0: null
  75.         //1: wall
  76.         //2: door
  77.         //4: hidden door
  78.         
  79.         private const WALL_WALL:uint = 1;
  80.         private const WALL_DOOR:uint = 2;
  81.         private const WALL_HIDDEN_DOOR:uint = 4;
  82.         private const NEWS_X:Array = [010, -1];
  83.         private const NEWS_Y:Array = [-1010];
  84.         private const NEWS_ROT:Array = [900, -90180];
  85.         
  86.         
  87.         //[north, east, south, west]
  88.         private const WALL_ARR:Array = 
  89.         [
  90. [
  91. [1,2,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1],
  92. [1,1,2,1,2,1,0,0,0,1,0,0,4,4,1,1,0,0,4,4],
  93. [2,1,2,0,1,1,0,0,0,0,0,0,1,1,1,4,1,1,0,0],
  94. [1,1,1,0,1,1,1,1,2,0,0,0,0,0,1,1,1,1,1,1],
  95. [0,0,0,2,0,0,0,0,0,1,0,0,0,0,0,1,1,2,0,0],
  96. [0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,4],
  97. [1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1],
  98. [1,2,1,0,1,0,1,1,0,0,1,0,0,0,0,0,2,2,0,0],
  99. [0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,4,4],
  100. [1,1,1,1,1,2,1,1,1,0,0,0,0,0,0,0,1,0,1,2],
  101. [1,1,1,1,1,1,1,1,1,0,0,2,1,2,1,2,1,2,1,1],
  102. [1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1],
  103. [0,1,1,0,1,1,0,1,1,1,0,0,1,1,1,1,0,1,1,1],
  104. [0,0,0,0,0,1,2,1,0,0,0,0,4,1,1,0,0,0,1,0],
  105. [0,0,0,0,0,0,0,0,0,0,0,0,4,1,2,2,0,0,0,0],
  106. [0,0,0,0,0,1,1,1,0,0,0,0,4,1,0,0,0,0,0,0],
  107. [0,0,1,2,1,0,0,0,0,0,0,0,4,1,0,0,0,0,0,0],
  108. [0,0,0,0,0,0,1,1,1,0,0,0,4,1,1,2,1,0,0,0],
  109. [0,0,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0],
  110. [0,1,1,1,1,1,1,2,1,0,0,1,1,1,1,1,1,1,1,1]
  111. ],
  112. [
  113. [0,1,1,0,1,0,0,0,1,2,1,2,0,2,0,2,0,1,1,1],
  114. [0,4,0,0,0,2,0,0,1,0,1,1,1,1,0,1,0,1,0,1],
  115. [1,1,1,1,0,1,0,0,1,0,1,1,1,2,0,2,0,2,0,1],
  116. [0,0,1,1,0,0,1,1,1,1,1,1,1,1,0,1,0,1,0,1],
  117. [0,0,2,2,0,0,1,1,1,0,1,1,1,1,1,2,0,2,0,1],
  118. [0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,1,1,1],
  119. [0,0,0,1,1,1,0,1,1,0,1,1,1,1,1,1,0,2,0,1],
  120. [0,0,1,0,2,2,0,1,1,0,1,1,1,1,1,1,1,1,0,1],
  121. [0,0,1,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1],
  122. [0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,1,0,1],
  123. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,4],
  124. [0,0,0,0,0,0,0,0,2,1,1,0,0,0,0,0,0,0,0,1],
  125. [1,0,1,1,0,1,1,0,1,0,1,1,4,1,0,1,1,0,0,1],
  126. [1,0,1,1,1,0,0,1,1,0,1,1,1,4,1,1,1,1,1,1],
  127. [1,0,1,1,1,0,0,1,1,0,1,1,1,2,0,1,1,1,1,1],
  128. [1,0,1,1,0,0,0,0,1,0,1,1,1,2,0,1,1,1,1,1],
  129. [1,1,0,0,1,0,0,0,1,0,1,1,1,2,0,1,1,1,1,1],
  130. [1,1,0,0,1,1,0,0,1,0,1,1,1,1,1,2,0,1,1,1],
  131. [1,0,0,0,0,1,0,0,1,0,1,0,0,0,0,0,0,0,1,1],
  132. [0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1]
  133. ],
  134. [
  135. [1,1,2,1,2,1,0,0,0,1,0,0,4,4,1,1,0,0,4,4],
  136. [2,1,2,0,1,1,0,0,0,0,0,0,1,1,1,4,1,1,0,0],
  137. [1,1,1,0,1,1,1,1,4,0,0,0,0,0,1,1,1,1,1,1],
  138. [0,0,0,2,0,0,0,0,0,1,0,0,0,0,0,1,1,2,0,0],
  139. [0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,4],
  140. [1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1],
  141. [1,2,1,0,1,0,1,1,0,0,1,0,0,0,0,0,2,2,0,0],
  142. [0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,4,4],
  143. [1,1,1,1,1,2,1,1,1,0,0,0,0,0,0,0,1,0,1,1],
  144. [1,1,1,1,1,1,1,1,1,0,0,2,1,2,1,2,1,2,1,1],
  145. [1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1],
  146. [0,1,1,0,1,1,0,1,1,1,0,0,1,1,1,1,0,1,1,1],
  147. [0,0,0,0,0,1,2,1,0,0,0,0,1,4,1,0,0,0,1,0],
  148. [0,0,0,0,0,0,0,0,0,0,0,0,1,1,2,2,0,0,0,0],
  149. [0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0],
  150. [0,0,1,2,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0],
  151. [0,0,0,0,0,0,1,1,1,0,0,0,1,1,2,2,1,0,0,0],
  152. [0,0,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0],
  153. [0,1,1,1,1,2,1,2,1,0,0,1,1,1,1,1,1,1,1,2],
  154. [1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1]
  155. ],
  156. [
  157. [1,0,1,1,1,1,1,0,0,1,2,1,2,0,2,0,2,0,1,1],
  158. [1,0,4,0,0,0,2,0,0,1,0,1,1,1,1,0,1,0,1,0],
  159. [1,2,1,1,0,0,1,0,0,1,0,1,2,1,2,0,2,0,2,0],
  160. [1,0,0,1,1,0,0,0,1,1,1,1,1,1,2,0,1,0,1,0],
  161. [1,0,0,2,2,0,0,1,1,1,0,1,1,1,1,1,2,0,2,0],
  162. [1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,0,0,1,1],
  163. [1,1,0,0,1,1,1,0,1,1,0,1,1,1,1,1,2,0,2,0],
  164. [1,0,0,1,0,2,2,0,1,1,0,1,1,1,1,1,1,1,1,0],
  165. [1,0,0,1,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1],
  166. [1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0],
  167. [1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  168. [1,0,0,0,0,0,0,0,0,2,1,1,0,0,0,0,0,0,0,0],
  169. [1,1,0,1,1,0,1,1,0,1,0,1,1,1,2,0,1,1,0,0],
  170. [1,1,0,1,1,1,0,0,1,1,0,1,1,1,1,1,1,1,1,1],
  171. [1,1,0,1,1,1,0,0,1,1,0,1,1,1,2,0,1,1,1,1],
  172. [1,1,0,1,1,0,0,0,0,1,0,1,1,1,2,0,0,1,1,1],
  173. [1,1,1,0,0,1,0,0,0,1,0,1,1,1,2,0,1,1,1,1],
  174. [1,1,1,0,0,1,1,0,0,1,0,1,1,4,4,4,2,0,1,1],
  175. [1,1,0,0,0,0,1,0,0,1,0,1,0,0,0,0,0,0,0,1],
  176. [1,0,0,0,0,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0]
  177. ]
  178.         ];
  179.         
  180.         
  181.         private var scene:Scene3D;
  182.         private var view:View;
  183.         private var camera:Camera3D;
  184.         
  185.         // The camera controller
  186.         private var controller:WalkController;
  187.         
  188.         public function Main()
  189.         {
  190.             stage.scaleMode = StageScaleMode.NO_SCALE;
  191.             stage.align = StageAlign.TOP_LEFT;
  192.             
  193.             // Creating scene
  194.             scene = new Scene3D();
  195.             scene.root = new Object3D();
  196.             
  197.             // create box
  198.                 for (var r:int = 0; r < CELL_ARR.length; r++ )
  199.                 {
  200.                     for (var c:int = 0; c < CELL_ARR[r].length; c++ )
  201.                     {
  202.                         var flg:uint
  203.                         var box:Box;
  204.                         
  205.                         flg = CELL_ARR[r][c];
  206.                         if (flg & CELL_FLOOR) 
  207.                         {
  208.                             box = Box(scene.root.addChild(new Box(CELL_WIDTH, CELL_WIDTH, FLOOR_HEIGHT)));
  209.                             box.cloneMaterialToAllSurfaces(new DevMaterial(0,0x994422));
  210.                             box.x = CELL_WIDTH * (c );
  211.                             box.y = -CELL_WIDTH * (r - ROW_NUM + 1);
  212.                             box.z =  - CELL_HEIGHT / 2;
  213.                         }
  214.                         
  215.                         //north,east,south,west, each direction walls
  216.                         for(var news:uint = 0; news < 4; news++)
  217.                         {
  218.                         
  219.                         
  220.                     
  221.                             flg = WALL_ARR[news][r][c];
  222.                             if (flg & WALL_WALL)
  223.                             {
  224.                                 box = Box(scene.root.addChild(new Box(WALL_WIDTH, CELL_WIDTH, CELL_HEIGHT)));
  225.                                 box.cloneMaterialToAllSurfaces(new DevMaterial(0,0x999999));
  226.                             }
  227.                             else if(flg & WALL_DOOR || flg & WALL_HIDDEN_DOOR)
  228.                             {
  229.                                 box = Box(scene.root.addChild(new Box(WALL_WIDTH, CELL_WIDTH, 400)));
  230.                                 box.cloneMaterialToAllSurfaces(new DevMaterial(0,0x990000));
  231.                                 box.z = CELL_HEIGHT / 2 - 200;
  232.                             }
  233.                             else
  234.                             {
  235.                                 continue;
  236.                             }
  237.                             box.rotationZ = MathUtils.toRadian(NEWS_ROT[news]);
  238.                             box.x = CELL_WIDTH * c + NEWS_X[news] * (CELL_WIDTH /2 - WALL_WIDTH / 2);
  239.                             box.y = -(CELL_WIDTH * (r - ROW_NUM + 1) +  NEWS_Y[news] * (CELL_WIDTH /2 - WALL_WIDTH / 2));
  240.                             
  241.                         }
  242.                     }
  243.                 }
  244. /*
  245.             var plane:Plane = Plane(scene.root.addChild(new Plane(CELL_WIDTH * COL_NUM, CELL_WIDTH * ROW_NUM)));
  246.             plane.cloneMaterialToAllSurfaces(new FillMaterial(0x221100));
  247.             
  248.             plane.z = 5000;//CELL_HEIGHT / 2;
  249.             plane.rotationX = 0 * Math.PI / 180;
  250. */
  251.             
  252.             // Adding camera and view
  253.             camera = new Camera3D();
  254.             camera.rotationX = MathUtils.toRadian(-90)
  255. //            camera.rotationZ = MathUtils.toRadian(120)
  256.             scene.root.addChild(camera);
  257.             view = new View();
  258.             addChild(view);
  259.             view.camera = camera;
  260.             
  261.             // 徒歩のコントローラーを作成
  262.             controller = new WalkController(stage);
  263.             
  264.             // キーボード操作を可能にする機能
  265.             controller.setDefaultBindings();
  266.             // キーボードショートカットの整理
  267.             controller.bindKey(KeyboardUtils.UP, ObjectController.ACTION_FORWARD);
  268.             controller.bindKey(KeyboardUtils.DOWN, ObjectController.ACTION_BACK);
  269.             controller.bindKey(KeyboardUtils.LEFT, ObjectController.ACTION_LEFT);
  270.             controller.bindKey(KeyboardUtils.RIGHT, ObjectController.ACTION_RIGHT);
  271.             
  272.             // WalkControllerの対象を設定
  273.             controller.object = camera;
  274.             // 障害物の衝突設定
  275.             controller.checkCollisions = true;
  276.             // 徒歩の速度
  277.             controller.speed = 2000;
  278.             // ジャンプ(スペースでジャンプできます)の速度
  279.             controller.jumpSpeed = 3750;
  280.             // 重力の速度
  281.             controller.gravity = 1200;
  282.             // 視点(制御点)の高さ
  283.             controller.objectZPosition = 2;
  284.             
  285.             // FPS display launch
  286.             FPS.init(stage);
  287.             
  288.             stage.addEventListener(Event.RESIZE, onResize);
  289.             stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
  290.             onResize(null);
  291.         }
  292.         
  293.         private function onEnterFrame(e:Event):void
  294.         {
  295.             // interface
  296.             controller.processInput();
  297.             
  298.             // Scene calculating
  299.             scene.calculate();
  300.         }
  301.         
  302.         /**
  303.          * Resize Handler
  304.          */
  305.         private function onResize(e:Event):void
  306.         {
  307.             view.width = stage.stageWidth;
  308.             view.height = stage.stageHeight;
  309.             
  310.             // BackGround Color
  311.             var bgMatrix:Matrix = new Matrix();
  312.             bgMatrix.rotate(90 * Math.PI / 180);
  313.             graphics.clear()
  314.             graphics.beginGradientFill("linear", [0xFFFFFF, 0x001122], [100100], [0255], bgMatrix);
  315.             graphics.drawRect(00, stage.stageWidth, stage.stageHeight);
  316.         }
  317.         
  318.     }
  319. }
noswf
Get Adobe Flash Player