protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); _bitmapFont = Content.Load<BitmapFont>("montserrat-32"); var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(viewportAdapter) { Zoom = 2.0f }; _sceneGraph = new SceneGraph(); var carHullTexture = Content.Load<Texture2D>("car-hull"); var carHullSprite = new Sprite(carHullTexture); var carWheelTexture = Content.Load<Texture2D>("car-wheel"); var carWheelSprite = new Sprite(carWheelTexture); _carNode = new SceneNode("car-hull", viewportAdapter.Center.ToVector2()); _carNode.Entities.Add(carHullSprite); _leftWheelNode = new SceneNode("left-wheel", new Vector2(-29, 17)); _leftWheelNode.Entities.Add(carWheelSprite); _rightWheelNode = new SceneNode("right-wheel", new Vector2(40, 17)); _rightWheelNode.Entities.Add(carWheelSprite); _carNode.Children.Add(_rightWheelNode); _carNode.Children.Add(_leftWheelNode); _sceneGraph.RootNode.Children.Add(_carNode); }
protected override void Initialize() { base.Initialize(); var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(viewportAdapter); }
protected override void Initialize() { var viewPortAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); regularCoin.InitializeList(coins); camera = new Camera2D(viewPortAdapter); base.Initialize(); }
//protected override void Initialize() //{ // base.Initialize(); // _graphicsDeviceManager.IsFullScreen = true; // _graphicsDeviceManager.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width; // _graphicsDeviceManager.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height; // _graphicsDeviceManager.ApplyChanges(); //} protected override void LoadContent() { _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _font = Content.Load<BitmapFont>("Fonts/courier-new-32"); _camera = new Camera2D(_viewportAdapter); _explosionAnimations = Content.Load<SpriteSheetAnimationGroup>("explosion-animations"); _spriteBatch = new SpriteBatch(GraphicsDevice); _backgroundTexture = Content.Load<Texture2D>("black"); var bulletTexture = Content.Load<Texture2D>("laserBlue03"); var bulletRegion = new TextureRegion2D(bulletTexture); _bulletFactory = new BulletFactory(_entityManager, bulletRegion); SpawnPlayer(_bulletFactory); _meteorFactory = new MeteorFactory(_entityManager, Content); for (var i = 0; i < 13; i++) { _meteorFactory.SpawnNewMeteor(_player.Position); } }
protected override void LoadContent() { _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(_viewportAdapter); _backgroundTexture = Content.Load<Texture2D>("vignette"); _bitmapFont = Content.Load<BitmapFont>("montserrat-32"); _spriteBatch = new SpriteBatch(GraphicsDevice); }
protected override void Initialize() { _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(_viewportAdapter); Window.AllowUserResizing = true; Window.Position = Point.Zero; Components.Add(_fpsCounter = new FramesPerSecondCounterComponent(this)); base.Initialize(); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); _bitmapFont = Content.Load<BitmapFont>("montserrat-32"); _tiledMap = Content.Load<TiledMap>("level01"); var viewportAdapter = new ScalingViewportAdapter(GraphicsDevice, 800, 480); _camera = new Camera2D(viewportAdapter) { Zoom = 0.5f, Position = new Vector2(_tiledMap.WidthInPixels / 4f, _tiledMap.HeightInPixels / 4f) }; }
public void Draw(Camera2D camera, SpriteBatch spriteBatch) { spriteBatch.Begin(transformMatrix: SceneManager.Instance.ViewportAdapter.GetScaleMatrix(), samplerState: SamplerState.PointWrap); spriteBatch.Draw(_static, Vector2.Zero, Color.White); if (!IsBossMap) { spriteBatch.Draw(_treeBack2, new Vector2(0, _treeBack2Offset + _verticalOffset * 0.2f), new Rectangle((int)(camera.Position.X * 0.3f), 0, _treeBack1.Width, _treeBack1.Height), Color.White); spriteBatch.Draw(_treeBack1, new Vector2(0, _treeBack1Offset + _verticalOffset * 0.4f), new Rectangle((int)(camera.Position.X * 0.5f), 0, _treeBack1.Width, _treeBack1.Height), Color.White); } spriteBatch.End(); }
public void SetupCameraKeys(Camera2D _camera) { const float movementSpeed = 200; const float rotationSpeed = 0.5f; const float zoomSpeed = 0.5f; var cameraMovement = _inputManager.AddListener(new KeyboardListenerSettings()); cameraMovement.KeyTyped += (sender, arg) => { if (arg.Key == Keys.W) _camera.Move(new Vector2(0, -movementSpeed) * deltaTime); if (arg.Key == Keys.S) _camera.Move(new Vector2(0, movementSpeed) * deltaTime); if (arg.Key == Keys.A) _camera.Move(new Vector2(-movementSpeed, 0) * deltaTime); if(arg.Key == Keys.D) _camera.Move(new Vector2(movementSpeed, 0) * deltaTime); }; }
protected override void Initialize() { _viewportAdapter = new BoxingViewportAdapter(GraphicsDevice, 800, 480); _camera = new Camera2D(_viewportAdapter) { //Zoom = 0.5f, Origin = new Vector2(400, 240), //Position = new Vector2(408, 270) }; Window.AllowUserResizing = true; Window.ClientSizeChanged += (s, e) => _viewportAdapter.OnClientSizeChanged(); SetUpInput(); base.Initialize(); }
protected override void Initialize() { _fpsCounter = new FramesPerSecondCounter(); _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(_viewportAdapter); //{ // MinimumZoom = 0.1f, // MaximumZoom = 2.0f, // Zoom = 0.7833337f, // Origin = new Vector2(400, 240), // Position = new Vector2(408, 270) //}; Window.AllowUserResizing = true; base.Initialize(); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(viewportAdapter); var logoTexture = Content.Load<Texture2D>("logo-square-128"); _sprite = new Sprite(logoTexture) { Position = viewportAdapter.Center.ToVector2() }; var particleTexture = new Texture2D(GraphicsDevice, 1, 1); particleTexture.SetData(new[] { Color.White }); ParticleInit(new TextureRegion2D(particleTexture)); }
protected override void Initialize() { _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(_viewportAdapter) { MinimumZoom = 0.1f, MaximumZoom = 2.0f, Zoom = 0.7833337f, Origin = new Vector2(400, 240), Position = new Vector2(408, 270) }; Window.Title = $"MonoGame.Extended - {GetType().Name}"; Window.Position = Point.Zero; Window.AllowUserResizing = true; base.Initialize(); }
protected override void Initialize() { _fpsCounter = new FramesPerSecondCounter(); _viewportAdapter = new BoxingViewportAdapter(GraphicsDevice, 800, 480); _camera = new Camera2D(_viewportAdapter) { MinimumZoom = 0.5f, MaximumZoom = 2.0f, Zoom = 0.5f, Origin = new Vector2(400, 240), Position = new Vector2(408, 270) }; Window.AllowUserResizing = true; Window.ClientSizeChanged += (s, e) => _viewportAdapter.OnClientSizeChanged(); 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() { _camera = new Camera2D(GraphicsDevice); _camera.Position = new Vector2(-400,1400); _mouseLight = new MouseLight(new Vector2(Mouse.GetState().Position.X, Mouse.GetState().Position.Y), new Vector4(1, 1, 1, 1)); _hexes = new Hex[40000]; for (int i = 0; i < _hexes.Length; i++) { Vector2 position = HelperFuncts.NextHexPos(); _hexes[i] = new Hex(position); } MovementHelper.Hexes = _hexes; previousKeyBoardState = Keyboard.GetState(); HelperFuncts.GraphicsDevicePointer = graphics.GraphicsDevice; Components.Add(new FrameRateCounter(this)); // MovementHelper.ShortestPath(202,805); base.Initialize(); }
public void Draw(Camera2D camera, SpriteBatch spriteBatch) { spriteBatch.Begin(transformMatrix: camera.GetViewMatrix(), samplerState: SamplerState.PointClamp); _tiledMap.Draw(camera); if (SceneManager.Instance.DebugMode) DrawColliders(spriteBatch); spriteBatch.End(); }
//protected override void Initialize() //{ // base.Initialize(); // _graphicsDeviceManager.IsFullScreen = true; // _graphicsDeviceManager.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width; // _graphicsDeviceManager.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height; // _graphicsDeviceManager.ApplyChanges(); //} protected override void LoadContent() { _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _guiManager = new GuiManager(_viewportAdapter, GraphicsDevice); _font = Content.Load<BitmapFont>("Fonts/courier-new-32"); var normal = new GuiTextureRegionDrawable(new TextureRegion2D(Content.Load<Texture2D>("Gui/button-normal"))); var pressed = new GuiTextureRegionDrawable(new TextureRegion2D(Content.Load<Texture2D>("Gui/button-clicked"))); var hover = new GuiTextureRegionDrawable(new TextureRegion2D(Content.Load<Texture2D>("Gui/button-hover"))); var buttonStyle = new GuiButtonStyle(normal, pressed, hover); var button = new GuiButton(buttonStyle) { Position = new Vector2(400, 240) }; button.Clicked += (sender, args) => { if (_player != null) { Explode(_player.Position, 3); _player.Destroy(); _player = null; } }; _guiManager.Controls.Add(button); var labelStyle = new GuiLabelStyle(_font); var label = new GuiLabel(labelStyle, "Hello") { Position = new Vector2(100, 100) }; label.MouseUp += (sender, args) => label.Text = args.Position.ToString(); _guiManager.Controls.Add(label); _camera = new Camera2D(_viewportAdapter); _explosionAnimations = Content.Load<SpriteSheetAnimationGroup>("explosion-animations"); _spriteBatch = new SpriteBatch(GraphicsDevice); _backgroundTexture = Content.Load<Texture2D>("black"); var bulletTexture = Content.Load<Texture2D>("laserBlue03"); var bulletRegion = new TextureRegion2D(bulletTexture); _bulletFactory = new BulletFactory(_entityManager, bulletRegion); SpawnPlayer(_bulletFactory); _meteorFactory = new MeteorFactory(_entityManager, Content); for (var i = 0; i < 13; i++) _meteorFactory.SpawnNewMeteor(_player.Position); }
/// <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() { // TODO: Add your initialization logic here base.Initialize(); IsMouseVisible = true; _camera = new Camera2D(GraphicsDevice); _camera.Zoom = 2.0f; _camera.Position = new Vector2(-120,-5); }
//----------------------//------------------------// public override void LoadContent() { base.LoadContent(); var viewportSize = SceneManager.Instance.VirtualSize; _camera = new Camera2D(SceneManager.Instance.ViewportAdapter); // Player init _player = new Player(ImageManager.loadCharacter("Player")); // Enemies init _enemies = new List<Enemy>(); // Projectiles init _projectilesTextures = new Dictionary<string, Texture2D>() { {"common", ImageManager.loadProjectile("Common")}, {"cannonball", ImageManager.loadProjectile("Cannonball")} }; _projectiles = new List<GameProjectile>(); _shotSe = SoundManager.LoadSe("Shot"); _projectilesColliderTexture = new Texture2D(SceneManager.Instance.GraphicsDevice, 1, 1); _projectilesColliderTexture.SetData<Color>(new Color[]{ Color.Orange }); // Shops init _shops = new List<GameShop>(); // Checkpoints init _checkpoints = new List<GameCheckpoint>(); // Coins init _coins = new List<GameCoin>(); _coinsSe = SoundManager.LoadSe("Coins"); // Random init _rand = new Random(); // Stage Complete Helper init _stageCompletedHelper = new SceneMapSCHelper(); // Pause helper init _pauseHelper = new SceneMapPauseHelper(); // Ambience SE init var ambienceSe = SoundManager.LoadSe("Ambience"); if (ambienceSe == null) { _ambienceSe = null; } else { _ambienceSe = ambienceSe.CreateInstance(); _ambienceSe.IsLooped = true; } // Load the map LoadMap(SceneManager.Instance.MapToLoad); // Create the HUD CreateHud(); // Background init _backgroundHelper = new SceneMapBackgroundHelper(); // Start BGM and Ambience SE SoundManager.StartBgm(SoundManager.BGMType.Map); _ambienceSe.PlaySafe(); }
protected override void Initialize() { base.Initialize(); _camera = new Camera2D(GraphicsDevice); }
protected override void Initialize() { base.Initialize(); _camera = new Camera2D(GraphicsDevice); _camera.MaximumZoom = 1f; _camera.MinimumZoom = .5f;//.3f? _camera.Zoom = .8f; _debugView = new DebugView(_world, game,_ratio); IsMouseVisible = true; negativeForce = false; Pause = false; GameOver = false; CalledMother = false; }
protected override void Initialize() { base.Initialize(); _camera = new Camera2D(GraphicsDevice); _camera.MaximumZoom = 1f; _camera.MinimumZoom = .5f;//.3f? _camera.Zoom = .8f; _debugView = new DebugView(_world, game,_ratio); IsMouseVisible = true; negativeForce = false; Pause = false; GameOver = false; #region Obsolete //_listeners = new Listeners(); //_listeners.SetupCameraKeys(_camera); //_listeners.SetPlayerKeys() #endregion }
//protected override void Initialize() //{ // base.Initialize(); // _graphicsDeviceManager.IsFullScreen = true; // _graphicsDeviceManager.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width; // _graphicsDeviceManager.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height; // _graphicsDeviceManager.ApplyChanges(); //} protected override void LoadContent() { _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _guiManager = new GuiManager(_viewportAdapter, GraphicsDevice); _font = Content.Load<BitmapFont>("Fonts/courier-new-32"); //var textureRegion = new TextureRegion2D(Content.Load<Texture2D>("Gui/9patch-2")); //var dialogPatch = new GuiPatchDrawable(textureRegion, 100, 100, 122, 111, Color.White); //var dialogStyle = new GuiButtonStyle(dialogPatch); //var dialog = new GuiButton(dialogStyle) //{ // HorizontalAlignment = GuiHorizontalAlignment.Stretch, // VerticalAlignment = GuiVerticalAlignment.Stretch //}; //_guiManager.Layout.Children.Add(dialog); var checkedOn = Content.Load<Texture2D>("Gui/button-clicked").ToGuiDrawable(); var checkedOff = Content.Load<Texture2D>("Gui/button-normal").ToGuiDrawable(); var checkBoxStyle = new GuiCheckBoxStyle(checkedOn, checkedOff); var checkBox = new GuiCheckBox(checkBoxStyle) {HorizontalAlignment = GuiHorizontalAlignment.Left}; _guiManager.Layout.Children.Add(checkBox); var normal = Content.Load<Texture2D>("Gui/button-normal").ToGuiDrawable(); var pressed = Content.Load<Texture2D>("Gui/button-clicked").ToGuiDrawable(); var hover = Content.Load<Texture2D>("Gui/button-hover").ToGuiDrawable(); var buttonStyle = new GuiButtonStyle(normal, pressed, hover); var button = new GuiButton(buttonStyle) {VerticalAlignment = GuiVerticalAlignment.Bottom}; button.Clicked += (sender, args) => { if (_player != null) { Explode(_player.Position, 3); _player.Destroy(); _player = null; } }; _guiManager.Layout.Children.Add(button); var labelStyle = new GuiLabelStyle(_font); _scoreLabel = new GuiLabel(labelStyle, "Hello") { HorizontalAlignment = GuiHorizontalAlignment.Right, VerticalAlignment = GuiVerticalAlignment.Top }; _guiManager.Layout.Children.Add(_scoreLabel); _guiManager.PerformLayout(); _camera = new Camera2D(_viewportAdapter); _explosionAnimations = Content.Load<SpriteSheetAnimationGroup>("explosion-animations"); _spriteBatch = new SpriteBatch(GraphicsDevice); _backgroundTexture = Content.Load<Texture2D>("black"); var bulletTexture = Content.Load<Texture2D>("laserBlue03"); var bulletRegion = new TextureRegion2D(bulletTexture); _bulletFactory = new BulletFactory(_entityManager, bulletRegion); SpawnPlayer(_bulletFactory); _meteorFactory = new MeteorFactory(_entityManager, Content); for (var i = 0; i < 13; i++) _meteorFactory.SpawnNewMeteor(_player.Position); }
public void Update(Camera2D camera) { _verticalOffset = Math.Max(GameMap.Instance.MapHeight - SceneManager.Instance.VirtualSize.Y - camera.Position.Y, 0); }
/// <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() { // TODO: Add your initialization logic here fpsCounter = new FramesPerSecondCounter(); viewportAdapter = new BoxingViewportAdapter(GraphicsDevice, Settings.ResolutionWidth, Settings.ResolutionHeight); camera = new Camera2D(viewportAdapter) { Zoom = 1f }; IsMouseVisible = true; //Window.AllowUserResizing = true; Window.ClientSizeChanged += (s, e) => viewportAdapter.OnClientSizeChanged(); DatabaseConnector.SetConnectionString(Settings.ServerName, Settings.Username, Settings.Password, Settings.DatabaseName); base.Initialize(); }
public void Draw(Camera2D camera, SpriteBatch batch, Character player) { foreach (var layer in Map.Layers) layer.Draw(); if (Debug) { foreach (var encounterCollide in EncounterColliders) { batch.Draw(ContentLoader.Button, encounterCollide, Color.Green); } foreach (var collisionCollide in CollisionColliders) { batch.Draw(ContentLoader.Button, collisionCollide, Color.Blue); } foreach (var areaCollide in AreaColliders) { batch.Draw(ContentLoader.Button, areaCollide.Key, Color.Aqua); } foreach (var opponent in OpponentList) { batch.Draw(ContentLoader.Health, opponent.AI.Hitbox, Color.White); } } foreach (var opponent in OpponentList) { opponent.Draw(batch); } foreach (var shop in shopList) { shop.Draw(batch, player); } Box.Draw(batch); foreach (var boxCollide in BoxColliders) { batch.Draw(ContentLoader.Health, boxCollide, Color.Red); } }
/// <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() { // TODO: Add your initialization logic here _camera = new Camera2D(GraphicsDevice); _camera.Zoom = 4.5f; _camera.Position = new Vector2(-120, -5); IsMouseVisible = true; base.Initialize(); _gameClient = new gameClient(); _gameClient.Content = Content; RenderData.Content = Content; _gameClient.Start(); BuildWorld(); }