Ejemplo n.º 1
0
        private static void FPS()
        {
            Time time = clock.ElapsedTime;

            win.SetTitle("FPS : " + (1.0f / time.AsSeconds()).ToString());
            clock.Restart();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gameloop Update
        /// </summary>
        public void Run()
        {
            ContentLoader.LoadContent();
            Initialize();

            tFpsSet = cFpsSet.ElapsedTime;

            while (Window.IsOpen)
            {
                // Game Logic

                if (UpdateTime)
                {
                    Window.DispatchEvents();
                    Update();
                    UpdateTime = false;
                    tFpsSet    = cFpsSet.ElapsedTime;
                }

                if (tFpsSet.AsSeconds() >= (float)1 / (float)iFPSlimit)
                {
                    cFpsSet.Restart();

                    Window.Clear(ClearColor);
                    Draw();
                    Window.Display();

                    iframesreview++;

                    tFpsSet    = cFpsSet.ElapsedTime;
                    UpdateTime = true;
                }
                else
                {
                    tFpsSet = cFpsSet.ElapsedTime;
                }



                // Reviewing FPS on Console

                tFpsReview = cFpsReview.ElapsedTime;
                if (tFpsReview.AsMilliseconds() >= 1000)
                {
                    //Console.Clear();
                    //Console.WriteLine(iframesreview + " Frames per Second");
                    iframesreview = 0;
                    cFpsReview.Restart();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates Player Logic
        /// </summary>
        /// <param name="VirtualPlayerPosition">Virtual Player Position, aka Position if the Player would move, not the Map</param>
        /// <param name="up">Bool allowing up Movement</param>
        /// <param name="down">Bool allowing down Movement</param>
        /// <param name="right">Bool allowing right Movement</param>
        /// <param name="left">Bool allowing left Movement</param>
        public void Update(ref Vector2f VirtualPlayerPosition, ref bool up, ref bool down, ref bool right, ref bool left)
        {
            CollisionDetection(ref VirtualPlayerPosition, ref up, ref down, ref right, ref left, sCharacter.Radius * 2, sCharacter.Radius * 2);

            PlayerRotation();

            if (Input.Shoot)
            {
                tShoot = cShoot.ElapsedTime;

                if (tShoot.AsMilliseconds() > 333)
                {
                    cShoot.Restart();
                    Shoot(MainMap.GetTileMapPosition());
                }
            }

            for (int x = 0; x < lProjectile.Count; x++)
            {
                lProjectile[x].Update();
            }

            DisposeProjectile(lProjectile, uDamage);

            fProcentualHealth = (float)fHealth / (float)iHealthMax;

            if (fHealth >= 0)
            {
                sCharacter.FillColor = new Color(255, (byte)(0 + (255 * fProcentualHealth)), (byte)(0 + (255 * fProcentualHealth)));
            }

            tRegenerate = cRegenarate.ElapsedTime;

            if (tRegenerate.AsSeconds() > 3 && fHealth < iHealthMax)
            {
                fHealth += (float)100 / 1500;
                if (fHealth > iHealthMax)
                {
                    fHealth = iHealthMax;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a List of the Elements to be drawed
        /// Custom List is used to to add Lists rapidly
        /// </summary>
        public override CustomList Draw(RenderWindow window)
        {
            lDrawList = new CustomList();

            lDrawList.AddElement(textQuest);
            lDrawList.AddList(pPlayer.Draw());

            for (int x = 0; x < lEnemies.Count; x++)
            {
                Vector2f EnemyPosition = lEnemies[x].GetPosition();

                if (EnemyPosition.X > GameLoop.GetWindowSize().X || EnemyPosition.X < -50 ||
                    EnemyPosition.Y > GameLoop.GetWindowSize().Y || EnemyPosition.Y < -50)
                {
                    continue;
                }

                lDrawList.AddList(lEnemies[x].Draw());
            }

            if (cText != null)
            {
                tText = cText.ElapsedTime;
            }

            if (tText.AsSeconds() <= 5)
            {
                RectangleShape rShape = new RectangleShape(new Vector2f(20, 15));
                rShape.FillColor        = Color.White;
                rShape.OutlineThickness = 2;
                rShape.OutlineColor     = Color.Black;
                rShape.Position         = new Vector2f(877, 490);

                lDrawList.AddElement(rShape);

                rShape                  = new RectangleShape(new Vector2f(30, 20));
                rShape.FillColor        = Color.White;
                rShape.OutlineThickness = 2;
                rShape.OutlineColor     = Color.Black;
                rShape.Position         = new Vector2f(847, 470);

                lDrawList.AddElement(rShape);

                rShape                  = new RectangleShape(new Vector2f(50, 25));
                rShape.FillColor        = Color.White;
                rShape.OutlineThickness = 2;
                rShape.OutlineColor     = Color.Black;
                rShape.Position         = new Vector2f(805, 450);

                lDrawList.AddElement(rShape);

                rShape                  = new RectangleShape(new Vector2f(200, 50));
                rShape.FillColor        = Color.White;
                rShape.OutlineThickness = 2;
                rShape.OutlineColor     = Color.Black;
                rShape.Position         = new Vector2f(702, 409);

                lDrawList.AddElement(rShape);
                lDrawList.AddElement(TextStreamer.TextForPlayer("Tod den Ecksisten!!", new Vector2f(710, 420)));
            }
            else
            {
                cText = null;
            }


            tTileUndHerrsche.Draw(window, vTileMapPosition);

            return(lDrawList);
        }