Inheritance: IGraphicsDeviceManager, IGraphicsDeviceService, IDisposable
示例#1
0
        public Bus(Game game, GraphicsDeviceManager graphics, Vector2 location)
            : base(game, graphics, "content/bus", true)
        {
            this.mLocation = location;

     
        }
示例#2
0
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GameStateManagementGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            #if WINDOWS_PHONE
            graphics.IsFullScreen = true;

            // Choose whether you want a landscape or portait game by using one of the two helper functions.
            InitializeLandscapeGraphics();
            // InitializePortraitGraphics();
            #endif
            // Create the screen factory and add it to the Services
            screenFactory = new ScreenFactory();
            Services.AddService(typeof(IScreenFactory), screenFactory);

            // Create the screen manager component.
            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            #if WINDOWS_PHONE
            // Hook events on the PhoneApplicationService so we're notified of the application's life cycle
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Launching +=
                new EventHandler<Microsoft.Phone.Shell.LaunchingEventArgs>(GameLaunching);
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Activated +=
                new EventHandler<Microsoft.Phone.Shell.ActivatedEventArgs>(GameActivated);
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Deactivated +=
                new EventHandler<Microsoft.Phone.Shell.DeactivatedEventArgs>(GameDeactivated);
            #else
            // On Windows and Xbox we just add the initial screens
            AddInitialScreens();
            #endif
        }
示例#3
0
 public override void Update(GraphicsDeviceManager graphics, float elapsed)
 {
     //if (collisionBox.position != ) {
     mario.MarioVel_X = 0;
     mario.MarioVel_Y += 5*elapsed/100;
     //}
 }
示例#4
0
 public void ResetCamera(Vector2 position, Vector2 origin, float rotation, Vector2 scale, GraphicsDeviceManager graphics)
 {
     Rotation = rotation;
     ResetScreenScale(graphics, scale);
     Position = position;
     Bounds = graphics.GraphicsDevice.Viewport.Bounds;
 }
示例#5
0
        /// <summary>
        /// Initializes io2GameLib
        /// </summary>
        public Io2GameLibGame()
        {
            // Regular initialization stuff
            Content.RootDirectory = "Content";
            Graphics = new GraphicsDeviceManager(this);
            Graphics.IsFullScreen = true;

            // Extend battery life under lock.
            // InactiveSleepTime = TimeSpan.FromSeconds(1); // CRASH on WIN8

            // Create the settings object
            Settings = new GameLibSettings();

            // Create the screenmanager
            ScreenManager = new ScreenManager(this);
            Components.Add(ScreenManager);

            // Add the default background screen
            ScreenManager.AddScreen(new BackgroundScreen());

            // Let the user get a change to initialize there own services
            InitializeServices();

            // Register the default services
            RegisterDefaultServices();

            // An old construct still alive
            Io2GameLibGame.instance = this;
        }
示例#6
0
        public Game1()
        {
            // jazyk
            Thread.CurrentThread.CurrentUICulture	=	CultureInfo.GetCultureInfo("cs-CZ");

            this.graphics	=	new GraphicsDeviceManager(this);

            // rozmìry okna
            this.graphics.PreferredBackBufferWidth	=	733;
            this.graphics.PreferredBackBufferHeight	=	608;

            this.Content.RootDirectory	=	"Content";

            TargetElapsedTime = TimeSpan.FromTicks(333333);

            // Create the screen factory and add it to the Services
            screenFactory = new ScreenFactory();
            Services.AddService(typeof(IScreenFactory), screenFactory);

            // Create the screen manager component.
            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            this.AddInitialScreens();
        }
示例#7
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.DeviceCreated += new EventHandler<EventArgs>(graphics_DeviceCreated);
            // graphics.ApplyChanges();
            Content.RootDirectory = "Content";

//            if (graphics.GraphicsDevice == null)
//            {
//                CCLog.Log("FOO");
//            }

            graphics.IsFullScreen = false;

            // Frame rate is 30 fps by default for Windows Phone.
            // Divide by 2 to make it 60 fps
            TargetElapsedTime = TimeSpan.FromTicks(333333 / 2);
            IsFixedTimeStep = true;

            IsMouseVisible = true;

            // Extend battery life under lock.
            //InactiveSleepTime = TimeSpan.FromSeconds(1);

            CCApplication application = new AppDelegate(this, graphics);
            Components.Add(application);

#if !WINDOWS_PHONE && !XBOX && !WINDOWS
            GamerServicesComponent component = new GamerServicesComponent(this);
            this.Components.Add(component);
#endif
        }
示例#8
0
 public AppDelegate(Game game, GraphicsDeviceManager graphics)
     : base(game, graphics)
 {
     this.game = game;
     CCApplication.sm_pSharedApplication = this;
     this.setOrientation(Orientation.kOrientationLandscapeLeft);
 }
示例#9
0
 public static void Initialize(ref GraphicsDeviceManager graphics)
 {
     GraphicsHandler.graphics = graphics;
     graphics.PreferredBackBufferWidth = (int)GameOptions.Resolution.X;
     graphics.PreferredBackBufferHeight = (int)GameOptions.Resolution.Y;
     graphics.ApplyChanges();
 }
