Exemplo n.º 1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            //SB.Begin();
            SB.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null);
#if TeddyCrashout
            try {
#endif
            if (Current != null)
            {
                Current.Draw(this, gameTime);
            }
#if TeddyCrashout
        }

        catch (System.Exception ex) {
            Crash.Error(this, $"D-Flow Error:\n{ex.Message}\n\nTraceback:\n{ex.StackTrace}\n\nTarget:\n{ex.TargetSite}\n\nSource:\n{ex.Source}\n\nIf you see this message you very likely fell victim to a bug!\n\nPlease go to my issue tracker and report it, if it hasn't been done before.\nhttps://github.com/TrickyGameTools/TeddyBear/issues\n\nThank you!");
        }
#endif
            DrawTex(MousePointer, MX, MY);
            SB.End();

            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            var gpstate = GamePad.GetState(PlayerIndex.One);
            var kbstate = Keyboard.GetState();

            // This line will for now remain, but may have to leave once the editor is really getting to move
            if (Main.DoQuit || (kbstate.IsKeyDown(Keys.Q) && (kbstate.IsKeyDown(Keys.LeftControl) || kbstate.IsKeyDown(Keys.RightControl))))
            {
                Main.Me.SaveMap();
                Exit();
            }

            // TODO: Add your update logic here
            var mstate = Mouse.GetState();

            MX = mstate.X;
            MY = mstate.Y;
#if TeddyCrashout
            try {
#endif
            if (Current != null)
            {
                Current.Update(this, gameTime, mstate, gpstate, kbstate);
            }
#if TeddyCrashout
        }

        catch (System.Exception ex) {
            Crash.Error(this, $"U-Flow Error:\n{ex.Message}\n\nTraceback:\n{ex.StackTrace}\n\nTarget:\n{ex.TargetSite}\n\nSource:\n{ex.Source}\n\nIf you see this message you very likely fell victim to a bug!\n\nPlease go to my issue tracker and report it, if it hasn't been done before.\nhttps://github.com/TrickyGameTools/TeddyBear/issues\n\nThank you!");
        }
#endif
            base.Update(gameTime);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            ProjectData.InitJCRDrivers();
            ProjectData.SetGame(this);

            #region Screen Size
            //graphics.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width;
            //graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
            graphics.HardwareModeSwitch = false;
            graphics.IsFullScreen       = true;
            graphics.ApplyChanges();
            #endregion

            #region TeddyBear Draw MonoGame Driver
            TeddyBear.TeddyDraw_MonoGame.Init();
            #endregion

            // Sprite Batch
            SB = new SpriteBatch(GraphicsDevice);

            // Mouse Pointer
            MousePointer = ProjectData.GetTex(GraphicsDevice, "MousePointer.png");

            // TQMG
            TQMG.Init(graphics, GraphicsDevice, SB, ProjectData.JCR);
            TQMG.RegLog(ProjectData.Log);

            // Exporter
            TeddyXport.XPort.init();

            // Unknown
            TeddyBear.TeddyDraw_MonoGame.SetUnknown(TQMG.GetImage("Unknown.png"));
            TeddyBear.TeddyDraw_MonoGame.Log = ProjectData.Log;


            // Do we have a project and a map?
#if DEBUG
            if (false)
            {
            }              // just some crap as things are different while debugging.
#else
            if (ProjectData.args.Length < 3)
            {
                Crash.Error(this, "No arguments given!\nUsage: TeddyEdit <project> <map>\n \n If you are not sure how to use this tool, use the launcher in stead!");
            }
#endif
            else
            {
#if DEBUG
                ProjectData.Project = "Test";
#else
                ProjectData.Project = ProjectData.args[1];
#endif
                if (!ProjectData.AllWell)
                {
                    Crash.Error(this, $"Project loading failed! {ProjectData.Project}");
                }
                else
                {
#if DEBUG
                    ProjectData.MapFile = $"{Dirry.AD(ProjectData.ProjectConfig.C("LevelDir"))}/Test Map";
#else
                    ProjectData.MapFile = $"{Dirry.AD(ProjectData.ProjectConfig.C("LevelDir"))}/{ProjectData.args[2]}";
#endif
                }
            }


            // Teddy Save Log
            TeddyBear.TeddySave.SetLog(ProjectData.Log);

            // Final
            base.Initialize();

            if (ProjectData.AllWell)
            {
                SetStage(Main.Me);
            }
        }