Post: How To Create A Game in 1 day and a half.
02-17-2012, 02:56 AM #1
KingcreekS
NOTHING IS IMPOSSIBL
(adsbygoogle = window.adsbygoogle || []).push({}); Ok NGU, Today I will teach you how to make a game like the one I've made:
[ATTACH=CONFIG]15525[/ATTACH]

Foreword to Same Game

In this five part series, I'll be creating a version of a game called SameGame using the Microsoft Foundation Class library from start to finish. I'll include features beyond the simple removing of blocks in the game. I'll implement an undo/redo subsystem and some user configuration dialogs. I'll show you step by step with not only source code but screenshots how to build a fun game from start to finish and how to use Microsoft's MFC classes. Every article comes with complete source code, so you can build and run the game yourself.

The rules to the SameGame are quite simple, you try to remove all of the colored blocks from the playing field. In order to remove a block the player must click on any block that is next to, vertically or horizontally, another with the same color. When this happens all of the blocks of that color that are adjacent to the clicked block are removed. All of the blocks above the ones removed then fall down to take their place. When an entire column is removed, all columns to the right are shifted to the left to fill that space. The blocks aren't shifted individually but as a column. The game is over when there are no more valid moves remaining. The goal is to end with an empty board in as little time as possible. Some versions of the SameGame use a scoring algorithm that can be implemented as an additional exercise for the user.

Prerequisites

You'll need to have a basic C++ knowledge of functions, recursion, classes, and inheritance. The code was written using Visual Studio 2005 on Windows XP although later versions of Visual Studio should be fine although the screenshots will look slightly different from what you will see. You must use the Standard or Professional edition of Visual Studio; Visual Studio Express cannot be used, because it does not come with MFC.

First and foremost, you'll learn some basics of how to create your own game. You'll learn about the Microsoft Foundation Class library and some basic usage and the Document/View architecture paradigm.

Here's an outline of the series, with links to each article:

You must login or register to view this content. Creating a real, playable game.
You must login or register to view this content. Adding difficulty levels and other menu options.
You must login or register to view this content.Changing the game board size and the block count.
You must login or register to view this content.Adding undo/redo functionality and keyboard accelerators.

Why MFC?

MFC is an easy-to-use library, especially for a simple game like the one we want to make. It will make it easy to create an application with a true Windows look-and-feel.

Starting the Same Game Project

In this article I'll be using Visual Studio 2005 to create our game. The following instructions can easily be adapted to all other versions of Visual Studio. First start up Visual Studio and create a new project. The type of project is "Visual C++" -> "MFC" -> "MFC Application".

[ATTACH=CONFIG]15526[/ATTACH]

Next the MFC application wizard will appear. If you do not choose the name SameGame, then the names of your classes will be slightly different than those that appear in this article. This allows you to select quite a few options that the resulting generated code will include. For our simple game we can disable quite a few of these options. The following graphics show which options to select in order to get the project just the way we want it.

[ATTACH=CONFIG]15527[/ATTACH]

Selecting "Single document" allows the application to use the document/view architecture when multiple documents aren't necessary. The last setting of interest on this page is "Use of MFC". The two options are for a shared DLL or as a static library. Using a DLL means that your users must have the MFC DLLs installed on their computer, which most computers do. The static library option links the MFC library right into your application. The executable that is produced will be larger in size but will work on any Windows machine.

Advance through the next three pages, taking the defaults until the following page is displayed.

[ATTACH=CONFIG]15528[/ATTACH]

(If you are using Visual 2010, this screen does not have a "None" option for Toolbars. Just choose "Use a Classic Menu" without checking either toolbar.) A thick frame allows the user to resize the window. Since our game is a static size, un-check this option. A maximize box isn't needed, nor is a status bar or a toolbar. Advancing to the next page will bring you to the "Advanced Features" page.

[ATTACH=CONFIG]15529[/ATTACH]