示例#10
0
        public static void panToCharacter(Character character, Camera camera, Map map, GraphicsDeviceManager graphics, int panSeconds=1)
        {
            // camera starts at P1. Camera moves a distance equal to the differencce between the camera's center at P1 and the chracter given.
            //get the current camera position and center.

            float ViewSizeX = graphics.GraphicsDevice.Viewport.Width;  // width of the current game viewport
            float ViewSizeY = graphics.GraphicsDevice.Viewport.Height; // height of the current game viewport

            Vector2 originalCameraPosition = camera.cameraLocation; //record the original position of the camera
            Vector2 originalCameraCenter = new Vector2(originalCameraPosition.X + ViewSizeX/2, originalCameraPosition.Y + ViewSizeY/2);

            int originalCharPosX = (int)character.position.X;
            int originalCharPosY = (int)character.position.Y;

            Tile OriginalCharTile = map.tiles[originalCharPosX, originalCharPosY];// character.position;

            int originalCharPosPixX = ((originalCharPosX * (Tile.width)) + ((originalCharPosY - 1) * (Tile.width / 2)) + (int)camera.cameraLocation.X);
            int originalCharPosPixY = ((originalCharPosY * (Tile.height / 2)) + (int)camera.cameraLocation.Y);

            Vector2 originalCharPosPix = new Vector2(originalCharPosPixX,originalCharPosPixY);

            //camera change equal to the difference in the camera center at p1 and the character's initial position

            Vector2 transformVector = originalCameraCenter - originalCharPosPix;

            //move the camera such that it reaches its final destination in panSeconds seconds
            //calculate pixels to move and sleep time such that the camera moves a distance x in panSeconds seconds

            panCameraToLocation(camera, transformVector);
            //camera.cameraLocation = transformVector;
        }
示例#11
0
        public GameBase(Orientation orientation)
            : base()
        {
            _instance = this;

            GraphicsDeviceManager graphics = new GraphicsDeviceManager(this);

            if (orientation == Orientation.Portrait)
            {
                graphics.SupportedOrientations = DisplayOrientation.Portrait | DisplayOrientation.PortraitDown;
            }
            else
            {
                graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
            }

            graphics.IsFullScreen = true;

            Content.RootDirectory = "Content";

            GlobalTimerController.ClearInstance();
            TouchProcessor.ClearInstance();

            _scenes = new Dictionary<Type, Scene>();
            _currentScene = null;
            _tombstoneFileName = DefaultTombstoneFileName;
            _sceneTransitionCrossFadeTextureName = "";

            PurchaseManager = new External_APIS.iOS.InAppPurchaseManager();
        }
示例#12
0
        /// <summary>
        /// Initializes game & graphics based on config.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="graphicsDeviceManager"></param>
        public void Initialize(Game game, GraphicsDeviceManager graphicsDeviceManager)
        {
            this.Game = game;
            this.GraphicsDeviceManager = graphicsDeviceManager;

            // set custom resolution if required
            if (this.Config.Screen.Width != 0 && this.Config.Screen.Height != 0)
            {
                this.GraphicsDeviceManager.PreferredBackBufferWidth = this.Config.Screen.Width;
                this.GraphicsDeviceManager.PreferredBackBufferHeight = this.Config.Screen.Height;
            }

            // set full screen mode.
            this.GraphicsDeviceManager.IsFullScreen = this.Config.Screen.IsFullScreen;

            // set vsync.
            this.Game.IsFixedTimeStep = this.Config.Graphics.IsFixedTimeStep;
            this.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = this.Config.Graphics.IsVsyncEnabled;

            // set mouse mode.
            this.Game.IsMouseVisible = this.Config.Input.IsMouseVisible;

            // set orientation.
            this.GraphicsDeviceManager.SupportedOrientations = this.Config.Screen.SupportedOrientations;

            this.Initialize();

            this.GraphicsDeviceManager.ApplyChanges();
        }
示例#13
0
        /// <summary>
        /// Default constructor for the WizardryGameServer class.
        /// </summary>
        public WizardryGameServer()
        {
            graphics = new GraphicsDeviceManager( this );
            Content.RootDirectory = "Content";
            textureProvider = new TextureProvider( Content );

            // Windows Settings for the XNA window
            Window.Title = "Wizardry Server";
            graphics.PreferredBackBufferWidth = 200;
            graphics.PreferredBackBufferHeight = 1;

            // Set up the lobbies list
            lobbies = new GameLobby[GameSettings.MAX_LOBBIES];
            for ( int i = 0; i < GameSettings.MAX_LOBBIES; ++i )
            {
                lobbies[i] = null;
            }

            playerLobbies = new ConcurrentDictionary<long, int>();

            // Setup the server configuration
            NetPeerConfiguration config = new NetPeerConfiguration( GameSettings.APP_NAME );
            config.Port = GameSettings.SERVER_PORT_NUM;
            config.EnableMessageType( NetIncomingMessageType.DiscoveryRequest );

            // Start the server
            server = new NetServer( config );
            server.Start();
            WriteConsoleMessage( "Server starting!" );

            // Start the Packet Receiver thread
            Thread packets = new Thread( new ThreadStart( this.PacketProcessor ) );
            packets.Start();
        }
