( Index )
Month

Brief Information about the Sept '06 CSIG Meeting

Balloons

C++ Version 7 and Visual Studio 2005

Written by B. Arnold

CodeProject Snapshot

Welcome to the CSIG, a Special Interest Group of the ACGNJ. The subject for this month is a discussion about Windows Sound and Graphics using the latest Microsoft C++ compiler.

First, let me welcome everyone back from their Summer activities.

The subject for this month is a graphical game program that is programmed like the one on "Pick Up Sticks" presented January, 2003. (See code archive.) However, the code uses the latest C++ compiler in Microsoft's Visual Studio 2005 so there are many changes. The program may also be compiled using the free C++ Express compiler.

This game is suitable for small children ages 1 to 4 years. When the game starts, 35 colored balloons are presented on the screen. The target balloon has an X in the center. Pressing the space bar will explode the indicated balloon with a "pop" sound. When all the balloons are exploded, a smiley face appears with a different sound effect.

This is an exciting time for the C Language programming since Microsoft now has 4 different language compilers: C++, C++ Express, C-Sharp, and C-Sharp Express. These are all capable of creating Windows (tm) programs and the "Express" versions are free ! Additionally, Borland has just announced that it also has four new programs that are also available in free versions. These are Turbo C++, Turbo C-Sharp, Turbo Delphi and Turbo Delpi for .NET. You may also want to check with Intel and others for their generally free evaluation versions. Here a link with many compilers: http://www.willus.com/ccomp.shtml

Some Windows (tm) Compiler Companies

MICROSOFT
BORLAND
INTEL
BLOODSHED
GCC, the GNU Compiler Collection - GNU Project
Digital Mars C, C++ and D Compilers
Others

The beginning of the evening (starting at 7:30pm) will be a RANDOM ACCESS discussion. The main presentation will discuss the program.

Our download site has code and programs from most of our meetings. ( Source Code Files )

Sample Code - VC7

Sample Code
===========
// Paint the screen.   Paint the screen.   Paint the screen.
    private: System::Void Form1_OnPaint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e)
        {
            int topBalloon = -1;
            Rectangle windowRect = ClientRectangle;

            if (firstime)
            {
                Form1_InitBalloonArray(windowRect);
                firstime = false;
            }
            Graphics ^g = e->Graphics;

            for (int i = 0; i < MAXBALLOONS; i++)
            {
                if (pBaloonCenter[i]->X < 0) continue;

                SolidBrush^ balloonBrush = gcnew SolidBrush(*pBaloonColor[i]);
                g->FillEllipse(balloonBrush,
                    (*pBaloonCenter[i]).X - *pBalloonRadius[i],
                    (*pBaloonCenter[i]).Y - *pBalloonRadius[i],
                    2 * (*pBalloonRadius[i]),
                    2 * (*pBalloonRadius[i]));
                g->DrawEllipse(Pens::Black,
                    (*pBaloonCenter[i]).X - *pBalloonRadius[i],
                    (*pBaloonCenter[i]).Y - *pBalloonRadius[i],
                    2 * (*pBalloonRadius[i]),
                    2 * (*pBalloonRadius[i]));
                // ~balloonBrush();  or balloonBrush->Dispose();
                topBalloon = i;
            }

            if (-1 != topBalloon)       // Put a X in the center of the top balloon.
            {
                Pen ^ myBlackPen = gcnew Pen(Color::Black, 10);
                myBlackPen->StartCap = System::Drawing::Drawing2D::LineCap::Round;
                myBlackPen->EndCap = System::Drawing::Drawing2D::LineCap::Round;

                Pen ^ myWhitePen = gcnew Pen(Color::White, 5);
                myWhitePen->StartCap = System::Drawing::Drawing2D::LineCap::Round;
                myWhitePen->EndCap = System::Drawing::Drawing2D::LineCap::Round;

                g->DrawLine(myBlackPen,
                    (*pBaloonCenter[topBalloon]).X - 10, (*pBaloonCenter[topBalloon]).Y - 10,
                    (*pBaloonCenter[topBalloon]).X + 10, (*pBaloonCenter[topBalloon]).Y + 10);
                g->DrawLine(myBlackPen,
                    (*pBaloonCenter[topBalloon]).X - 10, (*pBaloonCenter[topBalloon]).Y + 10,
                    (*pBaloonCenter[topBalloon]).X + 10, (*pBaloonCenter[topBalloon]).Y - 10);
                g->DrawLine(myWhitePen,
                    (*pBaloonCenter[topBalloon]).X - 10, (*pBaloonCenter[topBalloon]).Y - 10,
                    (*pBaloonCenter[topBalloon]).X + 10, (*pBaloonCenter[topBalloon]).Y + 10);
                g->DrawLine(myWhitePen,
                    (*pBaloonCenter[topBalloon]).X - 10, (*pBaloonCenter[topBalloon]).Y + 10,
                    (*pBaloonCenter[topBalloon]).X + 10, (*pBaloonCenter[topBalloon]).Y - 10);
                //myBlackPen->Dispose();
                //myWhitePen->Dispose();
            }
        }

"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page