Exemplo n.º 1
0
        public CharacterImageEditor(string path = "")
        {
            Path      = path;
            MainLayer = new asd.Layer2D();

            Character = new EditableCharacterImage();
            if (path != "")
            {
                _ = Character.LoadCharacterImageIOAsync(path);
            }
            MainLayer.AddObject(Character);

            MainCamera = new asd.CameraObject2D();
            var size = Character.BaseImage?.Size ?? default;

            MainCamera.Src = new asd.RectI(new asd.Vector2DI(), size);
            if (size.X != 0 && size.Y != 0)
            {
                if ((float)asd.Engine.WindowSize.X / asd.Engine.WindowSize.Y >= 1.0f / 2)
                {
                    MainCamera.Dst = new asd.RectI((asd.Engine.WindowSize.X - size.X * asd.Engine.WindowSize.Y / size.Y) / 2,
                                                   0, size.X * asd.Engine.WindowSize.Y / size.Y, asd.Engine.WindowSize.Y);
                }
                else
                {
                    MainCamera.Dst = new asd.RectI(0, (asd.Engine.WindowSize.Y - size.Y * asd.Engine.WindowSize.X / size.X) / 2,
                                                   asd.Engine.WindowSize.X, size.Y * asd.Engine.WindowSize.X / size.X);
                }
            }
            MainLayer.AddObject(MainCamera);
            AddLayer(MainLayer);
        }
Exemplo n.º 2
0
 public CollidableMouse(float radius, asd.CameraObject2D camera)
 {
     this.camera = camera;
     collider    = new asd.CircleCollider()
     {
         Radius = radius
     };
 }
Exemplo n.º 3
0
        public GameScene()
        {
            bgLayer = new asd.Layer2D();
            layer   = new asd.Layer2D();
            uiLayer = new asd.Layer2D();

            camera = new asd.CameraObject2D
            {
                Src = new asd.RectI(200, 0, 400, 600),
                Dst = new asd.RectI(200, 0, 400, 600)
            };
            player = new Objects.Player();
        }
Exemplo n.º 4
0
        protected override void OnStart()
        {
            var scene = new asd.Scene();
            var layer = new asd.Layer2D();
            var obj = new asd.TextureObject2D();
            camera = new asd.CameraObject2D();

            obj.Texture = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Sample1.png");
            camera.Src = new asd.RectI(100, 100, 312, 312);
            camera.Dst = new asd.RectI(10, 10, 200, 200);

            layer.AddObject(obj);
            layer.AddObject(camera);
            scene.AddLayer(layer);
            asd.Engine.ChangeScene(scene);
        }
Exemplo n.º 5
0
        protected override void OnStart()
        {
            var scene = new asd.Scene();
            var layer = new asd.Layer2D();
            var obj   = new asd.TextureObject2D();

            camera = new asd.CameraObject2D();

            obj.Texture = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Sample1.png");
            camera.Src  = new asd.RectI(100, 100, 312, 312);
            camera.Dst  = new asd.RectI(10, 10, 200, 200);

            layer.AddObject(obj);
            layer.AddObject(camera);
            scene.AddLayer(layer);
            asd.Engine.ChangeScene(scene);
        }
Exemplo n.º 6
0
    public void Run()
    {
        // Altseedを初期化する。
        asd.Engine.Initialize("CameraObject2D_Texture", 640, 480, new asd.EngineOption());

        // 画像を読み込む。
        var tex = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Picture1.png");

        // テクスチャを描画するオブジェクトを設定する。
        var obj1 = new asd.TextureObject2D();

        obj1.Texture  = tex;
        obj1.Position = new asd.Vector2DF(200, 10);
        obj1.Angle    = 45.0f;
        obj1.Scale    = new asd.Vector2DF(0.5f, 0.5f);

        // グループを設定する。
        obj1.CameraGroup = 1;
        asd.Engine.AddObject2D(obj1);

        // カメラを設定する。
        var cameraOffscreen = new asd.CameraObject2D();

        cameraOffscreen.Src = new asd.RectI(0, 0, 640, 480);
        cameraOffscreen.Dst = new asd.RectI(0, 0, 640, 480);

        // グループを設定する。
        cameraOffscreen.CameraGroup = 1;

        // オフスクリーンモードであることを設定する。
        cameraOffscreen.IsOffsecreenMode = true;

        asd.Engine.AddObject2D(cameraOffscreen);

        // テクスチャを描画するオブジェクトを設定する。
        var obj2 = new asd.TextureObject2D();

        obj2.Texture  = cameraOffscreen.Texture;
        obj2.Position = new asd.Vector2DF(310, 10);
        obj2.Scale    = new asd.Vector2DF(0.5f, 0.5f);

        // グループを設定する。
        obj2.CameraGroup = 2;
        asd.Engine.AddObject2D(obj2);

        // カメラを設定する。
        var camera = new asd.CameraObject2D();

        camera.Src = new asd.RectI(0, 0, 640, 480);
        camera.Dst = new asd.RectI(0, 0, 640, 480);

        // グループを設定する。
        camera.CameraGroup = 2;
        asd.Engine.AddObject2D(camera);

        // Altseedのウインドウが閉じられていないか確認する。
        while (asd.Engine.DoEvents())
        {
            // Altseedを更新する。
            asd.Engine.Update();
            Recorder.TakeScreenShot("CameraObject2D_Texture", 30);
        }

        // Altseedを終了する。
        asd.Engine.Terminate();
    }
