Example #1
0
        public override void Update()
        {
            LifeTime -= Time.deltatime;
            if (LifeTime <= 0)
            {
                Destroy();
            }
            for (int i = 0; i < meshes.Count; i++)
            {
                ShrinkMesh(meshes[i], 0.01f);
            }
            if (Time.time - LastSplit > SplitInterval)
            {
                LastSplit = Time.time;
                List <Mesh> temp = new List <Mesh>();

                for (int i = 0; i < meshes.Count; i++)
                {
                    temp.AddRange(SplitMesh(meshes[i]));
                }

                TankGame.RemoveMeshesFromRenderStack(meshes);
                meshes = temp;
                TankGame.AddMeshesToRenderStack(meshes);
            }
        }
Example #2
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (TankGame game = new TankGame())
     {
         game.Run();
     }
 }
Example #3
0
        static void Main(string[] args)
        {
            TankGame tankGame = new TankGame();

            //sets fps to 60 fps
            SetTargetFPS(60);
            //creates a screen 1400 width 900 height
            InitWindow(1400, 900, "Tank World");

            //calls init(function)2
            tankGame.Init();

            //calls update and draw after init and keeps looping through them
            while (!WindowShouldClose())
            {
                tankGame.Update();
                tankGame.Draw();
            }

            tankGame.Shutdown();

            CloseWindow();
        }
Example #4
0
        public override void Update()
        {
            for (int i = 0; i < dots.Count; ++i)
            {
                if (!dots[i].alive)
                {
                    dots.Remove(dots[i]);
                }
            }

            while (prevLength > dots.Count)
            {
                TankGame.RemoveMeshFromRenderStack(meshes[meshes.Count - 1]);
                meshes.Remove(meshes[meshes.Count - 1]);
                prevLength--;
            }


            if (prevLength == 0)
            {
                Destroy();
                return;
            }

            for (int i = 0; i < dots.Count; ++i)
            {
                dots[i].Update(Time.deltatime);

                meshes[i].offset = dots[i].position;
                meshes[i].RotateVertices(i % 2 == 0 ? -dots[i].velocity.Length * 0.01f : dots[i].velocity.Length * 0.01f, ExtensionMethods.GetPolyCenter(meshes[i].vertices));

                //Move current color towards 0
                meshes[i].color = ExtensionMethods.Lerp(Vector3.Zero, startColor, (dots[i].killTime - Time.time) / dots[i].lifeTime).ToColor();
                meshes[i].Scale(2 * Time.deltatime);
            }
        }