예제 #1
0
        public static void PDL()
        {
            Player_Data PDL_PD = new Player_Data();

            PDL_PD.Player_X         = 2;
            PDL_PD.Player_Y         = 2;
            PDL_PD.Player_Dimension = 0;
            PDL_PD.Player_Speed     = 2.0;
        }
예제 #2
0
        //Draw_String
        static void Draw_String(Player_Data PD, int FPS)
        {
            // 文字列の描画
            DX.ChangeFontType(DX.DX_FONTTYPE_ANTIALIASING_4X4);
            DX.DrawString(0, 2, "X座標 : " + PD.Player_X.ToString(), Color_White);
            DX.DrawString(0, 20, "Y座標 : " + PD.Player_Y.ToString(), Color_White);
            DX.DrawString(0, 38, "ディメンション : " + PD.Player_Dimension.ToString(), Color_White);
            DX.DrawString(0, 56, "SPEED : " + PD.Player_Now_Speed.ToString(), Color_White);
            DX.DrawString(0, 74, "FPS : " + FPS.ToString(), Color_White);
            DX.DrawString(0, 92, "衝突 : " + CharacterControl.Collision.ToString(), Color_White);

            Console.WriteLine("X座標 : " + PD.Player_X.ToString());
            Console.WriteLine("Y座標 : " + PD.Player_Y.ToString());
            Console.WriteLine("衝突 : " + CharacterControl.Collision.ToString());
            //Console.WriteLine((int)(25+0.99999999999999));
        }
예제 #3
0
        //メイン描画処理ライン
        static public void GameDrawMain(Player_Data PD, int FPS)
        {
            //画像描画
            {
                //マップ描画
                Draw_Map(PD.Player_X, PD.Player_Y, PD.Player_Dimension, Map_Data.map_data);

                //プレイヤー描画
                {
                    DX.DrawExtendGraph(Window_Width / 2 - (Setting_TileSize / 2), Window_Heigt / 2 - (Setting_TileSize / 2), Window_Width / 2 + Setting_TileSize - (Setting_TileSize / 2), Window_Heigt / 2 + Setting_TileSize - (Setting_TileSize / 2), Tile_Data.TileGraphicData[3], DX.TRUE);
                }
            }

            //文字列描画(座標,FPS値等)
            {
                Draw_String(PD, FPS);
            }
        }