Exemplo n.º 7
0
    public void Run()
    {
        // Altseedを初期化する。
        asd.Engine.Initialize("Action2D_Camera", 640, 480, new asd.EngineOption());

        // カメラを設定する。
        var camera = new asd.CameraObject2D();

        camera.Src = new asd.RectI(0, 0, 640, 480);
        camera.Dst = new asd.RectI(0, 0, 640, 480);

        // エンジンにカメラオブジェクトを追加する。
        asd.Engine.AddObject2D(camera);

        {
            // マップオブジェクトを生成する。
            var mapObject = new asd.MapObject2D();

            var texture = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Chip1.png");

            // マップオブジェクトに50*50=2500個のチップを登録する。
            for (int i = 0; i < 50; ++i)
            {
                for (int j = 0; j < 50; ++j)
                {
                    // チップを生成する。
                    var chip = new asd.Chip2D();

                    // チップにテクスチャを設定する。
                    chip.Texture = texture;

                    // チップの描画先を指定する。
                    chip.Position = new asd.Vector2DF(i * 40 - 1000, j * 40 - 1000);

                    // マップオブジェクトにチップを追加する。
                    mapObject.AddChip(chip);
                }
            }

            // マップオブジェクトのインスタンスをエンジンへ追加する。
            asd.Engine.AddObject2D(mapObject);
        }

        // キャラクターを設定する。
        var charactor = new asd.TextureObject2D();

        // キャラクターの画像を読み込む。
        charactor.Texture = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Character1.png");

        // キャラクターをエンジンに追加する。
        asd.Engine.AddObject2D(charactor);

        // Altseedのウインドウが閉じられていないか確認する。
        while (asd.Engine.DoEvents())
        {
            // キャラクターを移動させる。
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.Up) == asd.ButtonState.Hold)
            {
                charactor.Position = charactor.Position + new asd.Vector2DF(0, -2);
            }
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.Down) == asd.ButtonState.Hold)
            {
                charactor.Position = charactor.Position + new asd.Vector2DF(0, +2);
            }
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.Left) == asd.ButtonState.Hold)
            {
                charactor.Position = charactor.Position + new asd.Vector2DF(-2, 0);
            }
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.Right) == asd.ButtonState.Hold)
            {
                charactor.Position = charactor.Position + new asd.Vector2DF(+2, 0);
            }

            //カメラをキャラクターの位置に合わせる。
            var pos = camera.Src;
            pos.X      = (int)charactor.Position.X - 640 / 2;
            pos.Y      = (int)charactor.Position.Y - 480 / 2;
            camera.Src = pos;

            // Altseedを更新する。
            asd.Engine.Update();

            Recorder.TakeScreenShot("Action2D_Camera", 20);
        }

        // Altseedの終了処理をする。
        asd.Engine.Terminate();
    }
