Example #1
0
        public PhantomGame(float width, float height, string name)
        {
            PhantomGame.Game = this;

            this.Name = name;

#if DEBUG
            if (width < 10 || height < 10)
            {
                throw new Exception("Please create a PhantomGame with a sensable size (width >= 10 || height >= 10).");
            }
#endif
            this.Width  = (float)Math.Floor(width);
            this.Height = (float)Math.Floor(height);
            this.Size   = new Vector2(this.Width, this.Height);

            this.multiplier = 1;

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            this.BackgroundColor = 0x123456.ToColor();
            this.Paused          = false;

            Trace.WriteLine("Phantom Game Engine");
            Trace.WriteLine("Starting " + this.Name + " build " + Assembly.GetExecutingAssembly().GetName().Version + " on " + DeviceHardware.Form + " device running " + DeviceHardware.OS + " " + DeviceHardware.OSVersion);
            Trace.WriteLine("Device: " + DeviceHardware.Manufacturer + " " + DeviceHardware.Model + " " + DeviceHardware.ModelVersion + " (" + DeviceHardware.Identifier + ")");
            Trace.WriteLine("Screen dimensions: " + DeviceHardware.ScreenWidth + "x" + DeviceHardware.ScreenHeight + " pixels at " + DeviceHardware.PPcm + " pixels per centimeter (" + DeviceHardware.PPI + " ppi)");
            Trace.WriteLine("Display size: " + DeviceHardware.DisplayRealWidth + "x" + DeviceHardware.DisplayRealHeight + " cm, " + DeviceHardware.DisplayDiagonal + " cm diagonal (" + DeviceHardware.DisplayDiagonal / 2.54f + "\")");

#if TESTFLIGHT
            TestFlight.Log("[Start " + this.Name + "] " + DeviceHardware.Form + "; " + DeviceHardware.Manufacturer + "; " + DeviceHardware.Model + "; " + DeviceHardware.ModelVersion + "; " + DeviceHardware.Identifier + "; " + DeviceHardware.OS + "; " + DeviceHardware.OSVersion);
            TestFlight.Log("[Screen] " + DeviceHardware.ScreenWidth + "x" + DeviceHardware.ScreenHeight + "; " + DeviceHardware.PPI + " ppi; " + DeviceHardware.DisplayDiagonal + " inch");
#endif

#if DEBUG
            // Setup Profiler:
            Profiler.Initialize(this, 16);
#endif

            XnaGame              = new Microsoft.Xna.Framework.Game();
            XnaGame.Exiting     += new EventHandler <EventArgs>(this.OnExit);
            XnaGame.Deactivated += new EventHandler <EventArgs>(this.OnDeactivate);
#if !PLATFORM_ANDROID
            XnaGame.Window.Title = this.Name;
#endif
            XnaGame.Content.RootDirectory = "Content";
            XnaGame.Components.Add(new XnaPhantomComponent(this));

            this.Content = new Content(XnaGame.Content);

            this.SetupGraphics();
            //TODO: Instruction caused an invalid operation exception indicating that memory might be corrupted.
            //Happened when running full screen with two monitors... I think this might be the problem for Hendrik too
            this.graphics.ApplyChanges();

            this.states = new List <GameState>();
        }