예제 #1
0
        //-----------------------------------------------------
        // Draw the current scene to the form, then cycle
        // through all game elements to update image
        //-----------------------------------------------------
        public void PaintForm()
        {
            graphics.DrawImage(screenBmp, 0, 0, screenBmp.Width * 2, screenBmp.Height * 2);

            Graphics g = Graphics.FromImage(screenBmp);

            g.Clear(Color.LightBlue);

            Figures.DrawSky(Buffers.XView, 0, Buffers.NH * Buffers.W, Buffers.NV * Buffers.H);

            //BackGr.StartClouds();

            for (int x = Buffers.XView / Buffers.W; x < Buffers.XView / Buffers.W + Buffers.NH; x++)
            {
                for (int y = 0; y < 24; y++)
                {
                    Figures.Redraw(x, y);
                }
            }

            BackGr.DrawBackGr(true);
            //ReadColorMap();

            if (Buffers.Options.Stars != 0)
            {
                Stars.ShowStars();
            }

            Enemies.ShowEnemies();

            if (!Play.OnlyDraw)
            {
                Players.DrawPlayer();
            }

            // ShowPage
        }
예제 #2
0
        //-------------------------------------------------
        // Draw the Demo
        //-------------------------------------------------
        private static void DrawDemo()
        {
            int i, j;

            SaveScreen[FormMarioPort.formRef.CurrentPage()].BackGrAddr = FormMarioPort.formRef.PushBackGr(X, Y, Buffers.W + 4, 2 * Buffers.H);
            SaveScreen[FormMarioPort.formRef.CurrentPage()].XPos       = X;
            SaveScreen[FormMarioPort.formRef.CurrentPage()].YPos       = Y;
            SaveScreen[FormMarioPort.formRef.CurrentPage()].Visible    = true;

            switch (Buffers.Demo)
            {
            case Buffers.dmDownInToPipe:
            case Buffers.dmUpOutOfPipe:
            {
                FormMarioPort.formRef.DrawPart(X, Y + DemoY, Buffers.W, 2 * Buffers.H, 0, 2 * Buffers.H - DemoY - 1, Buffers.Pictures[Buffers.Player, Buffers.data.mode[Buffers.Player], Walkingmode, Direction]);
                break;
            }

            case Buffers.dmUpInToPipe:
            case Buffers.dmDownOutOfPipe:
            {
                FormMarioPort.formRef.DrawPart(X, Y + DemoY, Buffers.W, 2 * Buffers.H, -DemoY, 2 * Buffers.H, Buffers.Pictures[Buffers.Player, Buffers.data.mode[Buffers.Player], Walkingmode, Direction]);
                Figures.Redraw(MapX, MapY - 1);
                Figures.Redraw(MapX + 1, MapY - 1);
                break;
            }

            case Buffers.dmDead:
            {
                FormMarioPort.formRef.DrawImage(X, Y, Buffers.W, 2 * Buffers.H, Buffers.Pictures[Buffers.Player, Buffers.data.mode[Buffers.Player], Walkingmode, Direction]);
                break;
            }
            }
            OldX = X;
            OldY = Y;
        }