Exemplo n.º 8
0
        public void Run()
        {
            // aceを初期化する。
            asd.Engine.Initialize("CameraObject2D", 640, 480, new asd.EngineOption());

            // テクスチャを生成する。
            {
                var tex0 = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Sample1.png");
                var obj0 = new asd.TextureObject2D();
                obj0.Texture = tex0;
                obj0.CenterPosition = new asd.Vector2DF(256, 256);
                obj0.Position = new asd.Vector2DF(320, 240);
                obj0.Scale = new asd.Vector2DF(0.5f, 0.5f);

                asd.Engine.AddObject2D(obj0);
            }

            //一つ目の画面全体を写すカメラ。(オブジェクトをそのまま描画する。)
            {
                var camera1 = new asd.CameraObject2D();
                camera1.Src = new asd.RectI(0, 0, 640, 480);
                camera1.Dst = new asd.RectI(0, 0, 640, 480);
                asd.Engine.AddObject2D(camera1);
            }

            //二つ目のマウスポインタの周辺を拡大して表示するカメラ。
            var camera2 = new asd.CameraObject2D();
            asd.Engine.AddObject2D(camera2);

            //フレーム用テクスチャ画像を準備する。
            var frame = new asd.TextureObject2D();
            {
                var tex = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Frame.png");
                frame.Texture = tex;
                frame.CenterPosition = new asd.Vector2DF(55.0f, 55.0f);

                asd.Engine.AddObject2D(frame);
            }

            // aceが進行可能かチェックする。
            while (asd.Engine.DoEvents())
            {
                //マウスポインタの位置を取得する。
                var pos = asd.Engine.Mouse.Position;

                //拡大用カメラの描画元を指定する。
                camera2.Src = new asd.RectI((int)(pos.X) - 25, (int)(pos.Y) - 25, 50, 50);

                //ポインタを中心に100x100の拡大画像を表示する。
                camera2.Dst = new asd.RectI((int)(pos.X) - 50, (int)(pos.Y) - 50, 100, 100);

                //フレーム画像の描画中心をマウスポインタの位置に合わせる。
                frame.Position = pos;

                // aceを更新する。
                asd.Engine.Update();
            }

            // aceを終了する。
            asd.Engine.Terminate();
        }
