예제 #1
0
        public Scene(Game game)
        {
            //Create player 1
            Tank P1;

            P1 = new Tank("P1", game);
            P1.SetPosition(new Vector2(100, 450));
            AddChild(P1);

            //Create player 2
            Tank P2;

            P2 = new Tank("P2", game);
            P2.SetPosition(new Vector2(1440, 450));
            P2.AddRotation((float)Math.PI);
            AddChild(P2);
        }
예제 #2
0
        public void Init()
        {
            stopwatch.Start();
            lastTime = stopwatch.ElapsedMilliseconds;

            if (Stopwatch.IsHighResolution)
            {
                Console.WriteLine("Stopwatch high-resolution frequency: {0} ticks per second", Stopwatch.Frequency);
            }

            //Initialize objects here
            collisionManager = new CollisionManager();
            world            = new GameObject("");

            topCollider    = new GameObject("");
            bottomCollider = new GameObject("");
            leftCollider   = new GameObject("");
            rightCollider  = new GameObject("");

            topCollider.collidable = true;
            topCollider.collider   = new Vector2(1920 / 2, 30);
            topCollider.SetPosition(new Vector2(1920 / 2, -30));
            bottomCollider.collidable = true;
            bottomCollider.collider   = new Vector2(1920 / 2, 30);
            bottomCollider.SetPosition(new Vector2(1920 / 2, 1080 + 30));
            leftCollider.collidable = true;
            leftCollider.collider   = new Vector2(30, 1080);
            leftCollider.SetPosition(new Vector2(1920 + 30, 1080 / 2));
            rightCollider.collidable = true;
            rightCollider.collider   = new Vector2(30, 1080);
            rightCollider.SetPosition(new Vector2(-30, 1080 / 2));

            player = new Tank("../Images/tank.png");
            player.SetPosition(new Vector2(1920 / 2, 1080 / 2));
            collisionManager.Add(player);

            collisionManager.Add(topCollider);
            collisionManager.Add(bottomCollider);
            collisionManager.Add(leftCollider);
            collisionManager.Add(rightCollider);
            world.AdoptChild(player);
        }