示例#14
0
 public static void SetResolution(GraphicsDeviceManager graphics, int x, int y)
 {
     ResX = x;
     ResY = y;
     graphics.PreferredBackBufferHeight = y;
     graphics.PreferredBackBufferWidth = x;
 }
        /// <summary>
        /// Initializes a new instance of the BallerburgGame class
        /// </summary>
        public BallerburgGame()
        {
            Instance = this;
              gameSettings = new GameSettings();
              playerSettings = new PlayerSettings[4];

              applicationSettings = new ApplicationSettings();

              graphics = new GraphicsDeviceManager(this)
                     {
                       PreferredBackBufferWidth = 640,
                       PreferredBackBufferHeight = 480
                     };

              graphicsManager = new BallerburgGraphicsManager();
              contentManager = new ContentManager();
              shaderManager = new ShaderManager();
              audioManager = new AudioManager(applicationSettings, contentManager);
              gameObjectManager = new GameObjectManager(contentManager, this.audioManager, this.graphicsManager);

              MousePointer = new MousePointer(this)
                         {
                           DrawOrder = 1000,
                           RestrictZone = new Rectangle(0, 0, 640, 480)
                         };
              Components.Add(MousePointer);

              // Create the screen manager component.
              screenManager = new ScreenManager(graphicsManager, contentManager, gameObjectManager, applicationSettings, gameSettings, shaderManager, audioManager, playerSettings)
                          {
                            GameMousePointer = MousePointer
                          };
        }
示例#16
0
        public GameStateManagementGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);
            //TargetElapsedTime = TimeSpan.FromTicks(333333);
            TargetElapsedTime = TimeSpan.FromTicks(333);

            #if WINDOWS_PHONE
            graphics.IsFullScreen = true;
            InitializeLandscapeGraphics();
            #endif

            screenFactory = new ScreenFactory();
            Services.AddService(typeof(IScreenFactory), screenFactory);
            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            #if WINDOWS_PHONE
            // hook
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Launching +=
                new EventHandler<Microsoft.Phone.Shell.LaunchingEventArgs>(GameLaunching);
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Activated +=
                new EventHandler<Microsoft.Phone.Shell.ActivatedEventArgs>(GameActivated);
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Deactivated +=
                new EventHandler<Microsoft.Phone.Shell.DeactivatedEventArgs>(GameDeactivated);
            #else
            AddInitialScreens();
            #endif
            gameMusic = Content.Load<SoundEffect>("sounds/GamePlayHalfBit");
            gameMusicI = gameMusic.CreateInstance();
            gameMusicI.IsLooped = true;
            gameMusicI.Play();
        }
        public FarseerPhysicsGame()
        {
            Window.Title = "Farseer Samples Framework";
            _graphics = new GraphicsDeviceManager(this);
            _graphics.PreferMultiSampling = true;
            #if WINDOWS || XBOX
            _graphics.PreferredBackBufferWidth = 1280;
            _graphics.PreferredBackBufferHeight = 720;
            ConvertUnits.SetDisplayUnitToSimUnitRatio(24f);
            IsFixedTimeStep = true;
            #elif WINDOWS_PHONE
            _graphics.PreferredBackBufferWidth = 800;
            _graphics.PreferredBackBufferHeight = 480;
            ConvertUnits.SetDisplayUnitToSimUnitRatio(16f);
            IsFixedTimeStep = false;
            #endif
            #if WINDOWS
            _graphics.IsFullScreen = false;
            #elif XBOX || WINDOWS_PHONE
            _graphics.IsFullScreen = true;
            #endif

            Content.RootDirectory = "Content";

            //new-up components and add to Game.Components
            ScreenManager = new ScreenManager(this);
            Components.Add(ScreenManager);

            FrameRateCounter frameRateCounter = new FrameRateCounter(ScreenManager);
            frameRateCounter.DrawOrder = 101;
            Components.Add(frameRateCounter);
        }
示例#18
0
        public void Initialize(StateInitDesc initDesc)
        {
            Kernel          = initDesc.Kernel;
            _dataContent    = initDesc.DataContent;
            _archiveManager = initDesc.ArchiveManager;
            _graphics       = initDesc.GraphicsDevice;
            _input          = initDesc.Input;
            _stateChange    = initDesc.StateChange;
            _shader         = new KingdomShader(initDesc.ContentManager);
            _camera         = new Camera()
            {
                CameraPosition             = new Vector3(0, 251, -920),
                CameraRotationYawPitchRoll = new Vector3(-90, 0, -10),
            };
            _menuState = new MenuState(this);

            Kernel.World    = initDesc.StateSettings.GetInt("WorldId", Kernel.World);
            Kernel.Area     = initDesc.StateSettings.GetInt("PlaceId", Kernel.Area);
            Kernel.Entrance = initDesc.StateSettings.GetInt("SpawnId", Kernel.Entrance);
            Field           = new Kh2Field(
                Kernel,
                _camera,
                initDesc.StateSettings,
                _graphics.GraphicsDevice,
                _shader,
                _input);

            BasicallyForceToReloadEverything();
            _menuState.Initialize(initDesc);
        }