예제 #4
0
        static public void Player_Control(Player_Data PD, double ElapsedTime1F)
        {
            //変数宣言
            double Player_X, Player_Y, Player_Speed, Player_Now_Speed;
            double tmp_Player_X, tmp_Player_Y;
            int    Player_Dimension;
            bool   Collision1 = false;
            bool   Collision2 = false;
            bool   Collision3 = false;

            //Player_Dataの内容を代入
            tmp_Player_X     = Player_X = PD.Player_X; //tmp = 移動前座標
            tmp_Player_Y     = Player_Y = PD.Player_Y;
            Player_Dimension = PD.Player_Dimension;
            Player_Speed     = PD.Player_Speed;

            //操作 Math.Floor()
            {
                //Esc
                if (Key_State.KeyState[DX.KEY_INPUT_ESCAPE] == 1 && Key_State.KeyStateOld[DX.KEY_INPUT_ESCAPE] == 0)
                {
                    Game_Main.GameControlHandle = "GameEscMenu";
                    return;
                }
                //左シフト
                switch (Key_State.KeyState[DX.KEY_INPUT_LSHIFT])
                {
                case 1:
                    Player_Now_Speed = Player_Speed * 3;
                    break;

                default:
                    Player_Now_Speed = Player_Speed;
                    break;
                }
                //W
                switch (Key_State.KeyState[DX.KEY_INPUT_W])
                {
                case 1:
                    Player_Y -= Player_Now_Speed * ElapsedTime1F;
                    break;

                default:
                    break;
                }
                //S
                switch (Key_State.KeyState[DX.KEY_INPUT_S])
                {
                case 1:
                    Player_Y += Player_Now_Speed * ElapsedTime1F;
                    break;

                default:
                    break;
                }
                //A
                switch (Key_State.KeyState[DX.KEY_INPUT_A])
                {
                case 1:
                    Player_X -= Player_Now_Speed * ElapsedTime1F;
                    break;

                default:
                    break;
                }
                //D
                switch (Key_State.KeyState[DX.KEY_INPUT_D])
                {
                case 1:
                    Player_X += Player_Now_Speed * ElapsedTime1F;
                    break;

                default:
                    break;
                }

                //マウスホイール
                Player_Dimension += DX.GetMouseWheelRotVol();
                if (Player_Dimension < 0)
                {
                    Player_Dimension = 0;
                }
                else if (Player_Dimension > 1)
                {
                    Player_Dimension = 1;
                }
            }

            //値修正
            {
                //Xがマップ左端に衝突した場合
                if (Player_X <= 0)
                {
                    Player_X = 0;
                }
                //Xがマップ右端に衝突した場合
                if (Player_X >= (Map_Data.map_data[Player_Dimension][0][0].GetLength(0) - 1))
                {
                    Player_X = (Map_Data.map_data[Player_Dimension][0][0].GetLength(0) - 1);
                }
                //Yがマップ上端に衝突した場合
                if (Player_Y < 0)
                {
                    Player_Y = 0;
                }
                //Yがマップ下端に衝突した場合
                if (Player_Y >= (Map_Data.map_data[Player_Dimension][0].GetLength(0) - 1))
                {
                    Player_Y = (Map_Data.map_data[Player_Dimension][0].GetLength(0) - 1);
                }


                //X(tmp)がマップ右端に衝突した場合
                if (tmp_Player_X >= (Map_Data.map_data[Player_Dimension][0][0].GetLength(0) - 1))
                {
                    tmp_Player_X = (Map_Data.map_data[Player_Dimension][0][0].GetLength(0) - 1);
                }
                //Y(tmp)がマップ下端に衝突した場合
                if (tmp_Player_Y >= (Map_Data.map_data[Player_Dimension][0].GetLength(0) - 1))
                {
                    tmp_Player_Y = (Map_Data.map_data[Player_Dimension][0].GetLength(0) - 1);
                }
            }


            ////当たり判定の処理
            {
                //埋まったとき 頂点4点が衝突判定のとき、4点全ての判定がなくなるまで当たり判定無効
                {
                    if ((Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)Player_Y][(int)Player_X]] == true &&
                         Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)(Player_Y + 0.99999999999999)][(int)Player_X]] == true &&
                         Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)Player_Y][(int)(Player_X + 0.99999999999999)]] == true &&
                         Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)(Player_Y + 0.99999999999999)][(int)(Player_X + 0.99999999999999)]] == true) || (
                            Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)Player_Y][(int)Player_X]] == true &&
                            Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)(Player_Y + 0.99999999999999)][(int)Player_X]] == true &&
                            Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)Player_Y][(int)(Player_X + 0.99999999999999)]] == true &&
                            Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)(Player_Y + 0.99999999999999)][(int)(Player_X + 0.99999999999999)]] == true))
                    {
                        disable_collision = true;
                    }

                    if (disable_collision == true && ((Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)Player_Y][(int)Player_X]] == false &&
                                                       Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)(Player_Y + 0.99999999999999)][(int)Player_X]] == false &&
                                                       Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)Player_Y][(int)(Player_X + 0.99999999999999)]] == false &&
                                                       Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)(Player_Y + 0.99999999999999)][(int)(Player_X + 0.99999999999999)]] == false) && (
                                                          Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)Player_Y][(int)Player_X]] == false &&
                                                          Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)(Player_Y + 0.99999999999999)][(int)Player_X]] == false &&
                                                          Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)Player_Y][(int)(Player_X + 0.99999999999999)]] == false &&
                                                          Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)(Player_Y + 0.99999999999999)][(int)(Player_X + 0.99999999999999)]] == false)))
                    {
                        disable_collision = false;
                    }
                }
                //Console.WriteLine("disable_collison:"+disable_collision.ToString());


                //衝突したかどうか
                if (disable_collision == false)
                {
                    //Xだけで判定 y == tmp_Player_Y
                    if (Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)tmp_Player_Y][(int)Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)(tmp_Player_Y + 0.99999999999999)][(int)Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)tmp_Player_Y][(int)(Player_X + 0.99999999999999)]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)(tmp_Player_Y + 0.99999999999999)][(int)(Player_X + 0.99999999999999)]] == true)
                    {
                        Collision1 = true;
                    }
                    else if (Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)tmp_Player_Y][(int)Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)(tmp_Player_Y + 0.99999999999999)][(int)Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)tmp_Player_Y][(int)(Player_X + 0.99999999999999)]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)(tmp_Player_Y + 0.99999999999999)][(int)(Player_X + 0.99999999999999)]] == true)
                    {
                        Collision1 = true;
                    }

                    //Yだけで判定 x == tmp_Player_X
                    if (Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)Player_Y][(int)tmp_Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)(Player_Y + 0.99999999999999)][(int)tmp_Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)Player_Y][(int)(tmp_Player_X + 0.99999999999999)]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)(Player_Y + 0.99999999999999)][(int)(tmp_Player_X + 0.99999999999999)]] == true)
                    {
                        Collision2 = true;
                    }
                    else if (Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)Player_Y][(int)tmp_Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)(Player_Y + 0.99999999999999)][(int)tmp_Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)Player_Y][(int)(tmp_Player_X + 0.99999999999999)]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)(Player_Y + 0.99999999999999)][(int)(tmp_Player_X + 0.99999999999999)]] == true)
                    {
                        Collision2 = true;
                    }

                    //X, Yで判定
                    if ((Collision1 == false && Collision2 == false) && (Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)Player_Y][(int)Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)(Player_Y + 0.99999999999999)][(int)Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)Player_Y][(int)(Player_X + 0.99999999999999)]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][0][(int)(Player_Y + 0.99999999999999)][(int)(Player_X + 0.99999999999999)]] == true))
                    {
                        Collision3 = true;
                    }
                    else if (((Collision1 == false && Collision2 == false) || (Collision1 == false && Collision2 == false)) && (Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)Player_Y][(int)Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)(Player_Y + 0.99999999999999)][(int)Player_X]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)Player_Y][(int)(Player_X + 0.99999999999999)]] == true || Tile_Data.Tile_Collision[Map_Data.map_data[Player_Dimension][1][(int)(Player_Y + 0.99999999999999)][(int)(Player_X + 0.99999999999999)]] == true))
                    {
                        Collision3 = true;
                    }

                    //上3つのどれかでtrueになったとき
                    Collision = false;
                    if (Collision1 == true || Collision2 == true || Collision3 == true)
                    {
                        Collision = true;
                    }
                }



                //衝突した場合
                if (Collision == true && /*頂点4点すべて衝突判定の場合は当たり判定無効->*/ disable_collision == false)
                {
                    //X
                    if (Collision1 == true || Collision3 == true)
                    {
                        if (tmp_Player_X > Player_X)//Xが小さくなった場合
                        {
                            Player_X = (int)Player_X + 1;
                        }
                        else if (tmp_Player_X < Player_X)//Xが大きくなった場合
                        {
                            Player_X = (int)Player_X;
                        }
                    }
                    //Y
                    if (Collision2 == true || Collision3 == true)
                    {
                        if (tmp_Player_Y > Player_Y)//Yが小さくなった場合
                        {
                            Player_Y = (int)Player_Y + 1;
                        }
                        else if (tmp_Player_Y < Player_Y)//Yが大きくなった場合
                        {
                            Player_Y = (int)Player_Y;
                        }
                    }
                }
            }

            //変更された座標等を代入
            PD.Player_X         = Player_X;
            PD.Player_Y         = Player_Y;
            PD.Player_Dimension = Player_Dimension;
            PD.Player_Now_Speed = Player_Now_Speed;
        }
