// remove the specified brick from this level's collection public void DeleteBrick(Brick brick) { if (Bricks.Contains(brick)) { Bricks.Remove(brick); Changed = true; } }
// need to repaint when the mouse moves so that we // can draw the ghosted brick private void BrickBreakerEditorControl_MouseMove( object sender, MouseEventArgs e) { // if we're actually editing a level if (LevelData != null) { // see if mouse is over an existing brick // brick data is zero-based, so we subtract the top, left // of the playable area to translate to a 0,0 origin m_ClickedBrick = LevelData.FindBrick( e.X - m_GameRect.Left, e.Y - m_GameRect.Top); // apply grid settings and bounds checking CalcNewBrickXY(e.Location); } }
// add a new brick to the level, given the coordinate // of the a top, left corner, knowing the width and // height of all bricks on this level public Brick AddBrick(int x, int y, int hits) { Brick brick = null; if (x >= 0 && y >= 0) { brick = new Brick(); brick.X = x; brick.Y = y; brick.HitsToClear = hits; Bricks.Add(brick); Changed = true; } return brick; }