예제 #3
0
파일: Play.cs 프로젝트: zzsun777/MarioPort
        //-------------------------------------------------------------------
        // main loop of the world to handle drawing, hiding, and showing of the
        // resources. When mario runs out of lives the thread is killed and cleaned
        // up. read: GAME OVER!
        //-------------------------------------------------------------------
        static bool Restart()
        {
            bool PlayWorld = false;

            TextStatus = false;
            //InitStatus();

            Blocks.InitBlocks();
            TmpObj.InitTempObj();
            Glitter.ClearGlitter();
            Enemies.ClearEnemies();

            // ShowPage

            Buffers.GameDone = false;
            Buffers.Passed   = false;

            for (int i = Enemies.StartEnemiesAt * -1; i < Buffers.NH + Enemies.StartEnemiesAt; i++)
            {
                int j = (Buffers.XView / Buffers.W) + i;
                Enemies.StartEnemies(j, (short)(1 - 2 * System.Convert.ToByte(j > Players.MapX)));
            }

            //   SetYOffset (YBase);

            /*for (int i = 0; i < FormMarioPort.MAX_PAGE; i++)
             * {
             * //      DrawSky (XView, 0, NH * W, NV * H);
             *
             * //      StartClouds();
             *
             * for (int x = Buffers.XView / Buffers.W; x < Buffers.XView / Buffers.W + Buffers.NH; x++)
             *    for (int y = 0; y < Buffers.NV - 1; y++)
             *       Figures.Redraw(x, y);
             *
             * BackGr.DrawBackGr(true);
             * //ReadColorMap();
             *
             * if (Buffers.Options.Stars != 0)
             *    Stars.ShowStars();
             *
             * Enemies.ShowEnemies();
             * if (!OnlyDraw)
             *    Players.DrawPlayer();
             *
             * FormMarioPort.formRef.ShowPage();
             * }
             */

            Buffers.Demo = Buffers.dmNoDemo;
            Waiting      = false;

            //Palettes.NewPalette (P256*);
            //for (int i = 1; i < 100; i++)
            //{
            //Waterfalls()?
            //Palettes.BlinkPalette();
            //}

            Figures.SetSkyPalette();
            BackGr.DrawPalBackGr();
            //Palettes.InitGrass();

            if (OnlyDraw)
            {
                return(false);
            }

            //   Palettes.UnLockPal();
            //   FadeUp (64);
            //   Palettes.ReadPalette (Palette);

            TextStatus = Stat;// && !KeyBoard.PlayingMacro());

            //uint counter = 0;
            do //until gamedone
            {
                try
                {
                    //Console.WriteLine("Restart Loop");

                    //if (!Keyboard.PlayingMacro)
                    //{
                    //   if (Key = 31) //'S'
                    //   {
                    //      Stat = !Stat;
                    //      TextStatus = Stat;
                    //      Keyboard.Key = 255;
                    //   }
                    //   if (Keyboard.Key = 16) //'Q'
                    //   {
                    //      if (Buffers.BeeperSound)
                    //         Buffers.BeeperOff();
                    //      else
                    //      {
                    //         Buffers.BeeperOn();
                    //         Buffers.Beep (80);
                    //      }
                    //      Key = 255;
                    //   }

                    //   if (Key == 197 || Key == 198) //Pause/Break
                    //   {
                    //      Music.PauseMusic();
                    //      //do
                    //      //{
                    //      //   while (Keyboard.Key = 197) {} //busy wait of some sort?
                    //      //} while //(Keyboard.kbHit);
                    //   }
                    //   else
                    //   {
                    //      if (Keyboard.Key != 0)
                    //      {
                    //         Buffers.GameDone = true;
                    //         Buffers.Passed = true;
                    //      }
                    //   }

                    //   if (Buffers.TextCounter) //in 40..40+MAX_PAGE
                    //      ShowObjects = false;

                    //   HideGlitter();
                    //   if (Options.Stars != 0)
                    //      HideStars();
                    //   if (ShowObjects)
                    //      HideTempObj();
                    //   if (ShowScore)
                    //      HideTotalBack();
                    //   ErasePlayer();
                    //   if (ShowObjects)
                    //   {
                    //      HideEnemies();
                    //      EraseBlocks();
                    //   }
                    //}

                    // { Fade };
                    Buffers.LavaCounter++;

                    if (!Waiting)
                    {
                        if (Buffers.Demo == Buffers.dmNoDemo)
                        {
                            Enemies.MoveEnemies();
                            Players.MovePlayer();
                        }
                        else
                        {
                            Players.DoDemo();
                        }
                    }



                    if (!Waiting)
                    {
                        if (Buffers.Passed)
                        {
                            if (Buffers.Demo == Buffers.dmNoDemo || Players.InPipe)
                            {
                                Waiting             = true;
                                Buffers.TextCounter = 0;
                            }
                            Buffers.TextCounter++;
                            if (!ShowScore && (Buffers.TextCounter >= 50 && Buffers.TextCounter < 50 + FormMarioPort.MAX_PAGE)) //in 50..50 + MAX_PAGE
                            {
                                //SetFont (0, Bold + Shadow);
                                //TXT.CenterText (20, Buffers.PlayerName [Buffers.Player], 30.ToString("X"));
                                //SetFont(1, Bold + Shadow);
                                //TXT.CenterText (40, "STAGE CLEAR!", 31);
                                if (Buffers.TextCounter == (50 + FormMarioPort.MAX_PAGE))
                                {
                                    ShowScore = true;
                                }
                            }
                        }
                        else
                        if (Buffers.GameDone)
                        {
                            Buffers.data.lives[Buffers.Player]--;
                            Buffers.data.mode[Buffers.Player] = Buffers.mdSmall;
                            Buffers.TextCounter = 0;
                            Buffers.data.score[Buffers.Player] += Buffers.LevelScore;
                            Waiting          = true;
                            Buffers.GameDone = false;
                        }
                    }



                    //if (Keyboard.Key = 25) //P
                    //   Pause();

                    if (ShowScore && (Buffers.TextCounter == 120) && (Buffers.LevelScore > 0))
                    {
                        int i = (int)(Buffers.LevelScore - 50);
                        if (i < 0)
                        {
                            i = 0;
                        }
                        Buffers.data.score[Buffers.Player] += Buffers.LevelScore - 1;
                        Buffers.LevelScore  = i;
                        Buffers.TextCounter = 119;
                        CountingScore       = true;
                    }
                    else
                    {
                        CountingScore = false;
                    }

                    if (Waiting)
                    {
                        Buffers.TextCounter++;
                        if (Buffers.data.lives[Buffers.Player] == 0)
                        {
                            if (Buffers.TextCounter >= 100 && Buffers.TextCounter < 100 + FormMarioPort.MAX_PAGE) //in 100..100 + MAX_PAGE
                            {
                                //SetFont (0, Bold + Shadow);
                                //CenterText (20, Buffers.PlayerName[Buffers.Player], 30.ToString("X"));
                                //SetFont (1, Bold + Shadow);
                                //CenterText (40, "GAME OVER", 31);
                                ShowScore = true;
                            }
                            if (Buffers.TextCounter > 350)
                            {
                                Buffers.GameDone = true;
                            }
                        }
                        else
                        if (Buffers.Passed)
                        {
                            if (Buffers.TextCounter > 250)
                            {
                                Waiting = false;
                            }
                        }
                        else
                        if (Buffers.TextCounter > 100)
                        {
                            Buffers.GameDone = true;
                        }
                    }

                    TmpObj.MoveTempObj();
                    Blocks.MoveBlocks();

                    if (Keyboard.kbEsc)
                    {
                        Buffers.QuitGame = true;
                    }

                    MoveScreen();
                    TmpObj.RunRemove();

                    if (Buffers.Options.Horizon < Buffers.NV)
                    {
                        int j = Buffers.Options.Horizon;
                        for (int i = 0 / Buffers.W; i < Buffers.NH; i++)
                        {
                            int k = Buffers.XView / Buffers.W + (i + Buffers.LavaCounter / 8) % (Buffers.NH + 1);
                            if (Buffers.WorldMap[k, j] == '%')
                            {
                                Figures.Redraw(k, j);
                            }
                        }
                    }


                    //FormMarioPort.formRef.ResetStack();

                    if (ShowObjects)
                    {
                        Blocks.DrawBlocks();
                        Enemies.ShowEnemies();
                    }
                    Players.DrawPlayer();

                    if (ShowScore)
                    {
                        ShowTotalBack();
                    }
                    //if (TextStatus)
                    //   Status.ShowStatus();
                    if (ShowObjects)
                    {
                        TmpObj.ShowTempObj();
                    }
                    if (Buffers.Options.Stars != 0)
                    {
                        Stars.ShowStars();
                    }
                    Glitter.ShowGlitter();

                    Buffers.LastXView[FormMarioPort.formRef.CurrentPage()] = Buffers.XView;

                    //if (ShowRetrace)
                    //   SetPalette(0, 0, 0, 0);

                    // ShowPage

                    //if (ShowRetrace)
                    //   SetPalette( 0, 63, 63, 63);

                    BackGr.DrawPalBackGr();

                    //Palette.BlinkPalette();

                    Music.PlayMusic();

                    if (Players.InPipe && Keyboard.PlayingMacro)
                    {
                        Buffers.GameDone = true;
                    }


                    if (Players.InPipe && !Buffers.GameDone && !Waiting)
                    {
                        Enemies.StopEnemies();
                        Glitter.ClearGlitter();
                        //FadeDown(64);
                        //FormMarioPort.formRef.LockPal();
                        //FormMarioPort.formRef.ClearVGAMem();

                        switch (Players.PipeCode[1])
                        {
                        case 'à':
                            FindPipeExit();
                            //Delay(100);
                            break;

                        case 'á':
                            //Swap();
                            FindPipeExit();
                            break;

                        case 'ç':
                            Buffers.GameDone = true;
                            PlayWorld        = true;
                            break;
                        }

                        Players.InitPlayer(Players.MapX * Buffers.W + Buffers.W / 2, (Players.MapY - 1) * Buffers.H, Buffers.Player);

                        FormMarioPort.formRef.SetView(Buffers.XView, Buffers.YView);

                        for (int i = 0; i < FormMarioPort.MAX_PAGE; i++)
                        {
                            Buffers.LastXView[i] = Buffers.XView;
                        }

                        if (Players.PipeCode[1] == 'à')
                        {
                            Restart();
                        }
                        else
                        if (Players.PipeCode[1] == 'á')
                        {
                            BuildLevel();
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("error" + e);
                }

                FormMarioPort.formRef.PaintForm();
                System.Threading.Thread.Sleep(1 / 60 * 1000);
            } while (!Buffers.GameDone && !Buffers.QuitGame);
            return(PlayWorld);
        }
예제 #4
0
파일: Play.cs 프로젝트: zzsun777/MarioPort
        //-------------------------------------------------------------------
        // Scrolls the screen to move along with mario as he moves.
        //-------------------------------------------------------------------
        public static void MoveScreen()
        {
            int    Scroll;
            int    N1, N2;
            int    OldX, NewX, Page;
            Random rand = new Random();

            Page   = FormMarioPort.formRef.CurrentPage();
            Scroll = Buffers.XView - Buffers.LastXView[Page];
            if (!Players.EarthQuake)
            {
                FormMarioPort.formRef.SetView(Buffers.XView, Buffers.YView);
            }
            else
            {
                Players.EarthQuakeCounter++;
                if (Players.EarthQuakeCounter > 0)
                {
                    Players.EarthQuake = false;
                }
                int Rand1 = rand.Next(0, 2);
                int Rand2 = rand.Next(0, 2);
                FormMarioPort.formRef.SetView(Buffers.XView, Buffers.YView + Rand1 - Rand2);
            }
            if (Scroll < 0)
            {
                Enemies.StartEnemies((Buffers.XView / Buffers.W) - Enemies.StartEnemiesAt, 1);
            }
            else if (Scroll > 0)
            {
                Enemies.StartEnemies((Buffers.XView / Buffers.W) + Buffers.NH + Enemies.StartEnemiesAt, -1);
            }

            int i = Buffers.Options.Horizon;

            BackGr.DrawBackGr(false);
            Buffers.Options.Horizon = (byte)i;

            if (Scroll > 0)
            {
                for (int j = Buffers.LastXView[Page]; j < Buffers.XView; j++)
                {
                    i = j - Buffers.W - Buffers.W;
                    if (i >= 0)
                    {
                        FormMarioPort.formRef.PutPixel(i, 0, 0);
                    }
                    i = Buffers.W - j % Buffers.W - 1;
                    Figures.Redraw(j / Buffers.W + Buffers.NH + 1, i);
                }
            }

            if (Scroll < 0)
            {
                for (int j = Buffers.LastXView[Page]; j > Buffers.XView; j--)
                {
                    i = Buffers.W - j % Buffers.W - 1;
                    Figures.Redraw(j / Buffers.W - 1, i);
                }
            }
        }