public SinglePlayer(ContentManager content, SpriteBatch batch, GraphicsDevice device, GameWindow window) { graphicsDevice = device; spriteBatch = batch; Cam = new Camera(); Entities = new List <Entity>(); TextureManager.Init(); TextureManager.LoadContent(content); enemy = new Enemy(new Vector2(0, -3050)); player = new Player(); Entities.Add(enemy); Entities.Add(player); Cam.Zoom = 2f; Cam.Position = new Vector2(0, 300); enemyY = enemy.Position.Y; enemyX = enemy.Position.X; bgObjects = new List <BackgroundObject>(); AddBGObject(); MediaPlayer.Play(TextureManager.Song("Menu")); MediaPlayer.IsRepeating = true; MediaPlayer.Volume = MusicVolume; EventInput.Initialize(window); EventInput.KeyUp += (sender, args) => player.shield.comboManager.KeyPressed(args.KeyCode); tween.Tween(this, new { CamZoom = 1f }, 15f).Ease(Ease.LinearIn); tween.Tween(this, new { CamY = 300 }, 15f).Ease(Ease.LinearIn); tween.Tween(this, new { IntroOpacity = 0f }, 15f).Ease(Ease.LinearIn); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { Window.Title = Settings.GameName; Engine.Services.Register(new GraphicsDeviceService(this.GraphicsDevice)); Engine.Services.Register(new ContentManagerService(this.Content)); Engine.Services.Register(new LightManagerService(new PenumbraComponent(this))); Engine.Services.Register(new NetHandler()); Engine.Services.Register(new SceneManager()); Engine.Services.Get <LightManagerService>().Component.Initialize(); _camera = new Camera(new Rectangle(0, 0, Settings.ResolutionX, Settings.ResolutionY)); EventInput.Initialize(this.Window); this.InitalizeScenes(); _consoleComponent = new ConsoleComponent(this); _consoleComponent.FontColor = Color.Wheat; this.Components.Add(_consoleComponent); this.InitalizeCommands(); _consoleRedirector = new ConsoleRedirector(_consoleComponent); Console.SetOut(_consoleRedirector); GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp; base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { Client.ServiceLocator.RegisterService(new GraphicsDeviceService(this.GraphicsDevice)); Client.ServiceLocator.RegisterService(new ContentManagerService(this.Content)); Client.ServiceLocator.RegisterService(new LightManagerService(new PenumbraComponent(this))); Client.ServiceLocator.RegisterService(new NetHandler()); Client.ServiceLocator.RegisterService(new SceneManager()); Client.ServiceLocator.GetService <LightManagerService>().Component.Initialize(); _camera = new Camera(new Rectangle(0, 0, Settings.ResolutionX, Settings.ResolutionY)); EventInput.Initialize(this.Window); this.InitalizeScenes(); _consoleComponent = new ConsoleComponent(this); this.Components.Add(_consoleComponent); this.InitalizeCommands(); _consoleRedirector = new ConsoleRedirector(_consoleComponent); Console.SetOut(_consoleRedirector); Window.Title = Settings.GameName; base.Initialize(); }
public Main() { Globals.Graphics = new GraphicsDeviceManager(this); EventInput.Initialize(Window); Globals.Content = Content; Content.RootDirectory = "Content"; }
protected override void Initialize() { #if WINDOWS EventInput.Initialize(this); EventInput.CharEntered += new EventHandler <CharacterEventArgs>(EventInput_CharEntered); #endif graphics.ApplyChanges(); spriteBatch = new SpriteBatch(GraphicsDevice); this.Services.AddService(typeof(SpriteBatch), spriteBatch); base.Initialize(); #if SILVERLIGHT renderTarget = new RenderTarget2D(this.GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 1, this.GraphicsDevice.PresentationParameters.BackBufferFormat, RenderTargetUsage.DiscardContents); #else renderTarget = new RenderTarget2D(this.GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, false, this.GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); #endif ShowMainMenu(this.screenManager); }
public GameConsoleComponent(GameConsole console, Game game, SpriteBatch spriteBatch) : base(game) { this.console = console; EventInput.Initialize(game.Window); this.spriteBatch = spriteBatch; AddPresetCommands(); inputProcesser = new InputProcessor(new CommandProcesser()); inputProcesser.Open += (s, e) => renderer.Open(); inputProcesser.Close += (s, e) => renderer.Close(); renderer = new Renderer(game, spriteBatch, inputProcesser); var inbuiltCommands = new IConsoleCommand[] { new ClearScreenCommand(inputProcesser), new ExitCommand(game), new MouseCommand(game), new TitleCommand(game), new PromptCommand(game), new BugCommand(game), new HelpCommand() }; GameConsoleOptions.Commands.AddRange(inbuiltCommands); }
public TextInput(Game game, Vector2 position, int width, int height) { if (!EventInput.initialized) { EventInput.Initialize(game.Window); } EventInput.CharEntered += EventInput_CharEntered; EventInput.KeyDown += EventInput_KeyDown; Game = game; GraphicsDevice = game.GraphicsDevice; ControlRectangle = new Rectangle((int)position.X, (int)position.Y, width, height); SkipDraw = true; CursorDimensions = new Dimensions(width, height); DefaultHeight = height; }
public Game1() { myGraphicsDeviceManager = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = 1280, PreferredBackBufferHeight = 720 }; GameInfo.myMouseFunction = SetMouseVisibility; GameInfo.myScreenSize.X = myGraphicsDeviceManager.PreferredBackBufferWidth; GameInfo.myScreenSize.Y = myGraphicsDeviceManager.PreferredBackBufferHeight; //graphics.SynchronizeWithVerticalRetrace = false; //IsFixedTimeStep = false; Content.RootDirectory = "Content"; ContentManagerInstance.Content = Content; EventInput.Initialize(Window); }
protected override void Initialize() { VertexPositions.Initialize(); EventInput.Initialize(Window); Blocks.InitialzizeBlocks(); _graphics.PreferredBackBufferWidth = Config.Width; _graphics.PreferredBackBufferHeight = Config.Height; if (!Config.VSync) { IsFixedTimeStep = false; _graphics.SynchronizeWithVerticalRetrace = false; } _graphics.ApplyChanges(); _camera = new Camera(0.3f, 0.002f, GraphicsDevice); //move speed, rotate speed, ... _spriteBatch = new SpriteBatch(GraphicsDevice); _statistics = new StatisticOverlay(Content.Load <SpriteFont>("NormalFont"), new Vector2(48, 48)); //debug _mainMenu = new MainMenu(Content); base.Initialize(); }