示例#19
0
文件: State.cs 项目: anxkha/Mortuum
 public State(ContentManager content, GraphicsDeviceManager graphics, Player player)
 {
     _content = content;
     _graphics = graphics;
     _player = player;
     _firstFrame = true;
 }
示例#20
0
 public Vector3 ResetScreenScale(GraphicsDeviceManager graphics, Vector2 screenScale)
 {
     var scaleX = (float)graphics.GraphicsDevice.Viewport.Width / screenScale.X;
     var scaleY = (float)graphics.GraphicsDevice.Viewport.Height / screenScale.Y;
     Scale = new Vector3(scaleX, scaleY, 1.0f);
     return Scale;
 }
示例#21
0
 public MonoGameImpl()
 {
     _graphics = new GraphicsDeviceManager(this);
     _graphics.PreferredBackBufferWidth = 1280;
     _graphics.PreferredBackBufferHeight = 720;
     Content.RootDirectory = "Content";
 }
示例#22
0
        public Alligator(Game game, GraphicsDeviceManager graphics, Vector2 location)
            : base(game, graphics, "content/alligator", true)
        {
            this.mLocation = location;


        }
示例#23
0
 public static void Initialize(Game game, GraphicsDeviceManager graphics)
 {
     GlobalContent.game = game;
     GlobalContent.graphics = graphics;
     GlobalContent.content = game.Content;
     GlobalContent.Initialized = true;
 }
示例#24
0
        public CircularGame()
        {
            Window.Title = "Circular";
            _graphics = new GraphicsDeviceManager ( this ) {
                                                               PreferMultiSampling = true,
                                                               PreferredBackBufferWidth = 1280,
                                                               PreferredBackBufferHeight = 720
                                                           };

            #if WINDOWS || XBOX
            ConvertUnits.SetDisplayUnitToSimUnitRatio ( 24f );
            IsFixedTimeStep = true;
            #elif WINDOWS_PHONE
            _graphics.PreferredBackBufferWidth = 800;
            _graphics.PreferredBackBufferHeight = 480;
            ConvertUnits.SetDisplayUnitToSimUnitRatio(16f);
            IsFixedTimeStep = false;
            #endif

            #if WINDOWS
            _graphics.IsFullScreen = false;
            #elif XBOX || WINDOWS_PHONE
            _graphics.IsFullScreen = true;
            #endif

            Content.RootDirectory = "Content";

            //new-up components and add to Game.Components
            ScreenManager = new ScreenManager ( this );
            Components.Add ( ScreenManager );

            var frameRateCounter = new FPSComponent ( ScreenManager ) { DrawOrder = 101 };
            Components.Add ( frameRateCounter );
        }
示例#25
0
文件: Camera2D.cs 项目: AnyKey/tojam4
 public Camera2D(GraphicsDeviceManager graphics, Vector2 lookAt, float zoomLevel)
 {
     screenCenter = new Vector2(graphics.GraphicsDevice.Viewport.Width / 2.0f, graphics.GraphicsDevice.Viewport.Height / 2.0f);
     this.lookAt = lookAt;
     this.zoomLevel = zoomLevel;
     this.zoomOrigin = screenCenter;
 }
示例#26
0
文件: Game1.cs 项目: netonjm/Rube.Net
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            //#if MACOS
            //            Content.RootDirectory = "AngryNinjas/Content";
            //#else
            Content.RootDirectory = "Content";
            //#endif
            //
            //#if XBOX || OUYA
            //            graphics.IsFullScreen = true;
            //#else
            graphics.IsFullScreen = false;
            //#endif

            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333 / 2);

            // Extend battery life under lock.
            //InactiveSleepTime = TimeSpan.FromSeconds(1);

            CCApplication application = new AppDelegate(this, graphics);
            Components.Add(application);
            //#if XBOX || OUYA
            //            CCDirector.SharedDirector.GamePadEnabled = true;
            //            application.GamePadButtonUpdate += new CCGamePadButtonDelegate(application_GamePadButtonUpdate);
            //#endif
        }
示例#27
0
        public FormManager(GraphicsDeviceManager _graphics, Game _game, Manager _manager)
        {
            this.graphics = _graphics;
            this.parent = _game;

            manager = _manager;
        }
示例#28
0
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
              Content.RootDirectory = "Content";
              graphics.IsFullScreen = true;
              InitializeLandscapeGraphics();
              // Frame rate is 30 fps by default for Windows Phone.
              TargetElapsedTime = TimeSpan.FromTicks(333333);

              // Extend battery life under lock.
              InactiveSleepTime = TimeSpan.FromSeconds(1);

              screenFactory = new ScreenFactory();
              Services.AddService(typeof(IScreenFactory), screenFactory);

              screenManager = new ScreenManager(this);
              Components.Add(screenManager);

              Microsoft.Phone.Shell.PhoneApplicationService.Current.Launching +=
                new EventHandler<Microsoft.Phone.Shell.LaunchingEventArgs>(GameLaunching);
              Microsoft.Phone.Shell.PhoneApplicationService.Current.Activated +=
              new EventHandler<Microsoft.Phone.Shell.ActivatedEventArgs>(GameActivated);
              Microsoft.Phone.Shell.PhoneApplicationService.Current.Deactivated +=
              new EventHandler<Microsoft.Phone.Shell.DeactivatedEventArgs>(GameDeactivated);
        }
