// Token: 0x0600001A RID: 26 RVA: 0x000026D8 File Offset: 0x000008D8 private void AddSpriteToGame(GenericSprite sprite) { if (!sprite.IsVisible) { GameScene.add(sprite); } }
public void RenderBitmap_UsingSprite_ShouldFillColors() { // Arrange var colorMap = new Color[7, 7]; var frame = Color.White.ToBitmap(new[, ] { { true, true, false }, { false, true, false }, { false, true, true } }); var sprite = new GenericSprite(new Offset(4, 2), frame); var expected = Color.White.ToBitmap(new[, ] { { false, false, false, false, false, false, false }, { false, false, false, false, false, false, false }, { false, false, false, false, true, true, false }, { false, false, false, false, false, true, false }, { false, false, false, false, false, true, true }, { false, false, false, false, false, false, false }, { false, false, false, false, false, false, false } }); // Act ColorExtentions.RenderBitmap(colorMap, sprite); // Arrange Assert.Equal(expected, colorMap); }
public void Overlap_OnTwoSprites_ShouldReturnTrue() { // Arrange var colorsOne = Color.Red.ToBitmap(new[, ] { { true, true, true, true }, { true, false, false, false }, { true, false, false, false }, { true, false, false, false } }); var colorTwo = Color.White.ToBitmap(new[, ] { { false, true, false }, { true, true, true }, { false, true, false } }); ISprite left = new GenericSprite(new Offset(3, 2), colorsOne); ISprite right = new GenericSprite(new Offset(1, 4), colorTwo); AxisAlignedBoundingBoxOverlapCheck collisionDetection = new AxisAlignedBoundingBoxOverlapCheck(); // Act bool overlaps = collisionDetection.Overlap(left, right); // Assert Assert.True(overlaps); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); Services.AddService(typeof(SpriteBatch), _spriteBatch); _sprite1 = new GenericSprite(this, "akira1", new Vector2(500, 400)); _sprite1.AddTriangleOffsets(new Vector2(40, 10), new Vector2(3, 40)); _sprite2 = new GenericSprite(this, "akira2", new Vector2(300, 300)); _sprite2.AddTriangleOffsets(new Vector2(40, 10), new Vector2(3, 40)); _movableSprite = new GenericSprite(this, "Inimigo1", new Vector2(400, 300)); _movableSprite.AddTriangleOffsets(new Vector2(40, 10), new Vector2(3, 40)); _movableSprite.IsMovable = true; _messageSprite = new MessageSprite(this, "================== COLISÃO DETECTADA =================="); _messageSprite.Visible = false; Primitives2D.dotTexture = Content.Load <Texture2D>("Dot"); // DeteccaoColisao2D.AdditionalRenderTargetForCollision = new RenderTarget2D(_graphics.GraphicsDevice, _graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight, 1, _graphics.GraphicsDevice.DisplayMode.Format); Components.Add(_sprite1); Components.Add(_sprite2); Components.Add(_movableSprite); Components.Add(_messageSprite); }
/// <summary> /// Checks if the barrel is colliding with only the top part of a sprite /// </summary> /// <param name="sprite">A sprite object with an hitbox</param> protected bool IsTouchingTop(GenericSprite sprite) { return(this.hitbox.Bottom + this.Velocity.Y > sprite.hitbox.Top && this.hitbox.Top < sprite.hitbox.Top && this.hitbox.Right > sprite.hitbox.Left && this.hitbox.Left < sprite.hitbox.Right); }
/// <summary> /// Updates the visual mario lives in the upper left corner /// </summary> private void LivesLeftDisplay() { for (int i = 0; i < _livesLeft; i++) { GenericSprite lifeSprite = new GenericSprite(_game); lifeSprite.LoadContent("Graphics/marioLife"); lifeSprite._position = new Vector2(stackedBarrels._position.X + lifeSprite._texture.Width * i, 0); allLives.Add(lifeSprite); } }
public HomeMenu(Game1 game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content) { DKTitle = new GenericSprite(_game); playButton = new MenuButton(_game); infoButton = new MenuButton(_game); exitButton = new MenuButton(_game); LoadContent(); Initialize(); }
public void CopyData(GenericSprite Key, Sprite Value) { var source = Key; Value.image = source.image; Value.text = source.text; Value.size = source.size; Value.color = new Color(source.color.r, source.color.g, source.color.b); Value.flip = source.flip; Value.position = new Vector(source.position.x, source.position.y); Value.angle = source.angle; }
/// <param name="game">The game variable</param> /// <param name="graphicsDevice">Information about the screen used to display the game</param> /// <param name="content"></param> /// <param name="livesLeft">How many lives does mario have left</param> /// <param name="gameDuration">How long has the game been going</param> public DonkeyKong(Game1 game, GraphicsDevice graphicsDevice, ContentManager content, int livesLeft = 3, float gameDuration = 0f) : base(game, graphicsDevice, content) { //Initialize the game's variables at the start of the game _livesLeft = livesLeft; _gameTimer = new GameTimer(game, gameDuration); _gameTimer.Started = true; brick = new Brick(_game); stackedBarrels = new GenericSprite(_game); gameWon = false; gameOver = false; scoreSaved = false; _scoreManager = ScoreManager.Load(); LoadContent(); Initialize(); }
public InfoPage(Game1 game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content) { DKTitle = new GenericSprite(_game); joystickRightLeft = new GenericSprite(_game); marioWalking = new GenericSprite(_game); joystickUpDown = new GenericSprite(_game); marioClimbing = new GenericSprite(_game); arcadeButtons = new GenericSprite(_game); marioJumping = new GenericSprite(_game); goBackButton = new MenuButton(_game); LoadContent(); Initialize(); }
public void remove(GenericSprite sprite) { GameScene.remove(sprite); }