void OnExploding() { Vector2 pos = Target; LevelBackgroundComp bg = Level.Current.Background; Vector2 pixPos; pixPos.X = pos.X + RandomMath.RandomBetween(-ExplosionRange, ExplosionRange); pixPos.Y = pos.Y + RandomMath.RandomBetween(-ExplosionRange, ExplosionRange); bg.SetPixel(pixPos, RandomMath.RandomColor()); }
public ThingComp(ThingType type, LevelBackgroundComp bgComp, Texture2D collisionTexture) { this.Type = type; this.bg = bgComp; this.boundingRectangle.Width = collisionTexture.Width; this.boundingRectangle.Height = collisionTexture.Height; // TODO needed to fetch text.data per entity? only for those that may change its shape/texture during play? textureData = new Color[collisionTexture.Width * collisionTexture.Height]; collisionTexture.GetData(textureData); }
protected override void InitLevel() { // select bitmap bg Background = new LevelBackgroundComp("Level1.png"); Background.ForegroundColor = LEVEL_FOREGROUND_COLOR; // FIXME Background.TargetSpeed = SCREEN_MOTION_SPEED; // bitmap for things/items to load // FIXME ItemsMap = new LevelItemLoader("Level1Items.png"); //ItemsMap.AddItems(this, ITEM_BLOCK_COLOR, typeof(Block)); }
void Explode() { Vector2 pos = Target; int posX = (int)Math.Round(pos.X); int posY = (int)Math.Round(pos.Y); LevelBackgroundComp bg = Level.Current.Background; Vector2 pixPos; for (int x = posX - ExplosionRange; x <= posX + ExplosionRange; x++) { for (int y = posY - ExplosionRange; y <= posY + ExplosionRange; y++) { pixPos.X = x; pixPos.Y = y; bg.SetPixel(pixPos, RandomMath.RandomColor()); } } }