Solved

circles

Posted on 2000-04-13
6
495 Views
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.

Thanks.
0
Comment
Question by:parkerx
6 Comments
 
LVL 1

Expert Comment

by:sunj
Comment Utility
What is the problem that you are facing? You don't know which function to call?
0
 
LVL 1

Expert Comment

by:felonius
Comment Utility
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.

0
 

Expert Comment

by:bufordk
Comment Utility
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!
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Accepted Solution

by:
mikefulton earned 50 total points
Comment Utility
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];

circlebrush[0].CreateSolidBrush(RGB(255,0,0));
circlebrush[1].CreateSolidBrush(RGB(255,255,0));
circlebrush[2].CreateSolidBrush(RGB(0,255,0));
circlebrush[3].CreateSolidBrush(RGB(0,255,255));
circlebrush[4].CreateSolidBrush(RGB(0,0,255));
circlebrush[5].CreateSolidBrush(RGB(255,0,255));

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
circlebrush[0].DeleteObject();
circlebrush[1].DeleteObject();
circlebrush[2].DeleteObject();
circlebrush[3].DeleteObject();
circlebrush[4].DeleteObject();
circlebrush[5].DeleteObject();
0
 

Author Comment

by:parkerx
Comment Utility
Answer accepted
0
 

Author Comment

by:parkerx
Comment Utility
Thanks Mike. I should be trying this
out today.

Best wishes

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now