示例#29
0
		public GDGameScreen(MainGame game, GraphicsDeviceManager gdm, LevelFile bp, FractionDifficulty diff) : base(game, gdm)
		{
			blueprint = bp;
			difficulty = diff;

			Initialize();
		}
示例#30
0
		protected MonoSAMGame()
		{
			CurrentTime = new GameTime();

			Graphics = new GraphicsDeviceManager(this);
			Content.RootDirectory = "Content";
		}
示例#31
0
        public Main()
        {
            Options = new Options();

            Graphics = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferWidth = (int) Preferences.BackBuffer.X,
                PreferredBackBufferHeight = (int) Preferences.BackBuffer.Y,
            };

            IsFixedTimeStep = true;
            TargetElapsedTime = new TimeSpan(0, 0, 0, 0, (int) Preferences.TargetElapsedTimeMs);
            Content.RootDirectory = "Content";
            Window.AllowUserResizing = false;

            if (Preferences.Target == Core.Utilities.Setting.Xbox360)
                Components.Add(new GamerServicesComponent(this));

            Instance = this;

            LevelsFactory = new LevelsFactory();
            MusicController = new XACTMusicController();
            NewsController = new NewsController();
            SaveGameController = new SaveGameController();
            CheatsController = new CheatsController();

            Boot = BootSequence.Initial;

            Activated += new EventHandler<EventArgs>(DoWindowsFocusGained);
            Deactivated += new EventHandler<EventArgs>(DoWindowsFocusLost);
        }
示例#32
0
文件: App.cs 项目: juherask/VRPGame
    static Jypeli.JypeliWindow UglyHackToInstantiateJypeliWindow(XNA_Window gwin, XNA_GDM gdm)
    {
        ConstructorInfo jpwCtr = typeof(Jypeli.JypeliWindow).GetConstructor(
            BindingFlags.NonPublic | BindingFlags.Instance,
            null, new Type[] { typeof(XNA_Window), typeof(XNA_GDM) }, null);

        Jypeli.JypeliWindow jpw = (Jypeli.JypeliWindow)(jpwCtr.Invoke(new object[] { gwin, gdm }));
        return(jpw);
    }
示例#33
0
 public XNARenderSystemProvider()
 {
     _game      = new XNAGame();
     _gdManager = new XNA.GraphicsDeviceManager(_game);
     _gdManager.GraphicsProfile = XFG.GraphicsProfile.HiDef;
     _gdManager.ApplyChanges();
     _renderer = new XNARenderer(_gdManager.GraphicsDevice);
     _device   = _renderer.GraphicsDevice;
     _content  = new ContentManager(new EmbeddedResourceLocator(Tesla.Xna.DefaultContent.ResourceManager));
     _content.UseDefaultContent = false;
 }
 internal XNASwapChainImplementation(XNA.GraphicsDeviceManager gdManager, IntPtr windowHandle, PresentationParameters presentParams)
 {
     _gdManager             = gdManager;
     _graphicsDevice        = gdManager.GraphicsDevice;
     _windowHandle          = windowHandle;
     _presentParams         = presentParams;
     _pp                    = new XFG.PresentationParameters();
     _pp.DeviceWindowHandle = windowHandle;
     _pp.IsFullScreen       = false;
     _pp.DisplayOrientation = XNA.DisplayOrientation.Default;
     SetXNAPresentationParameters(presentParams);
     _graphicsDevice.Reset(_pp);
 }
示例#35
0
 public static void Initialize(GDM gdm, GD gd, CM cm, SB sb)
 {
     G.gdm = gdm;
     G.gd  = gd;
     G.cm  = cm;
     G.sb  = sb;
     w     = gdm.PreferredBackBufferWidth = 1024;
     h     = gdm.PreferredBackBufferHeight = 768;
     gdm.ApplyChanges();
     leftVp   = new Viewport(0, 0, G.w / 2, G.h);
     rightVp  = new Viewport(G.w / 2, 0, G.w / 2, G.h);
     screenVp = new Viewport(0, 0, G.w, G.h);
 }
示例#36
0
        public Engine()
        {
            this.graphics = new Microsoft.Xna.Framework.GraphicsDeviceManager(this);

            /*the first this is used because the "graphics" variable is outside the scope of method Engine() ,So we need to
             * get the variable which will be present in the object of this class...So we use "this" keyword to  get it.
             * The 2nd this is the parameter passed to the constructor of class GraphicsDeviceManager which takes as its argument
             * the game to which the graphics device manager should be associated with. We know that it will be associated to the
             * object of this class...SO we use "this" again.
             */

            this.content = new Microsoft.Xna.Framework.Content.ContentManager(this.Services);
            //this.spriteBatch = new Microsoft.Xna.Framework.Graphics.SpriteBatch(this.graphics.GraphicsDevice);
            //this.box = new mygame.Graphics.Image[Max_Obj];
            //this.Initialize();
        }
示例#37
0
        internal static void Initialize(Microsoft.Xna.Framework.GraphicsDeviceManager graphics, bool goFullscreen)
        {
            Width  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            Height = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;

            if (!goFullscreen)
            {
                Width  -= 20;
                Height -= 80;
            }

            graphics.PreferredBackBufferWidth  = Width;
            graphics.PreferredBackBufferHeight = Height;
            graphics.IsFullScreen = goFullscreen;

            ScreenRect = new Rectangle(0, 0, Width, Height);
        }