Exemplo n.º 9
0
        public GameMgr(int bestscore, bool isrestart)
        {
            //レイヤー登録
            {
                LayerOfBackGround = new asd.Layer2D();
                AddLayer(LayerOfBackGround);
                LayerOfBackGround_A = new asd.Layer2D();
                AddLayer(LayerOfBackGround_A);
                LayerOfMain = new asd.Layer2D();
                AddLayer(LayerOfMain);
                CameraOfMain     = new asd.CameraObject2D();
                CameraOfMain.Src = new asd.RectI(0, 0, asd.Engine.WindowSize.X, asd.Engine.WindowSize.Y);
                CameraOfMain.Dst = new asd.RectI(0, 0, asd.Engine.WindowSize.X, asd.Engine.WindowSize.Y);
                LayerOfMain.AddObject(CameraOfMain);
                LayerOfStatus = new asd.Layer2D();
                AddLayer(LayerOfStatus);
            }

            //オブジェクト配置

            //背景
            {
                BackGround         = new asd.TextureObject2D();
                BackGround.Texture = asd.Engine.Graphics.CreateTexture2D("Image/BackGround.png");
                LayerOfBackGround.AddObject(BackGround);

                BackGround_A = new asd.MapObject2D();
                for (int i = 0; i < 200; i++)
                {
                    asd.Chip2D chip = new asd.Chip2D();
                    chip.Texture  = asd.Engine.Graphics.CreateTexture2D("Image/Back_A.png");
                    chip.Position = new asd.Vector2DF(i * 640.0f, 0.0f);
                    BackGround_A.AddChip(chip);
                }
                CameraOfBackGround_A     = new asd.CameraObject2D();
                CameraOfBackGround_A.Src = new asd.RectI(0, 0, 640, 480);
                CameraOfBackGround_A.Dst = new asd.RectI(0, 0, 640, 480);
                LayerOfBackGround_A.AddObject(BackGround_A);
                LayerOfBackGround_A.AddObject(CameraOfBackGround_A);
            }

            //メイン
            {
                Airplane = new Player();
                LayerOfMain.AddObject(Airplane);
                BestScoreLine                 = new asd.GeometryObject2D();
                BoxOfBestScore                = new asd.RectangleShape();
                BoxOfBestScore.DrawingArea    = new asd.RectF(bestscore * 50.0f, 0, 5, 480);
                BestScoreLine.Shape           = BoxOfBestScore;
                BestScoreLine.Color           = new asd.Color(255, 255, 0);
                BestScoreLine.DrawingPriority = 3;
                LayerOfMain.AddObject(BestScoreLine);
                Walls   = new List <Wall>();
                Clouds  = new List <Cloud>();
                Rains   = new List <Rain>();
                Healers = new List <Healer>();
                Winds   = new List <Wind>();
            }

            //ステータス
            {
                HPBar                  = new asd.GeometryObject2D();
                BoxOfHPBar             = new asd.RectangleShape();
                BoxOfHPBar.DrawingArea = new asd.RectF(120, 440, Airplane.HP / Airplane.MaxHP * WidthOfHPBar, 20);
                HPBar.Shape            = BoxOfHPBar;
                HPBar.Color            = new asd.Color(255, 255, 255, 100);

                TextOfHP                = new asd.TextObject2D();
                TextOfHP.Font           = asd.Engine.Graphics.CreateDynamicFont("", 20, new asd.Color(255, 255, 255, 100), 0, new asd.Color(255, 255, 255, 100));
                TextOfHP.Text           = "HP";
                TextOfHP.Color          = new asd.Color(255, 255, 255, 100);
                TextOfHP.CenterPosition = TextOfHP.Font.CalcTextureSize(TextOfHP.Text, asd.WritingDirection.Horizontal).To2DF() / 2.0f;
                TextOfHP.Position       = new asd.Vector2DF(70.0f, 450.0f);

                TextOfScore          = new asd.TextObject2D();
                TextOfScore.Font     = asd.Engine.Graphics.CreateDynamicFont("", 20, new asd.Color(255, 255, 255), 0, new asd.Color(0, 0, 0));
                TextOfScore.Text     = "SCORE : 0";
                TextOfScore.Position = new asd.Vector2DF(10.0f, 10.0f);

                LayerOfStatus.AddObject(HPBar);
                LayerOfStatus.AddObject(TextOfHP);
                LayerOfStatus.AddObject(TextOfScore);
            }

            //スタート
            {
                LayerOfStart               = new asd.Layer2D();
                TextOfTitle                = new asd.TextObject2D();
                TextOfTitle.Font           = asd.Engine.Graphics.CreateDynamicFont("", 60, new asd.Color(255, 255, 255), 0, new asd.Color(255, 255, 255));
                TextOfTitle.Text           = "KAMI HIKOKI";
                TextOfTitle.CenterPosition = TextOfTitle.Font.CalcTextureSize(TextOfTitle.Text, asd.WritingDirection.Horizontal).To2DF() / 2.0f;
                TextOfTitle.Position       = new asd.Vector2DF(asd.Engine.WindowSize.X / 2.0f, asd.Engine.WindowSize.Y / 2.0f);
                TextOfPAK                = new asd.TextObject2D();
                TextOfPAK.Font           = asd.Engine.Graphics.CreateDynamicFont("", 20, new asd.Color(255, 255, 255), 0, new asd.Color(255, 255, 255));
                TextOfPAK.Text           = "Press Any Key";
                TextOfPAK.CenterPosition = TextOfPAK.Font.CalcTextureSize(TextOfPAK.Text, asd.WritingDirection.Horizontal).To2DF() / 2.0f;
                TextOfPAK.Position       = new asd.Vector2DF(asd.Engine.WindowSize.X / 2.0f, 430);
                LayerOfStart.AddObject(TextOfTitle);
                LayerOfStart.AddObject(TextOfPAK);
            }

            //ゲームオーバー
            {
                LayerOfGameOver               = new asd.Layer2D();
                TextOfGameOver                = new asd.TextObject2D();
                TextOfGameOver.Font           = asd.Engine.Graphics.CreateDynamicFont("", 100, new asd.Color(0, 0, 0), 0, new asd.Color(255, 255, 255));
                TextOfGameOver.Text           = "Game Over";
                TextOfGameOver.CenterPosition = TextOfGameOver.Font.CalcTextureSize(TextOfGameOver.Text, asd.WritingDirection.Horizontal).To2DF() / 2.0f;
                TextOfGameOver.Position       = new asd.Vector2DF(320.0f, 600.0f);

                LayerOfGameOver.AddObject(TextOfGameOver);

                CountOfGameOver = 0;
            }

            PairsOfWall = new SortedList <float, float>();
            Level       = 1;
            Count       = 0;
            Score       = 0;
            BestScore   = bestscore;
            IsRestart   = isrestart;

            if (!IsRestart)
            {
                AddLayer(LayerOfStart);
                LayerOfStatus.IsDrawn         = false;
                LayerOfMain.IsUpdated         = false;
                LayerOfBackGround_A.IsUpdated = false;
            }
            else
            {
                LayerOfStart.IsUpdated = false;

                // 音声ファイルを読み込む。BGMの場合、第2引数を false に設定することで、再生しながらファイルを解凍することが推奨されている。
                BGM = asd.Engine.Sound.CreateSoundSource("Sound/PaperPlane_Stage0.ogg", false);

                // 音声のループを有効にする。
                BGM.IsLoopingMode = true;

                // 音声のループ始端を1秒に、ループ終端を6秒に設定する。
                BGM.LoopStartingPoint = 2.0f;
                BGM.LoopEndPoint      = 15.714f;

                // 音声を再生する。
                id_BGM = asd.Engine.Sound.Play(BGM);
            }

            //LoadMap("MapData/Map.csv");
            MakeMap(100.0f);
        }