예제 #5
0
        static public void GameMain()
        {
            ////変数////
            //時間関係
            int    FPS, FPSCounter;
            long   NowTime, LastTime, FPSCheckTime; //現在の時間, 前回の時間, FPS計算用時間
            double ElapsedTime1F;                   //1フレーム経過にかかった時間(秒)

            //FPS計測関係の初期化
            {
                LastTime   = FPSCheckTime = DX.GetNowHiPerformanceCount();
                FPS        = 0;
                FPSCounter = 0;
            }

            //テクスチャ読み込み
            Tile_Data.TileData();   //
            Graphic_Data.Graphic_Data_Load();

            //Player_Data読み込み
            Player_Data_Load.PDL();                 //プレイヤーのデータを読み込む(Player_Dataに)
            Player_Data PD = new Player_Data();     //Player_Dataのインスタンス化

            //コントロール
            GameControlHandle = "GameMain";

            ///////////////////////////////////////////
            //メインループ
            while (DX.ScreenFlip() == 0 && DX.ProcessMessage() == 0 && DX.ClearDrawScreen() == 0)
            {
                //時間関係
                NowTime       = DX.GetNowHiPerformanceCount();    //現在の時間を取得
                ElapsedTime1F = (NowTime - LastTime) / 1000000.0; //1フレーム経過にかかった時間(秒)
                LastTime      = NowTime;

                //FPS計測
                FPSCounter++;
                if (NowTime - FPSCheckTime > 1000000)
                {
                    FPS          = FPSCounter;
                    FPSCounter   = 0;
                    FPSCheckTime = NowTime;
                }

                // キーボード押下状態の読み込み
                Array.Copy(Key_State.KeyState, Key_State.KeyStateOld, 256);
                DX.GetHitKeyStateAll(Key_State.KeyState);

                //描画
                Game_Draw_Main.GameDrawMain(PD, FPS);

                //操作
                if (GameControlHandle == "GameMain")
                {
                    CharacterControl.Player_Control(PD, ElapsedTime1F);
                }
                else if (GameControlHandle == "GameEscMenu")
                {
                    C_GameEscMenu.CGameEscMenu();
                }
            }
        }