示例#38
0
        public void Update(Microsoft.Xna.Framework.GraphicsDeviceManager graphics, Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, Microsoft.Xna.Framework.GameTime gameTime)
        {
            if (lastElapsedGameTime + 100 < gameTime.TotalGameTime.TotalMilliseconds)
            {
                lastElapsedGameTime = gameTime.TotalGameTime.TotalMilliseconds;
                int elapsedGameTime = gameTime.ElapsedGameTime.Milliseconds;

                bool cameraPositionChanged = false;

                Vector2 position = _controllerService.GetJoystickRightStickPosition();

                if (position.X != lastPosition.X || position.Y != lastPosition.Y)
                {
                    cameraPositionChanged = true;
                    // Changement total en 2 secondes
                    //_cameraXAxis += position.X / 600 * elapsedGameTime * MAX_CAMERA_POSITION;
                    //if(_cameraXAxis > MAX_CAMERA_POSITION)
                    //{
                    //    _cameraXAxis = MAX_CAMERA_POSITION;
                    //}
                    //if (_cameraXAxis < MIN_CAMERA_POSITION)
                    //{
                    //    _cameraXAxis = MIN_CAMERA_POSITION;
                    //}
                    //_cameraYAxis += position.Y / 600 * elapsedGameTime * MAX_CAMERA_POSITION;
                    //if (_cameraYAxis > MAX_CAMERA_POSITION)
                    //{
                    //    _cameraYAxis = MAX_CAMERA_POSITION;
                    //}
                    //if (_cameraYAxis < MIN_CAMERA_POSITION)
                    //{
                    //    _cameraYAxis = MIN_CAMERA_POSITION;
                    //}
                }
                if (position.X != lastPosition.X || position.Y != lastPosition.Y)
                {
                    lastPosition.X = position.X;
                    lastPosition.Y = position.Y;
                    _networkService.SendMessage("CAMERA_POS" + "|" + Math.Round(position.X * 100, 0).ToString() + "|" + Math.Round(position.Y * 100, 0).ToString());
                    //_networkService.SendMessage("CAMERA_POS" + "|" + Math.Round(_cameraXAxis, 0).ToString() + "|" + Math.Round(_cameraYAxis, 0).ToString());
                }
            }
        }
示例#39
0
文件: App.cs 项目: juherask/VRPGame
    private static void TryToSwitchAntialiasingOn()
    {
        // The GDM creates the graphicsdevices for windows to draw. Gain access to it.
        XNA_GDM gdm = UglyHackToGetGraphicsDeviceManagerWithReflection();

        gdm.PreferMultiSampling = true;
        gdm.ApplyChanges();

        // Ok, now lets switch the Jypeli.Game.Window before anyone noitices!
        XNA_Window gwin = UglyHackToGetXNAGAmeWindowWithReflection(VRPGame.Window);

        Jypeli.JypeliWindow antialiasedWindow = UglyHackToInstantiateJypeliWindow(gwin, gdm);

        UglyHackToSwitchJypeliWindowWithReflection(antialiasedWindow);

        // TODO: If everything else works do this e.g. with more reflection
        //  http://stackoverflow.com/questions/660480/determine-list-of-event-handlers-bound-to-event
        //Window.Resizing += new JypeliWindow.ResizeEvent( WindowResized );
        //Window.Resized += new JypeliWindow.ResizeEvent( WindowResized );
    }
示例#40
0
        public void Draw(Microsoft.Xna.Framework.GameTime gameTime, ref Microsoft.Xna.Framework.Graphics.SpriteBatch sp, ref Microsoft.Xna.Framework.GraphicsDeviceManager g, ref Microsoft.Xna.Framework.Graphics.SpriteFont font)
        {
            sp.Begin();

            g.GraphicsDevice.Clear(Color.Black);

            /// Logic for drawing the ActiveBackground
            ActiveBackground.DrawSky();
            ActiveBackground.DrawSunrays();
            ActiveBackground.DrawFlowers();
            ActiveBackground.DrawGrass();
            ActiveBackground.DrawSun();
            ActiveBackground.DrawCloud1();
            ActiveBackground.DrawCloud2();
            ActiveBackground.DrawCloud3();
            ActiveBackground.DrawCloud4();
            ActiveBackground.DrawCloud5();

            // sp.Draw(background, new Rectangle(0, 0, g.PreferredBackBufferWidth, g.PreferredBackBufferHeight), Color.White);

            // sp.DrawString(font, "Highscore", new Vector2(20, 20), Color.Black);

            /// <summary>
            /// Draws all the Lines necessary for the table to be displayed
            /// </summary>
            int index = 0;

            foreach (Rectangle line in lines)
            {
                sp.Draw(lineTexture, lines[index], Color.OrangeRed);
                index++;
            }

            int offsetX = (int)Math.Round((double)g.PreferredBackBufferWidth * 0.020);
            int offsetY = (int)Math.Round((double)g.PreferredBackBufferHeight * 0.020);

            /// <summary>
            /// Draws the linenumbers onto the table
            /// </summary>
            for (int i = 0; i < 10; i++)
            {
                switch (i)
                {
                case 0:
                {
                    sp.DrawString(GameSpecs.scoreFont, (i + 1).ToString(), new Vector2(lines[i].X + offsetX, lines[i].Y - (int)(offsetY * 10)), Color.OrangeRed);
                    break;
                }

                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                case 8:
                case 9:
                {
                    sp.DrawString(font, (i + 1).ToString(), new Vector2(lines[i - 1].X + offsetX, lines[i - 1].Y + offsetY), Color.OrangeRed);
                    break;
                }
                }
            }

            ///<summary>
            /// Writes the Highscores into the table
            ///</summary>

            int[] scores = scoreValues.ToArray();

            for (int i = 0; i < 10; i++)
            {
                if (i == 0)
                {
                    sp.DrawString(GameSpecs.scoreFont, scores[i].ToString(), new Vector2(lines[i].X + offsetX * 20, lines[i].Y + (int)(offsetY - offsetY * 11)), Color.OrangeRed);
                }
                else
                {
                    sp.DrawString(font, scores[i].ToString(), new Vector2(lines[i - 1].X + offsetX * 4, lines[i - 1].Y + offsetY), Color.OrangeRed);
                }
            }

            // Draw the Button(s)
            foreach (Button btn in bl)
            {
                sp.Draw(btn.Texture, new Rectangle((int)btn.Position.X, (int)btn.Position.Y, btn.SourceRectangle.Width, btn.SourceRectangle.Height), Color.White);
            }

            List <int> dimensions = Extension.CalculateDimensionsInPixel(ref g);

            int pictureWidth  = 0;
            int pictureHeight = 0;

            if (g.GraphicsDevice.DisplayMode.Height < 1080)
            {
                pictureHeight = 150;
                pictureWidth  = 150;
            }
            else
            {
                pictureHeight = 200;
                pictureWidth  = 200;
            }
            // Draws the picture of the leader of the highscore-ladder to the screen
            sp.Draw(player_picture_frame, new Rectangle((dimensions[6] + dimensions[9]) - 15, dimensions[4] - 15, pictureWidth + 30, pictureHeight + 30), Color.White);
            sp.Draw(leader_picture, new Rectangle(dimensions[6] + dimensions[9], dimensions[4], pictureWidth, pictureHeight), Color.White);

            sp.End();
        }
示例#41
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            //
            // Graphics
            //

#if NETFX_CORE
            graphics = new Microsoft.Xna.Framework.GraphicsDeviceManager(this);

            graphics.PreparingDeviceSettings += PreparingDeviceSettingsHandler;
#endif

            // Determine if HiDef is supported.
            // Find the default adapter and check if it supports Reach and Hidef.
            // TODO (****) What do we do if Reach isn't supported???
            foreach (GraphicsAdapter ga in GraphicsAdapter.Adapters)
            {
#if NETFX_CORE
                Debug.Assert(false, "Waiting on MG");
                // Assume Reach for now.
                hwSupportsReach = true;
                break;
#else
                if (ga.IsDefaultAdapter)
                {
                    if (ga.IsProfileSupported(GraphicsProfile.Reach))
                    {
                        hwSupportsReach = true;
                    }
                    if (ga.IsProfileSupported(GraphicsProfile.HiDef))
                    {
                        hwSupportsHiDef = true;
                    }

                    break;
                }
#endif
            }

            // Set HiDef iff HW supports AND user doesn't prefer Reach.
            hidef = false;
            if (hwSupportsHiDef && !BokuSettings.Settings.PreferReach)
            {
                hidef = true;
            }
            else
            {
                BokuSettings.ConstrainToReach();
            }

            Debug.Assert(false, "Should we even be here?");

            // Select right profile.
            graphics.GraphicsProfile = BokuGame.HiDefProfile ? GraphicsProfile.HiDef : GraphicsProfile.Reach;

            //graphics.PreferredBackBufferFormat = SurfaceFormat.Color;
            graphics.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8;

#if NETFX_CORE
            // For Win8 always force fullscreen and use full device resolution.
            graphics.IsFullScreen             = BokuSettings.Settings.FullScreen = true;
            BokuSettings.Settings.ResolutionX = graphics.PreferredBackBufferWidth;
            BokuSettings.Settings.ResolutionY = graphics.PreferredBackBufferHeight;
#endif

            // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< FULL SCREEN WINDOWED MODE FIX

#if !NETFX_CORE
            // Always start windowed.
            graphics.IsFullScreen = false;
#endif

            // FULL SCREEN WINDOWED MODE FIX >>>>>>>>>>>>>>>>>>>>>>>>>>>>>

            graphics.SynchronizeWithVerticalRetrace = syncRefresh;
            graphics.PreferMultiSampling            = BokuSettings.Settings.AntiAlias;

            //
            // Game
            //
#if NETFX_CORE
            IsFixedTimeStep          = false;
            Window.AllowUserResizing = false;
#endif
            IsMouseVisible = true;
        }   // end of BokuGame InitializeComponent()
示例#42
0
        //private static readonly ILog log = LogManager.GetLogger( typeof( Game1 ) );

        public Game1()
        {
            graphics = new MXF.GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }
示例#43
0
        public void Draw(Microsoft.Xna.Framework.GameTime gameTime, ref Microsoft.Xna.Framework.Graphics.SpriteBatch sp, ref Microsoft.Xna.Framework.GraphicsDeviceManager graphics, ref Microsoft.Xna.Framework.Graphics.SpriteFont font)
        {
            sp.Begin();
            g.Clear(Color.Black);

            /// Logic for drawing the ActiveBackground
            ActiveBackground.DrawSky();
            ActiveBackground.DrawSunrays();
            ActiveBackground.DrawFlowers();
            ActiveBackground.DrawGrass();
            ActiveBackground.DrawSun();
            ActiveBackground.DrawCloud1();
            ActiveBackground.DrawCloud2();
            ActiveBackground.DrawCloud3();
            ActiveBackground.DrawCloud4();
            ActiveBackground.DrawCloud5();

            // Draws the Background-Image
            // sp.Draw(background, new Rectangle(0, 0, bZero, hZero), Color.White);

            // Top-Left corner caption
            // sp.DrawString(font, "Endgame", new Vector2(20, 20), Color.White);

            // The Scoreboard
            sp.DrawString(GameSpecs.scoreFont, Convert.ToInt32(Timer.Score).ToString(), new Vector2((int)(bZero * 0.38), (int)(hZero * 0.011)), Color.OrangeRed);

            // The Placeholder-graphic for the KinectStream
            sp.Draw(placeholder, new Rectangle((int)(bZero * 0.300), (int)(hZero * 0.200), (int)(bZero * 0.400), (int)(hZero * 0.600)), Color.White);

            // The Countdown for taking the photo
            sp.DrawString(GameSpecs.scoreFont, Math.Round(Countdown.Counter).ToString(), new Vector2((float)(bZero / 2) - 80, (float)(hZero - 160)), Color.Turquoise);

            if (Session.PhotoTaken == true)
            {
                // Draw the Button(s)
                foreach (Button btn in bl)
                {
                    sp.Draw(btn.Texture, btn.Position, btn.SourceRectangle, btn.Color, btn.Rotation, btn.Origin, btn.Scale, btn.Effect, btn.LayerDepth);
                }
            }

            sp.End();
        }
示例#44
0
        public void Draw(Microsoft.Xna.Framework.GameTime gameTime, ref Microsoft.Xna.Framework.Graphics.SpriteBatch sp, ref Microsoft.Xna.Framework.GraphicsDeviceManager graphics, ref Microsoft.Xna.Framework.Graphics.SpriteFont font)
        {
            sp.Begin();

            g.Clear(Color.Black);

            /// Logic for drawing the ActiveBackground
            ActiveBackground.DrawSky();
            ActiveBackground.DrawSunrays();
            ActiveBackground.DrawFlowers();
            ActiveBackground.DrawGrass();
            ActiveBackground.DrawSun();
            ActiveBackground.DrawCloud1();
            ActiveBackground.DrawCloud2();
            ActiveBackground.DrawCloud3();
            ActiveBackground.DrawCloud4();
            ActiveBackground.DrawCloud5();

            // Draws the Background-Image
            // sp.Draw(background, new Rectangle(0, 0, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height), Color.White);

            // sp.DrawString(font, "Options", new Vector2(20, 20), Color.White);

            foreach (Button btn in bl)
            {
                sp.Draw(btn.Texture, btn.Position, btn.SourceRectangle, btn.Color, btn.Rotation, btn.Origin, btn.Scale, btn.Effect, btn.LayerDepth);
            }

            sp.End();
        }
示例#45
0
        public void Draw(Microsoft.Xna.Framework.GameTime gameTime, ref Microsoft.Xna.Framework.Graphics.SpriteBatch sp, ref Microsoft.Xna.Framework.GraphicsDeviceManager g, ref Microsoft.Xna.Framework.Graphics.SpriteFont font)
        {
            sp.Begin();

            /// Logic for drawing the ActiveBackground
            ActiveBackground.DrawSky();
            ActiveBackground.DrawSunrays();
            ActiveBackground.DrawFlowers();
            ActiveBackground.DrawGrass();
            ActiveBackground.DrawSun();
            ActiveBackground.DrawCloud1();
            ActiveBackground.DrawCloud2();
            ActiveBackground.DrawCloud3();
            ActiveBackground.DrawCloud4();
            ActiveBackground.DrawCloud5();

            // Draws the Background-Image
            // sp.Draw(background, new Rectangle(0, 0, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height), Color.White);

            // Draws the player-picture in question to detailview
            // sp.Draw(player_picture, detailPictureOutlines, Color.White);

            sp.Draw(player_picture, new Rectangle((int)(bZero * 0.300), (int)(hZero * 0.200), (int)(bZero * 0.400), (int)(hZero * 0.600)), Color.White);

            // Draws the caption in the Topleft-Corner
            // sp.DrawString(font, "Detailview - Click anywhere to return", new Vector2(20, 20), Color.Black);

            // Draws the caption that tells the player how to return to the highscore-tablescreen
            sp.DrawString(font, "Click on the Background to return", new Vector2((int)(bZero * 0.300), 40), Color.White);
            sp.End();
        }