There as nice article some time ago on this site for creating mastermind game by Mike Gold. I am rewriting complete game from scratch to implement Drag and Drop feature and presentable User interface. 
MasterMindGameLogic: I have Implemented Game logic in separate Class Board which handles all Game.
frmMasterMind.cs: Is a form containing user interface for mastermind game
I have used off-Screen drawing combined with opaque background by overriding OnPaintBackground method of form to Produce flicker free and smooth rendering of User interface.
For Dragging I have used combination of mouse down mouse Move and mouse up events.
For purpose of speeding up Drawing I have created all images in memory like pegs, Result pegs , peg hole and result hole so that I do not have to create this images during every screen refresh, other purpose of doing so was to allow in future to use Skin for such objects.
I have also used AntiAlias effect so show smooth edges wherever required however I will recommend caution while using that because it will reduce drawing speed considerably.
I have also tested this application on Compact framework beta1 pocket pc (after removing some parts like gradient peg, Inset circle, AntiAlias effects etc) it works in same manner except some thing messes up in menu (may be its bug of beta1)
Drawing Utility: I have written some useful methods for drawing various object of games like pegs, Hole on board raised string etc in this class.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Suchan KooprasitPosted May 7, 2010, 3:13 PM
Excuse me, sir I'm load opencode Mastermild game from http://www.c-sharpcorner.com/UploadFile/desaijm/MasterMindWithDragDrop11152005021555AM/MasterMindWithDragDrop.aspx?ArticleID=27644b65-b34c-4f64-8f1d-0bb36b52958c I wanna fix program for research tool help, but i'm basic C#.Net Language Program graphic. i'm medium Language ASP.Net C#. please to guide or recommend for fix **1. the show peg. yes, Answer agree Duplicate color. I'm wanna fix Answer not Duplicate color. but, i' not understand graphic C# code. So Please, Respect
Suchan KooprasitPosted Apr 22, 2010, 3:17 PM
Thank you.
julz barrabPosted Jun 7, 2007, 3:29 PM
In VS 2005 you get the error... " The call is ambiguous between the following methods or properties: 'System.Math.Floor(decimal)' and 'System.Math.Floor(double)" to fix change the error line of code to... r[i-1] = new Rectangle(p.X + border ,(int)(p.Y + border + Math.Floor(((decimal)i-1)/2)*boxWidth),boxWidth,boxWidth);