public Engine(ContentManager content, ScreenManager screenManager) { this.ScreenManager = screenManager; components = new List<Component>(); componentsToBeAdded = new List<Component>(); componentsToBeRemoved = new List<Component>(); Content = content; Audio = new Audio(this); Input = new InputState(); Physics = new Physics(this); Video = new Video(this); // these things require video Camera = new Camera2D(this); // lighting needs to know the camera matrix Lighting = new Lighting(this); SpriteBatch = new SpriteBatch(Global.GraphicsDeviceManager.GraphicsDevice); BloomComponent = new BloomComponent(this); BloomComponent.DrawOrder = int.MaxValue; BloomComponent.LoadContent(); Updating = false; }
public void Update(Camera2D _camera) { if (_isMoving) UpdateMove(_camera); else UpdateParallax(_camera); }
public void Update(Camera2D camera) { if (this.AttachedProjectile.X <= (float)(camera.Bounds.Left + this.m_iconOffset)) { base.X = (float)this.m_iconOffset; } else if (this.AttachedProjectile.X > (float)(camera.Bounds.Right - this.m_iconOffset)) { base.X = (float)(1320 - this.m_iconOffset); } else { base.X = this.AttachedProjectile.X - camera.TopLeftCorner.X; } if (this.AttachedProjectile.Y <= (float)(camera.Bounds.Top + this.m_iconOffset)) { base.Y = (float)this.m_iconOffset; } else if (this.AttachedProjectile.Y > (float)(camera.Bounds.Bottom - this.m_iconOffset)) { base.Y = (float)(720 - this.m_iconOffset); } else { base.Y = this.AttachedProjectile.Y - camera.TopLeftCorner.Y; } base.Rotation = CDGMath.AngleBetweenPts(camera.TopLeftCorner + base.Position, this.AttachedProjectile.Position); this.m_iconBG.Position = base.Position; this.m_iconBG.Rotation = base.Rotation; this.m_iconProjectile.Position = base.Position; this.m_iconProjectile.Rotation = this.AttachedProjectile.Rotation; this.m_iconProjectile.GoToFrame(this.AttachedProjectile.CurrentFrame); }
public Scenario(GameScreen gameScreen, GameWorld world, Camera2D camera) : base(gameScreen, world, camera) { levelNumber = 0; physics.bodys = new Body[1]{ new Body(world) }; images = new List<SpriteSheet>(); }
void DrawTile(Map map, Layer layer, Camera2D camera, Vector2 position, string selectedTileName) { if (!string.IsNullOrEmpty(selectedTileName)) { var point = new Vector2((int)((camera.Position.X + position.X) / 32), (int)((camera.Position.Y + position.Y) / 32)); if (layer.Tiles.ContainsKey(point)) layer.Tiles.Remove(point); layer.Tiles.Add(point, TileRepository.GetTile(selectedTileName)); /*UndoService.Current[map].AddChange(new DelegateChange(null, new Action(() => { layer.Tiles.Remove(point); }), new Action(() => { layer.Tiles.Add(point, TileRepository.GetTile(selectedTileName)); }), selectedTileName), "Draw a tile");*/ /*MainForm.MapPanel.AddShadowForObject(Texture2D.FromStream(MainForm.MapPanel.GraphicsDevice, TileRepository.GetTile(selectedTileName).Texture), point);*/ base.OnMouseMove(map, layer, camera, position, selectedTileName); } }
public override void LoadContent() { if (Camera == null) { Camera = new Camera2D(ScreenManager.GraphicsDevice); } iHUD = ScreenManager.Game.Services.GetService(typeof(IHUD)) as IHUD; iVisualiser = ScreenManager.Game.Services.GetService(typeof(IVisualiser)) as IVisualiser; //Swinger texture SwingerTexture = ScreenManager.Content.Load<Texture2D>("Common/slider"); //Halo texture HaloTexture = ScreenManager.Content.Load<Texture2D>("Common/halo"); //SpeedBoost texture SpeedBoostTexture = ScreenManager.Content.Load<Texture2D>("Common/slider"); //bullet texture BulletTexture = ScreenManager.Content.Load<Texture2D>("Common/bullet"); //////////////////////////////// //ObstacleManager //////////////////////////////// ObstacleManager = new ObstacleManager(); ObstacleManager.LoadContent(ScreenManager); base.LoadContent(); }
public void Draw(SpriteBatch spriteBatch, Camera2D camera) { foreach (MapLayer layer in mapLayers) { layer.Draw(camera, tilesets); } }
public Screen(ScreenManager manager) { this.manager = manager; this.loadComplete = false; this.camera = new Camera2D(manager.ViewManager.Width, manager.ViewManager.Height); this.inputManager = new InputManager(); }
public GameWorld(Vector2 gravity, float airDrag, Camera2D camera) : base(gravity) { this.camera = camera; this.airDrag = airDrag; this.BodyAdded += BodyAddedHandler; }
public override void Draw(SpriteBatch spriteBatch, Camera2D camera, Vector2 mousePosition, Texture2D pixel) { spriteBatch.Draw(pixel, new Rectangle((int)((camera.Position.X + mousePosition.X) / 32) * 32 + 1, (int)((camera.Position.Y + mousePosition.Y) / 32) * 32, 32, 32), Color.Orange); base.Draw(spriteBatch, camera, mousePosition, pixel); }
public override void Draw(Camera2D camera) { if ((this.ShowTerrain && CollisionMath.Intersects(this.Bounds, camera.Bounds)) || base.ForceDraw) { camera.Draw(Game.GenericTexture, base.Position, new Rectangle?(new Rectangle(0, 0, this.Width, this.Height)), base.TextureColor, MathHelper.ToRadians(base.Rotation), Vector2.Zero, 1f, SpriteEffects.None, 0f); } }
public void UpdateParallax(Camera2D _camera) { Matrix pos = _camera.GetParallaxMatrix(_speed); if (_camera.IsPlayerFollow) { _position.X = -pos.M41 - (int)-pos.M41 % _width; _position2.X = _position.X + _width; } else { if (-pos.M41 > _position2.X + -_camera.Translation.X && -pos.M41 < _position2.X + _width) _position.X = _position2.X + _width; else _position.X = _position2.X - _width; if (-pos.M41 > _position.X + -_camera.Translation.X && -pos.M41 < _position.X + _width) _position2.X = _position.X + _width; else _position2.X = _position.X - _width; } _position.Y = -pos.M42; _position2.Y = -pos.M42; }
public void Draw(Camera2D camera, List<Tileset> tilesets) { var destination = new Rectangle(0, 0, Engine.TileWidth, Engine.TileHeight); // TODO: Replace this drawcall with a single drawcall to render all grass tiles for (int y = 0; y < Height; y++) { destination.Y = y * Engine.TileHeight + (int)Engine.Origin.Y; for (int x = 0; x < Width; x++) { Tile tile = GetTile(x, y); if (tile.TileIndex == -1 || tile.Tileset == -1) continue; destination.X = x * Engine.TileWidth + (int)Engine.Origin.X; var position = new Vector2(destination.X, destination.Y); if (camera.IsVisible(position)) { FinalBomber.Instance.SpriteBatch.Draw( tilesets[tile.Tileset].Texture, destination, tilesets[tile.Tileset].SourceRectangles[tile.TileIndex], Color.White); } } } }
public Layer(Camera2D camera, float scrollRateX = 1f, float scrollRateY = 1f) { Offset = new Vector2(0,0); this.Camera = camera; ScrollRateX = scrollRateX ; ScrollRateY = ScrollRateY ; }
public void OnEnable() { _Camera = (Camera)target; _Camera2D = _Camera.gameObject.GetComponent<Camera2D>(); _Camera2D = _Camera2D ?? _Camera.gameObject.AddComponent<Camera2D>(); _Camera2D.hideFlags = HideFlags.HideInInspector; }
public ControllerViewManager(GraphicsDevice graphicsDevice, ContentManager content) { controllers = new List<Controller>(); views = new List<IView>(); this.content = content; this.graphicsDevice = graphicsDevice; this.batch = new SpriteBatch(graphicsDevice); this.world = new World(new Vector2(0, Constants.GamePlayGravity)); this.controllerQueue = new ConcurrentQueue<Tuple<Controller, QueueState>>(); this.viewQueue = new ConcurrentQueue<Tuple<IView, QueueState>>(); if (Constants.DebugMode && debugView == null) { debugView = new DebugViewXNA(world); debugView.AppendFlags(DebugViewFlags.DebugPanel); debugView.DefaultShapeColor = Color.Red; debugView.SleepingShapeColor = Color.Green; debugView.LoadContent(graphicsDevice, content); } if (camera == null) { Viewport v = graphicsDevice.Viewport; camera = new Camera2D(graphicsDevice); camera.Position = new Vector2(v.Width / 2, v.Height / 2); } else camera.ResetCamera(); }
public void Draw(Camera2D camera, GameTime gameTime) { if (PreSteps.Count > 0) foreach (var s in PreSteps) s(camera, this, gameTime); if (Skip) return; camera.GraphicsDevice.SetRenderTarget(RenderTarget); if (ClearColor != null) camera.GraphicsDevice.Clear(ClearColor.Value); if (ShaderSteps.Count > 0) foreach (var s in ShaderSteps) s.Prepare(camera); camera.Begin(SpriteSortMode, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect, TransformMatrix); if (DrawSteps.Count > 0) foreach (var s in DrawSteps) s(camera, this, gameTime); camera.End(); }
public override void Draw(Camera2D camera) { _spriteBatch.Begin(sortMode: SpriteSortMode.Immediate, blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointClamp, transformMatrix: camera.GetViewMatrix()); _spriteBatch.Draw(_texture, Position, Color.White); _spriteBatch.End(); }
protected PhysicsGameScreen() { HasCursor = false; World = null; Camera = null; DebugView = null; EnabledGestures = GestureType.None; }
public override void Draw(Camera2D camera) { if (base.Visible) { this.m_iconBG.Draw(camera); this.m_iconProjectile.Draw(camera); } }
public HImageListView(Vector2 pPosition, int pWidth, int pHeight, Color pBackgroundColor) : base(pPosition, pWidth, pHeight, pBackgroundColor) { _camera = new Camera2D(Vector2.Zero, _position); _scrollUp = new Rectangle((int)(pPosition.X + pWidth - 30), (int)(pPosition.Y + 10), 20, 20); _scrollDown = new Rectangle((int)(pPosition.X + pWidth - 30), (int)(pPosition.Y + pHeight-30), 20, 20); }
public override void Draw(SpriteBatch spritebatch, Camera2D camera = null) { Vector2 r = rotationMatrix.rotate(new Vector2((int)(xPosition), (int)(yPosition))); if (camera == null || camera.IsInView(r, texture)) { spritebatch.Draw(texture, r, null, Color.White, 0, new Vector2(texture.Width / 2, texture.Height / 2), 1, SpriteEffects.None, 0); } }
public void UpdateMove(Camera2D _camera) { Matrix pos = _camera.GetTransformMatrix(); if (-pos.M41 % _width*2 == 0) _position.X = -pos.M41 + _width; _position.X += -_speed; }
public void Draw(Camera2D Camera) { foreach (Sprite Tile in Tiles) { if (Tile == null) { continue; } Tile.Draw(Camera); } }
public void Camera2D_ContainsRectangle_Test() { var graphicsDevice = TestHelper.CreateGraphicsDevice(); var camera = new Camera2D(graphicsDevice); Assert.AreEqual(ContainmentType.Intersects, camera.Contains(new Rectangle(-50, -50, 100, 100))); Assert.AreEqual(ContainmentType.Contains, camera.Contains(new Rectangle(50, 50, 100, 100))); Assert.AreEqual(ContainmentType.Disjoint, camera.Contains(new Rectangle(850, 500, 100, 100))); }
void PickTile(Layer layer, Camera2D camera, Vector2 position) { var point = new Vector2((int)((camera.Position.X + position.X) / 32), (int)((camera.Position.Y + position.Y) / 32)); if (layer.Tiles.ContainsKey(point)) { _form.SelectTile(layer.Tiles[point].Name); } }
public override void Init() { Block.BLOCK_SIZE = 1280 / WorldRenderer.WIDTH; this.camera = new Camera2D(GetGraphics(), 1280, 720); this.world = new World(); this.renderer = new WorldRenderer(this); this.score = START_SCORE; this.lives = DEFAULT_LIFES; }
private void PrepareRippleRender(Camera2D camera, RenderStep step, GameTime gameTime) { Vector2 position = Game.Player.Instance.GameObject.Position - camera.TopLeftCorner; var effect = Shaders.Ripple; effect.Parameters["width"].SetValue(Magnitude); effect.Parameters["xcenter"].SetValue(position.X / 1320f); effect.Parameters["ycenter"].SetValue(position.Y / 720f); step.Effect = effect; }
public void Draw(GameTime gameTime, Camera2D camera) { if (!camera.IsVisible(Position)) return; Sprite.Draw(gameTime, FinalBomber.Instance.SpriteBatch, Position); if (_itemDestroyAnimation.IsAnimating) _itemDestroyAnimation.Draw(gameTime, FinalBomber.Instance.SpriteBatch, Position); }
public override void Draw(GameTime gameTime, SpriteBatch batch, Camera2D camera, Vector2 scale) { base.Draw(gameTime, batch, camera, scale); float health = ((float)this.CurHealth) / ((float)this.MaxHealth); Vector2 offset = new Vector2(this.Position.X - camera.Window.X, this.Position.Y - camera.Window.Y - 16); offset.X -= (healthBarEnemy.Bounds.Width / 2) - (this.Bounds.Width / 2); batch.Draw(healthBarEnemy, new Rectangle((int)offset.X, (int)offset.Y, (int)(((float)healthBarEnemy.Width) * health), healthBarEnemy.Height), new Rectangle(0, 0, (int)(((float)healthBarEnemy.Width) * health), healthBarEnemy.Height), Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.09f); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { AluminumVolume = (Height * Thickness * 2 + (Width - 2 * Thickness) * 2 * Thickness) * Width + (Height - 2 * Thickness) * (Width - 2 * Thickness) * Thickness; AluminumMass = AluminumVolume * ALUMINUM_DENSITY; // 2.7 g/cm^3 RocketVolume = Height * Width * Width; FueledMass = AluminumMass / (1 - FuelPercentage); FuelSpace = 0.8f * Height; InsideArea = (float)Math.Pow(Width - 2 * Thickness, 2); FuelDensity = FueledMass / (InsideArea * FuelSpace); targetLockIndicator = GetNode <Sprite>("LockIndicator"); activeCamera = GetNode <Camera2D>("ShipCam"); thrusterFlame = GetNode <Sprite>("ThrusterFlame"); laserCooldownTimer = GetNode <Timer>("LaserCooldown"); railgunCooldownTimer = GetNode <Timer>("RailgunCooldown"); missileCooldownTimer = GetNode <Timer>("MissileCooldown"); laserCooldownTimer.Connect("timeout", this, "OnLaserCooldownFinished"); railgunCooldownTimer.Connect("timeout", this, "OnRailgunCooldownFinished"); missileCooldownTimer.Connect("timeout", this, "OnMissileCooldownFinished"); }
public void Draw(Camera2D camera, bool useMapBackgroundColor = false) { _graphicsDevice.SetRenderTarget(_renderTarget); if (useMapBackgroundColor && BackgroundColor.HasValue) { _graphicsDevice.Clear(BackgroundColor.Value); } foreach (var layer in _layers) { layer.Draw(); } _graphicsDevice.SetRenderTarget(null); _spriteBatch.Begin(sortMode: SpriteSortMode.Immediate, blendState: BlendState.NonPremultiplied, samplerState: SamplerState.PointClamp, transformMatrix: camera.GetViewMatrix()); _spriteBatch.Draw(_renderTarget, Vector2.Zero, Color.White); _spriteBatch.End(); }
protected override void LoadContent() { loadSpriteFactories(); SoundManager.Instance.LoadAllSounds(Content); allObjectsManager = new TheGameObjectManager(); GameUtilities.GameObjectManager = allObjectsManager; spriteBatch = new SpriteBatch(GraphicsDevice); GameUtilities.Game = this; int width = GraphicsDevice.Viewport.Bounds.Width; int height = GraphicsDevice.Viewport.Bounds.Height; LoadLevel loader = new LoadLevel(width, height, allObjectsManager); InitializeControllers(); loader.loadTheLevel(); camera = new Camera2D(); Camera2D.LimitationList.Add(GameUtilities.LevelEndLine * GameUtilities.BlockSize); Camera2D.LimitationList.Add(GameUtilities.UndergroundEndLine * GameUtilities.BlockSize); Camera2D.LimitationList.Add(GameUtilities.Competitive1EndLine * GameUtilities.BlockSize); Camera2D.LimitationList.Add(GameUtilities.Competitive2EndLine * GameUtilities.BlockSize); }
public override void _Ready() { base._Ready(); _camera = GetNode <Camera2D>("Camera2D"); _reloadBar = GetNode <ReloadBar>("ReloadBar"); _reloadBar.Connect(nameof(ReloadBar.ReloadFinished), this, nameof(OnReloadBarFinished)); _hitBox.Connect("area_entered", this, nameof(OnHitBoxAreaEntered)); _timeIndicator = GetNode <TimeIndicator>("TimeIndicator"); _currentWeapon = GetNode <WeaponBase>("Weapon"); UpdateHUD(); AddChild(_dashTimer); GameManager.Instance.SceneManager.Connect(nameof(SceneManager.OnLevelChange), this, nameof(OnLevelChange)); }
/// <summary> /// Update het game over scherm /// </summary> /// <param name="gameTime">GameTime object dat ervoor zorgt dat we iets op een bepaalde tijd kunnen afspelen</param> /// <param name="camera">Camera2D object dat de hero volgt</param> /// <param name="hero">Hero object dat we besturen</param> /// <param name="collisionObjects">Lijst met alle objecten die kunnen colliden</param> /// <param name="background">Background object voor de game</param> /// <param name="collider">Collider object die kijkt of er een collision gebeurt</param> /// <param name="currentLevel">Level object dat ons huidig level bevat</param> public void Update(GameTime gameTime, Camera2D camera, Hero hero, List <ICollide> collisionObjects, Background background, Collider collider, ref Level currentLevel) { mouseState = Mouse.GetState(); screenManager.MakeMouseVisible(true); if (quitButton.Update(new Vector2(mouseState.X, mouseState.Y)) == true && mouseState != prevMouseState && mouseState.LeftButton == ButtonState.Pressed) { screenManager.Quit(); } else if (mainMenuButton.Update(new Vector2(mouseState.X, mouseState.Y)) == true && mouseState != prevMouseState && mouseState.LeftButton == ButtonState.Pressed) { screenManager.SetState(screenManager.GetMainMenuScreen()); } else if (restartButton.Update(new Vector2(mouseState.X, mouseState.Y)) == true && mouseState != prevMouseState && mouseState.LeftButton == ButtonState.Pressed) { RestartLevel(new Vector2(150, 600), ref currentLevel, collisionObjects, hero); ResetHeroCollectedStars(hero); ResetHeroLives(hero); screenManager.SetState(screenManager.GetPlayScreen()); } prevMouseState = mouseState; }
protected BaseLevel(Game1 game, Texture2D texture, Texture2D background, Texture2D portalTexture, int size) { _game = game; _texture = texture; _background = background; _portalTexture = portalTexture; _viewport = game.GraphicsDevice.Viewport; _tiles = new List <Tile>(); _shotsFired = new List <Bullet>(); _collidablesToRemove = new List <ICollidable>(); Size = size; Player = new Player( graphicsDevice: _game.GraphicsDevice, texture: Utility.LoadTexture(game, Player.ASSET_NAME), position: game.CurrentPlayingState.Movement.Position, bulletTexture: Utility.LoadTexture(game, "SpriteSheets/Wizard/wizardBullet") ); Camera = new Camera2D(_viewport); Characters = game.CurrentPlayingState.Characters.Count > 0 ? game.CurrentPlayingState.Characters : new List <Character>(); }
//██████████████████████████████████████ public override void _Ready() { camera = GetNode <Camera2D>("Camera2D"); camera.MakeCurrent(); camera.Zoom = Vector2.One * maxZoom;//max zoom = maxZoom; //observacion para cambion de resolucion GetTree().Connect("screen_resized", this, "screenChange"); screenChange(); //limite camera default mapResised(100, null, null); //joy connections GD.Print("JOYs: "); foreach (var joy in Input.GetConnectedJoypads()) { GD.Print("-" + joy.ToString()); } }
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)); }
public MainMenuController() { MainMenuTexture = Global.Content.Load <Texture2D>("GFX/MainMenuTest"); Items = new List <MainMenuItem>(); SelectedItem = 0; InputTimer = 0.25f; InputManager.UpPressed += OnUpPressed; InputManager.DownPressed += OnDownPressed; InputManager.VerticalReleased += OnVerticalReleased; GameViewport = new BoxingViewportAdapter(Global.Window, Global.Graphics, 512, 288, 74, 70); GameCamera = new Camera2D(GameViewport); GameCamera.Origin = new Vector2(0, 0); GameCamera.Position = new Vector2(0, 0); Initialize(); LastItem = Items.Count - 1; }
public override void Draw(Camera2D camera) { if (Visible) { camera.End(); camera.GraphicsDevice.Textures[1] = m_alphaMaskRT; camera.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp; camera.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, Game.MaskEffect); if (!DrawNothing) { camera.Draw(m_mapScreenRT, Vector2.Zero, Color.White); } camera.End(); camera.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null); if (DrawNothing) { m_playerSprite.Draw(camera); } } }
public override void UnloadContent() { base.UnloadContent(); camera = null; frameCounter = null; font = null; tilemapTexture = null; level = null; pixel = null; backgroundWaterGradientStrip = null; energyBar = null; healthBar = null; player = null; spikesPointingDown = null; spikesPointingUp = null; spikesPointingLeft = null; spikesPointingRight = null; enemies = null; SFX = null; }
public override void OnMouseClick(Map map, Layer layer, Camera2D camera, Vector2 position, string selectedTileName) { bool add = true; foreach (Light2D light in MainForm.MapPanel.Krpyton.Lights) { var mouse = (new Vector2(camera.Position.X, camera.Position.Y) + position).ToPoint(); for (int i = 0; i < MainForm.MapPanel._lightSymbolPixelData.Length; i++) { int x = i % MainForm.MapPanel._lightSymbolTexture.Width; int y = i / MainForm.MapPanel._lightSymbolTexture.Width; // System.Windows.Forms.MessageBox.Show(mouse.ToString() + " , " + x + (int)light.Position.X + " " + y + (int)light.Position.Y); if (new Rectangle(x + (int)light.Position.X, y + (int)light.Position.Y, 16, 16).Contains(mouse)) { add = false; ((MainForm)MainForm.ActiveForm).OpenProperties(light); MainForm.MapPanel.SelectedLight = light; } } } if (add) { var light = new Light2D() { Position = new Vector2(camera.Position.X + position.X, camera.Position.Y + position.Y), Color = Color.White, Texture = MapPanel.LightTexture, Range = 100, IsOn = true, Intensity = 1.5f, ShadowType = ShadowType.Occluded }; MainForm.MapPanel.Krpyton.Lights.Add(light); ((MainForm)MainForm.ActiveForm).OpenProperties(light); MainForm.MapPanel.SelectedLight = light; } }
public override void Initialise(ContentManager Content) { _camera = new Camera2D(_gameClient); _camera.Initialize(); _content = Content; _pingLabel = new Label() { Font = GameClient.DEFAULT_FONT, FrontColor = Color.Black, Location = new Point(0, 0), Text = "0 ms", }; _txtIn = new TextBox() { FrontColor = Color.Black, BackColor = Color.White, BorderColor = Color.Black, Font = GameClient.DEFAULT_FONT, NumbersAllowed = true, SpecialCharactersAllowed = true, IsVisible = true, SpacesAllowed = true, CharacterLimit = 300, Name = "txtIn", Location = new Point(10, GameClient.HEIGHT - (int)GameClient.DEFAULT_FONT.MeasureString(" ").Y - 5), Size = new Point(300, (int)GameClient.DEFAULT_FONT.MeasureString(" ").Y) }; for (int i = 0; i < 10; i++) { _lblMessages.Add(new Label() { Font = GameClient.DEFAULT_FONT_BOLD, FrontColor = Color.Black, IsVisible = true, Location = new Point(10, GameClient.HEIGHT - ((i + 1) * (int)GameClient.DEFAULT_FONT.MeasureString("test").Y) - _txtIn.Destination.Height - 5) }); } }
public Level(int levelNumber, InventoryManager im) : base(false) { LevelData data = DataLoader.LoadLevel(levelNumber); _levelBounds = new Rectangle(0, 0, data.Width, data.Height); _player = new Spaceman(data.PlayerStartLocation); _blackHole = data.BlackHole; _waves = new Wave[data.TrickleWaveData.Length + data.BurstWaveData.Length]; _camera = new Camera2D(_player.Position, _levelBounds.Width, _levelBounds.Height); //construct waves for (int i = 0; i < data.TrickleWaveData.Length; i++) { _waves[i] = new Wave(data.TrickleWaveData[i], true, _levelBounds); } for (int i = 0; i < data.BurstWaveData.Length; i++) { _waves[i + data.TrickleWaveData.Length] = new Wave(data.BurstWaveData[i], false, _levelBounds); } //Test code to set weapons 1-6 to created weapons im.setPrimaryWeapon(new ProjectileWeapon("Flamethrower", _player)); im.setSecondaryWeapon(new ProjectileWeapon("FreezeRay", _player)); im.setPrimaryGadget(new Gadget("Teleporter", this)); //Set Weapon holders in level _primaryWeapon = im.getPrimaryWeapon(); _secondaryWeapon = im.getSecondaryWeapon(); _unicorns = new Unicorn[data.Unicorns.Length]; for (int j = 0; j < data.Unicorns.Length; j++) { _unicorns[j] = new Unicorn(data.Unicorns[j]); } _foodCarts = data.FoodCarts; _primaryGadget = im.getPrimaryGadget(); userInterface = new GUI(_player, _blackHole); }
/// <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() { _frameCounter = new FramesPerSecondCounter(); GSM = new GameStateManager(); socket = new Sockets(); viewport = new ScalingViewportAdapter(graphics.GraphicsDevice, 800, 480); camera = new Camera2D(viewport) { MinimumZoom = 0.1f, MaximumZoom = 2.0f, Zoom = 1.0f, Origin = new Vector2(400, 240), Position = new Vector2(408, 270) }; Window.AllowUserResizing = true; GSM.PushState(new GameState(GSM, camera)); while (true) { if (socket.message == null) { continue; } else { PlayerPosition = new Vector2((int)socket.message["X"] * 32, (int)socket.message["Y"] * 32); camera.LookAt(PlayerPosition); Sockets.token = (string)socket.message["Token"]; break; } } base.Initialize(); }
public BunnyHopGame() { config = new Config(); database = new InMemoryDatabase(); ConfigLocator.Provide(config); ContentLocator.Provide(Content); InMemoryDatabaseLocator.Provide(database); graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = ConfigLocator.Config.VirtualWidth * ConfigLocator.Config.Scale; graphics.PreferredBackBufferHeight = ConfigLocator.Config.VirtualHeight * ConfigLocator.Config.Scale; graphics.PreferMultiSampling = false; graphics.ApplyChanges(); GraphicsLocator.Provide(graphics); var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, ConfigLocator.Config.VirtualWidth, ConfigLocator.Config.VirtualHeight); camera = new Camera2D(viewportAdapter); CameraLocator.Provide(camera); soundEffects = new List <SoundEffect>(); SoundLocator.Provide(soundEffects); Content.RootDirectory = "Content"; stateStack = new Stack <State>(); stateStack.Push(new SplashState()); //https://docs.microsoft.com/pt-br/dotnet/api/system.globalization.cultureinfo.currentculture?view=netcore-3.1 //CultureInfo culture = new CultureInfo("ko-KR", false); // us-EN ko-KR ja-JP //Thread.CurrentThread.CurrentCulture = culture; //Thread.CurrentThread.CurrentUICulture = culture; //Resources.Culture = CultureInfo.CurrentCulture; //Debug.Print(CultureInfo.CurrentCulture.Name); //Debug.Print(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); //Debug.Print(Resources.Culture.Name); }
public override void OnMouseMove(Map map, GameData.Layer layer, Camera2D camera, Microsoft.Xna.Framework.Vector2 position, string selectedTileName) { if (_lastX != -1 && _lastY != -1) { var direction = Vector3.Zero; direction.X = position.X - _lastX; direction.Y = position.Y - _lastY; var delta = camera.Position - direction; if (delta.X > 0 && delta.Y > 0) { camera.Position = delta; } } _lastX = position.X; _lastY = position.Y; base.OnMouseMove(map, layer, camera, position, selectedTileName); }
public static IEnumerable <Vertice2> ObterVetoresObjeto2DPelaTela(this Camera2D camera, List <Objeto2D> objs, RectangleF rect) { #warning Inserir novo sistema que considera angulo e zoom da camera for (int o = 0; o < objs.Count; o++) { Objeto2D obj = objs[o]; for (int i = 1; i < obj.Vertices.Count() + 1; i++) { Vertice2 v1, v2; if (i == obj.Vertices.Count()) { v1 = obj.Vertices[i - 1]; v2 = obj.Vertices[0]; } else { v1 = obj.Vertices[i - 1]; v2 = obj.Vertices[i]; } float x1Tela = -(camera.Pos.X - camera.ResWidth / 2) + obj.Pos.X + v1.X; float y1Tela = -(camera.Pos.Y - camera.ResHeight / 2) + obj.Pos.Y + v1.Y; float x2Tela = -(camera.Pos.X - camera.ResWidth / 2) + obj.Pos.X + v2.X; float y2Tela = -(camera.Pos.Y - camera.ResHeight / 2) + obj.Pos.Y + v2.Y; // Testa se o vetor está colidindo com a região do retângulo if (Util2D.IntersecaoRetaRetangulo(new Vetor2(x1Tela, y1Tela), new Vetor2(x2Tela, y2Tela), rect)) { yield return(v1); yield return(v2); } i++; // Próximo vetor } } }
public override void Draw(Camera2D camera) { if (!IsKilled) { foreach (var current in m_chainLinksList) { m_chain.Position = current; m_chain.Draw(camera); } BallAndChain.Draw(camera); if (Difficulty > GameTypes.EnemyDifficulty.BASIC) { foreach (var current2 in m_chainLinks2List) { m_chain.Position = current2; m_chain.Draw(camera); } BallAndChain2.Draw(camera); } } base.Draw(camera); }
public void ResetOnPlayerDeathPreset(Camera2D camera, Random rng, int worldLeftEndWidth, int worldRightEndWidth, GameTime gameTime, PlatformManager platformManager) { player.Health = 100; player.HealthMax = player.Health; player.Stamina = 100; player.StaminaMax = player.Stamina; camera.Zoom = 1.0f; player.IsDead = false; player.X = 175; player.Y = 175; player.HealthRegen = 2; player.StaminaRegen = 1; player.Damage = 10; isCrouching = false; EnemyManager.Enemies.Clear(); enemyManager.FillEnemyList(rng, presetWaves[0].NumberOfMelee, presetWaves[0].Difficulty, gameTime, PlatformVersion.Easy); enemyManager.FillRangedList(rng, presetWaves[0].NumberOfRanged, presetWaves[0].Difficulty, gameTime, PlatformVersion.Easy); platformManager.ClearPlatformLists(); platformManager.MakePlatforms(PlatformVersion.Easy, graphicsDevice, textureManager); player.UgManager.ResetUpgrades(); }
private void InitializeLevel() { if (SceneManager.GetActiveScene().name != "Main Menu") { _pauseCanvas = GameObject.FindGameObjectWithTag("Pause"); _gameOverCanvas = GameObject.FindGameObjectWithTag("Game Over"); _spawnPoints = GameObject.FindGameObjectsWithTag("Spawn Point").ToList(); _player1Label = GameObject.FindWithTag("Player1Label").GetComponent <TextMeshProUGUI>(); _player2Label = GameObject.FindWithTag("Player2Label").GetComponent <TextMeshProUGUI>(); _camera = FindObjectOfType <Camera2D>(); _eventSystem = FindObjectOfType <EventSystem>(); _inputModule = FindObjectOfType <StandaloneInputModule>(); _gameOverCanvas.SetActive(false); PlayerList.Clear(); TogglePause(); for (int i = 0; i < 2; i++) { PlayerList.Add(Instantiate(_playerPrefabsList[i], _spawnPoints[i].transform.position, Quaternion.identity).GetComponent <Player>()); PlayerList[i].MovementData = _movementDataList[i]; PlayerList[i].InputSettings = _inputSettingsList[i]; PlayerList[i].PlayerStats = _playerStatsList[i]; PlayerList[i].PlayerStatsHud.ChiBar = Instantiate(_chiBarPrefab, GameObject.Find("P" + (i + 1)).transform, false).GetComponent <Slider>(); PlayerList[i].PlayerStatsHud.HealthBar = Instantiate(_healthBarPrefab, GameObject.Find("P" + (i + 1)).transform, false).GetComponent <Slider>(); } PlayerList[1].PlayerTargetting.EnemyPlayerStats = PlayerList[0].PlayerVitals; PlayerList[0].PlayerTargetting.EnemyPlayerStats = PlayerList[1].PlayerVitals; PlayerList[0].PlayerTargetting.EnemyTransform = PlayerList[1].transform; PlayerList[1].PlayerTargetting.EnemyTransform = PlayerList[0].transform; _camera.Targets.Add(PlayerList[0].transform); _camera.Targets.Add(PlayerList[1].transform); PlayerList[0].PlayerStats.Reset(); PlayerList[1].PlayerStats.Reset(); } }
public WoodBlock( World world, ScreenManager screenManager, Vector2 position, Camera2D camera, string texturePath, TriangulationAlgorithm triangulationAlgorithm, Vector2 scale, float strength, float massKoef) : base( world, screenManager, position, camera, texturePath, triangulationAlgorithm, scale, strength, massKoef) { }
void IHandler <Start> .Handle(FrameArgs frame, Start e) { _cam = new Camera2D(e.Size, 100f); _atlas = new Atlas("mario.atlas"); _batch = new Batch(); _sprites = new Sprite[] { _atlas["mushroom"], _atlas["fire-flower"], _atlas["star"], _atlas["red-shell"], _atlas["green-shell"], _atlas["goomba"] }; _background = _atlas["background"]; _solidColor = new SpriteMaterial(new SolidColorShader(), null); _solidColor.Color = new Vector4(0f, 0f, 0f, 0.65f); _boardBackground = new Quad(_solidColor, Vector4.Zero, Vector4.One); for (var c = '0'; c <= '9'; c++) { _numbers.Add(c, _atlas[c.ToString()]); } _poof = new SpriteSequence(7, false, _atlas["smoke-1"], _atlas["smoke-2"], _atlas["smoke-3"], _atlas["smoke-4"]); this.Add(_poof); _sfx = new SoundChannel(); _sfx2 = new SoundChannel(); _sndNoMatch = new SoundEffect("no-match.opus"); _sndMatch = new SoundEffect("match.opus"); _sndLanding = new SoundEffect("landing.opus"); _sndCoin = new SoundEffect("coin.opus"); _sndOneUp = new SoundEffect("1-up.opus"); _music = new StreamingSoundChannel(); _musicFile = new StreamingOpusFile("mario.opus"); _musicGameOver = new StreamingOpusFile("game-over.opus"); }
public virtual void Draw(Camera2D camera) { var activeState = _activeState as IDrawableGameState;//I know, you're nauseous, please don't be mad. It'll be ok. No one will ever notice. Our little secret. I promise. xoxo if (activeState != null) { activeState.StateWillDraw(activeState.Camera); foreach (var drawable in activeState.DrawList) { drawable.Draw(activeState.Camera); } _nextWebView.Draw(camera); _globalGameWebLayer.Draw(camera); activeState.StateDidDraw(activeState.Camera); _textDrawingService.Draw(); } }
protected override void LoadContent() { IsMouseVisible = false; _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(_viewportAdapter); _spriteBatch = new SpriteBatch(GraphicsDevice); _backgroundTexture = Content.Load <Texture2D>("Textures/colored_castle"); var titleScreen = GuiScreen.FromFile(Content, @"Content/title-screen.json"); var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, _camera.GetViewMatrix); _guiSystem = new GuiSystem(_viewportAdapter, guiRenderer) { Screens = { titleScreen } }; var quitButton = titleScreen.FindControl <GuiButton>("QuitButton"); quitButton.Clicked += (sender, args) => _game.Back(); }
public override void _EnterTree() { Camera2D camera = GetNode <Camera2D>("Player/Camera2D"); CurrentCamera.Init(camera); root = this; WorldScreenSizeX = GetViewport().Size.x *CurrentCamera.GetXZoom(); if (!load) { TileMap back = GetNode("Tilemaps").GetNode <TileMap>("0"); TileMap ground = GetNode("Tilemaps").GetNode <TileMap>("1"); TileMap uiground = GetNode("Tilemaps").GetNode <TileMap>("3"); TileMap uiground2 = GetNode("Tilemaps").GetNode <TileMap>("2"); Building.Init(this); Loot.Init(this); Tree.Init(this); BuildingInterface.Init(GetNode("CanvasLayer")); Liquid.Init(); World.Init(ground, uiground, uiground2, back); Structure.Init(); SpaceShip.Init(); PlayerMouvements.initialPosition = World.spawn; InitialiseIverntories(); } else { TileMap back = GetNode("Tilemaps").GetNode <TileMap>("0"); TileMap ground = GetNode("Tilemaps").GetNode <TileMap>("1"); TileMap uiground = GetNode("Tilemaps").GetNode <TileMap>("3"); TileMap uiground2 = GetNode("Tilemaps").GetNode <TileMap>("2"); Loot.Init(this); Tree.Init(this); Building.Init(this); BuildingInterface.Init(GetNode("CanvasLayer")); World.Init(ground, uiground, uiground2, back, false); Save._Load(saveName); SpaceShip.Init(); } }
public override void Initialize() { // Should initialize some basic settings and stuff // Load settings files etc. // Set window icon and stuff can also be done with this. SettingManager.LoadSettings(); // Apply window size settings to window int windowWidth = int.Parse(SettingManager.GetSetting("window-width", "1440")); int windowHeight = int.Parse(SettingManager.GetSetting("window-height", "768")); Vector2 size = new Vector2(windowWidth, windowHeight); SetWindowSize(size, false); LogManager.AddEntry($"Creating LogiX window with width = {(int)size.X} and height = {(int)size.Y}"); // Create new camera that's focused on (0,0). // This should maybe be done somewhere else. But is good for testing atm. cam = new Camera2D(size / 2f, Vector2.Zero, 0f, 1f); _simulationOn = true; _makingIc = false; }
public void EndScene() { int windowWidth = Engine.Application.Window.ClientBounds.Width; int windowHeight = Engine.Application.Window.ClientBounds.Height; int desiredSourceWidth = 1920; int desiredSourceHeight = 1080; Camera2D cam = new Camera2D(Vector2.Zero, windowWidth, windowHeight); CurrentCamera = cam; m_device.SetRenderTarget(null); Device.Clear(Color.Black); float ratio = Math.Min((float)windowWidth / desiredSourceWidth, (float)windowHeight / desiredSourceHeight); m_mainBufferSprite.Scale = new Vector2(ratio, ratio); m_spriteBatch.Begin(); Draw(m_mainBufferSprite, Vector2.Zero); m_spriteBatch.End(); }
public override void LoadContent() { base.LoadContent(); //We enable diagnostics to show get values for our performance counters. //Settings.EnableDiagnostics = true; if (World == null) { World = new World(Vector2.Zero); } else { World.Clear(); } if (DebugView == null) { DebugView = new DebugViewXNA(World); // DebugView.RemoveFlags(DebugViewFlags.Shape); // DebugView.RemoveFlags(DebugViewFlags.Joint); DebugView.DefaultShapeColor = Color.White; DebugView.SleepingShapeColor = Color.LightGray; DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.Game.Content); } if (Camera == null) { Camera = new Camera2D(ScreenManager.GraphicsDevice); } else { Camera.ResetCamera(); } // Loading may take a while... so prevent the game from "catching up" once we finished loading ScreenManager.Game.ResetElapsedTime(); }
//After the objects have all moved, clamp the object to the screen void LateUpdate() { switch (m_AxisToClamp) { case Axis.X: transform.position = new Vector3(Camera2D.ClampToCameraView(gameCamera, m_Renderer.bounds).x, transform.position.y, transform.position.z); break; case Axis.Y: #if GAMEEYE2D_XZ transform.position = new Vector3(transform.position.x, transform.position.y, Camera2D.ClampToCameraView(gameCamera, m_Renderer.bounds).z); #else transform.position = new Vector3(transform.position.x, Camera2D.ClampToCameraView(gameCamera, m_Renderer.bounds).y, transform.position.z); #endif break; //In any other state (including XY or an error), clamp both X and Y axis. default: transform.position = Camera2D.ClampToCameraView(gameCamera, m_Renderer.bounds); break; } }