Turn off printing, ActiveX controls and set the number of recent files to zero. Since we won't actually be loading any files, this option won't be necessary. The last page of the MFC Application Wizard presents you with a list of generated classes.

Four classes that will be generated for you are the basis for the game. The first on the list is the view class, here it is called CSameGameView. I will come back to this class in a minute. The next class in the list is the application class. This class is a wrapper for the entire application and a main function is provided for your application by this class. The base class isn't selectable and must be CWinApp.

The next class in the list is the document class, CSameGameDoc based on the CDocument class. The document class is where all of the application data is stored. Again the base class cannot be changed.

The last class is the CMainFrame class. This CFrameWnd based class is the wrapper class for the actual window. The main frame class contains the menu and the client area view. The client area is where the actual game will be drawn.

Now back to the view class. The base class is a dropdown with a list of views that are generally available, each with its own use and application. The default view type is CView, which is a generic view where all of the display and interaction with the user must be done manually. This is the one that we want to select.

I will quickly go down the list and explain what each view type is used for, just for your information. The CEditView is a generic view which consists of a simple text box. The CFormView allows the developer to insert other common controls into it, i.e. edit boxes, combo boxes, buttons, etc. The CHtmlEditView has an HTML editor built into the view. The CHtmlView embeds the Internet Explorer browser control into the view. The CListView has an area similar to an Explorer window with lists and icons. The CRichEditView is similar to WordPad; it allows text entry but also text formatting, colors and stuff like that. A CScrollView is a generic view similar to CView but allows scrolling. Finally the CTreeView embeds a tree control into the view.

Finishing the MFC Application Wizard will produce a running MFC application. Since we haven't written any code yet it is a very generic window with nothing in it, but it is a fully functioning application all the same. Below is a screenshot of what your generic application ought to look like. To build your application, you can go to the Debug menu, and select Start without Debugging. Visual Studio may prompt you to rebuild the project—select "Yes".

OK NOW GO TO THE LINK AT THE TOP THE SECOND PART THEN THE 2,3,4 AND 5 PARTS.
I HOPE YOU ENJOY IT,
VerifyerModderz.
Last edited by KingcreekS ; 02-17-2012 at 03:18 AM.

The following 4 users say thank you to KingcreekS for this useful post:

MOHN, NeedaLifeSoon, ShinigamiUzi

The following 3 users groaned at KingcreekS for this awful post:

|C++|, Docko412, Epic?
02-17-2012, 11:52 AM #2
KingcreekS
NOTHING IS IMPOSSIBL
You cando it in only 1 day but i do itin a day and a half.
02-17-2012, 11:56 AM #3
ShinigamiUzi
Proud to be a Player
Can u do MW3 :carling:

The following user thanked ShinigamiUzi for this useful post:

xd366
02-17-2012, 06:24 PM #4
Dudevid
Do a barrel roll!
In all seriousness, following a simple tutorial one could put together a Unity game in a day and half. Sure, there's bucketloads left to learn thereafter, but it's far simpler to work with than most engines and stuff built with it can actually be sold on the App Store, Mac App Store, Android Market, and standalone over the web or through services like Steam.

EDIT: I should probably add that I appreciate the tutorial nonetheless. It's clear you've put a lot of work into it and I'm sure it will be helpful to many people.
02-17-2012, 10:02 PM #5
KingcreekS
NOTHING IS IMPOSSIBL
yea thankz you i put a lot of time into it and noone is looking it :(
02-18-2012, 12:03 AM #6
|C++|
< ^ > < ^ >
i dont like this at all it breaks the law of any real game anyone would want to make.

The following user thanked |C++| for this useful post:

Docko412
02-19-2012, 10:40 PM #7
caleb01
Little One
I thought this was a good post....would you mind checking this question I have in the ps3 section. Its 2 questions that I kind of want answered.

You must login or register to view this content.

-Its about game development-

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo