Posted on 2000-04-13
Last Modified: 2008-03-03
Can someone give me a simple code in C++/mfc what draws 6 different coloured
circles with 6 random numbers ranging from 1-49 written in them.

I am trying my hand on game progrmaming
and need this for a lottery game I am trying to write.

Question by:parkerx

Expert Comment

ID: 2714514
What is the problem that you are facing? You don't know which function to call?

Expert Comment

ID: 2721165
Newbie question!

I think you should buy yourself a C++ and MFC programming book and maybe a beginners book on programming and start reading. Games programming is not something that is learnt overnight.


Expert Comment

ID: 2744897
You really need to take some time and read about C++ or maybe programming basic like felonius said. you best bet is to go take some college courses on programming languages(if books aren't your thing). You may findout that C++ is not the language you need to use. C++ is one of the most difficult languages out there. But...when all-else-fails Remember these three words: conceptual, logical, physical (you can do the conceptual RIGHT NOW until you learn C++)and life in programming becomes alittle easier.... Good Luck!
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!


Accepted Solution

mikefulton earned 50 total points
ID: 2930261
I suspect the other comments are correct about you being a beginner, so the idea of finding a good book on programming is probably good advice.  However, I'll still try to give you a step or two in the right direction of your specific question.

Note that the listing below is not necessarily ALL of the code you would need, just the actual circle drawing part.  You still need to add the code that sets the desired screen position of each circle.

Also, this uses just the basic default font, which might also need changing.  But you can look into details like that after you have some results on screen.

This would go inside the "OnDraw" function for your document's "view" class.


CRect circlepos[6]; // should be set to desired circle positions
                    // This should be set globally, or else code
                    // should be added where the "..." goes below

int circlenum[6];   // Set to random numbers that will be printed in circles

int circle;         // Loop index for circles


// Create a separate brush for each circle
CBrush circlebrush[6];


for( circle = 0; circle < 6; circle++ )
      pDC->SelectObject( &circlebrush[circle] );

      // Get random number & cap it off at 49
      circlenum[circle] = rand() % 49;      

      // Draw circle
    pDC->Ellipse( &circlepos[circle] );

      // Get center point of circle & draw text
      // using default font
    int text_x = circlepos[circle].CenterPoint().x;
    int text_y = circlepos[circle].CenterPoint().y;
      pDC->TextOut( text_x, text_y, circlenum[circle] );

// Kill objects we just created

Author Comment

ID: 2930768
Answer accepted

Author Comment

ID: 2930772
Thanks Mike. I should be trying this
out today.

Best wishes


Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Are there Any RTS mpg sheets out there? 1 166
Python - how do I - array of IPAddresses? 3 373
Unity game development advices! 3 279
Unity 3D Lighting 1 86
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question