Exemplo n.º 10
0
        public void Run()
        {
            // aceを初期化する
            asd.Engine.Initialize("MapObject2D_Camera", 640, 480, new asd.EngineOption());

            //カメラを設定する。
            var camera = new asd.CameraObject2D();

            camera.Src = new asd.RectI(0, 0, 640, 480);
            camera.Dst = new asd.RectI(0, 0, 640, 480);

            {
                //マップオブジェクトを生成する。
                var mapObject = new asd.MapObject2D();

                var texture = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Sample2.png");

                //マップオブジェクトに50*50=2500個のチップを登録する。
                for (int i = 0; i < 50; ++i)
                {
                    for (int j = 0; j < 50; ++j)
                    {
                        //チップを生成する。
                        var chip = new asd.Chip2D();

                        //チップにテクスチャを設定する。
                        chip.Texture = texture;

                        //チップの描画先を指定する。
                        chip.Position = new asd.Vector2DF(i * 40 - 1000, j * 40 - 1000);

                        //マップオブジェクトにチップを追加する。
                        mapObject.AddChip(chip);
                    }
                }

                //レイヤーにマップオブジェクトを追加する。
                asd.Engine.AddObject2D(mapObject);

                //レイヤーにカメラオブジェクトを追加する。
                asd.Engine.AddObject2D(camera);
            }

            // aceが進行可能かチェックする。
            while (asd.Engine.DoEvents())
            {
                //カメラを移動させる
                var pos = camera.Src;
                pos.X += 1;
                pos.Y += 1;
                pos.X %= 1000;
                pos.Y %= 1000;
                camera.Src = pos;

                // aceを更新する。
                asd.Engine.Update();
            }

            // aceを終了する。
            asd.Engine.Terminate();
        }
Exemplo n.º 11
0
        public void Run()
        {
            // aceを初期化する。
            asd.Engine.Initialize("CameraObject2D", 640, 480, new asd.EngineOption());


            // テクスチャを生成する。
            {
                var tex0 = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Sample1.png");
                var obj0 = new asd.TextureObject2D();
                obj0.Texture        = tex0;
                obj0.CenterPosition = new asd.Vector2DF(256, 256);
                obj0.Position       = new asd.Vector2DF(320, 240);
                obj0.Scale          = new asd.Vector2DF(0.5f, 0.5f);

                asd.Engine.AddObject2D(obj0);
            }

            //一つ目の画面全体を写すカメラ。(オブジェクトをそのまま描画する。)
            {
                var camera1 = new asd.CameraObject2D();
                camera1.Src = new asd.RectI(0, 0, 640, 480);
                camera1.Dst = new asd.RectI(0, 0, 640, 480);
                asd.Engine.AddObject2D(camera1);
            }

            //二つ目のマウスポインタの周辺を拡大して表示するカメラ。
            var camera2 = new asd.CameraObject2D();

            asd.Engine.AddObject2D(camera2);

            //フレーム用テクスチャ画像を準備する。
            var frame = new asd.TextureObject2D();

            {
                var tex = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Frame.png");
                frame.Texture        = tex;
                frame.CenterPosition = new asd.Vector2DF(55.0f, 55.0f);

                asd.Engine.AddObject2D(frame);
            }

            // aceが進行可能かチェックする。
            while (asd.Engine.DoEvents())
            {
                //マウスポインタの位置を取得する。
                var pos = asd.Engine.Mouse.Position;

                //拡大用カメラの描画元を指定する。
                camera2.Src = new asd.RectI((int)(pos.X) - 25, (int)(pos.Y) - 25, 50, 50);

                //ポインタを中心に100x100の拡大画像を表示する。
                camera2.Dst = new asd.RectI((int)(pos.X) - 50, (int)(pos.Y) - 50, 100, 100);

                //フレーム画像の描画中心をマウスポインタの位置に合わせる。
                frame.Position = pos;

                // aceを更新する。
                asd.Engine.Update();
            }

            // aceを終了する。
            asd.Engine.Terminate();
        }