Пример #1
0
        public override List <Line> GetLines()
        {
            List <Line> l    = new List <Line>();
            Line        line = SpaceThing.MakeLine(prev, upperLeft, new Point(0, 0), new System.Windows.Media.Matrix());

            //MessageBox.Show("x " + line.X1 + "   y " + line.Y1 + Environment.NewLine + "x " + line.X2 + "   y " + line.Y2);
            l.Add(line);
            return(l);
        }
        public override List <Line> GetLines(Point offset)
        {
            List <Line> l = new List <Line>();

            Point p = new Point(offset.X + upperLeft.X, offset.Y + upperLeft.Y);

            l.Add(SpaceThing.MakeLine(verts[0], verts[1], p, rotationMatrix));
            l.Add(SpaceThing.MakeLine(verts[0], verts[2], p, rotationMatrix));
            l.Add(SpaceThing.MakeLine(verts[3], verts[4], p, rotationMatrix));

            if (Thrusting)
            {
                if (count * 5 % 2 == 0)
                {
                    l.Add(SpaceThing.MakeLine(verts[5], verts[6], p, rotationMatrix));
                    l.Add(SpaceThing.MakeLine(verts[5], verts[7], p, rotationMatrix));
                }
            }

            return(l);
        }
Пример #3
0
        public virtual async void GameLoop()
        {
            long time = DateTime.Now.Ticks;
            int  dt;

            Counter++;

            if (gameLoopRunning)
            {
                foreach (SpaceThing thing in Enemies)
                {
                    thing.Simulate(this);
                }
                foreach (Blastable debris in Debris)
                {
                    debris.Simulate(this);
                }
                foreach (Blastable bullet in Bullets)
                {
                    bullet.Simulate(this);
                }
                foreach (SpaceAlien a in Aliens)
                {
                    a.Simulate(this);
                    a.Shoot(this, Player.GetLocation());
                }

                if ((((Counter * 50000000 + 345) * (Counter + 55)) % 125 == 0) && Aliens.Count < 2)
                {
                    Aliens.Add(factory.GiveMeAnAlien(Score));
                }



                CollideAsteroidsAliensBullets();


                if (PlayerTimer < 0)
                {
                    CollidePlayerAndAsteroidsAndBullets();
                }



                await Task.Delay(1);

                //if (Counter == 3)
                //MessageBox.Show("hullo");

                PlayerTimer--;
                view.Children.Clear();

                // Player Draw
                if (PlayerTimer < 0)
                {
                    Player.Draw(view);
                }
                else
                if (((Counter / 5) % 2 == 0) /*&&(Counter < 50)*/)
                {
                    Player.Draw(view);
                }

                foreach (Blastable thing in Enemies)
                {
                    thing.Draw(view);
                }
                foreach (Blastable debris in Debris)
                {
                    debris.Draw(view);
                }
                foreach (Blastable bullet in Bullets)
                {
                    bullet.Draw(view);
                }
                foreach (SpaceAlien a in Aliens)
                {
                    a.Draw(view);
                }

                // LIVES
                Point p;
                int   i;

                for (i = 0; i < Lives; i++)
                {
                    p = new Point(60 + i * 30, 60);
                    view.Children.Add(SpaceThing.MakeLine((new Point(0, -25)), (new Point(10, 9)), p, new Matrix()));
                    view.Children.Add(SpaceThing.MakeLine((new Point(0, -25)), (new Point(-10, 9)), p, new Matrix()));
                    view.Children.Add(SpaceThing.MakeLine((new Point(-8, 2)), (new Point(8, 2)), p, new Matrix()));
                }



                // END LIVES

                Player.Simulate(this);
                //Player.Draw(view);

                HandleBlasts();
            }


            //if (Counter > 50)
            //MessageBox.Show(time + "");
            await Task.Delay(1);

            time = DateTime.Now.Ticks - time;
            dt   = 60 - (int)(time / 10000);
            if (dt > 0)
            {
                await Task.Delay(60 - (int)(time / 10000));
            }
            if (Enemies.Count < 1)
            {
                StartLevel((int)Math.Sqrt(Score / 600) + 6);
            }
            if (!stopped)
            {
                GameLoop();
            }
        }
 public void Draw(Canvas c)
 {
     c.Children.Add(SpaceThing.MakeLine(new Point(0, 1), new Point(0, 0), loc, new System.Windows.Media.Matrix()));
 }