Game Development Reference
In-Depth Information
Testing our game window
It isnowtime for usto test ourgamewindow! Wewill addasecond project to oursolu-
tion. With the SlimFramework solution still open, open the FILE menu, and select
New Project... . Name the new project, for example, Ch01 . Make sure you change the
selected project type to Windows Forms Application . Also, it is very important that
you make sure that the Solution drop-down list at the bottom of the window is set to
Add to solution or Visual Studio will create a new solution instead of adding this pro-
ject to our existing solution. If this option is not present, then it will add the new project
to this solution.
Click on OK and the new project will be created and added to our solution. Right-click
on it in the Solution Explorer pane and choose Set as StartUp Project . By doing
this, we've told Visual Studio that this is the project we want to start up when we tell it
to run our code.
The SlimFramework project can't be the startup project since it is just a class library,
and therefore cannot execute on its own. This is because the Class Library pro-
ject type does not have the Main method, like a Console Application or Win-
dows Forms Application does. A Main Method is the first method that is called
when the program starts up. So it is essentially the starting point of the program. You
should also delete the Form1.cs file from this new project since we don't need it.
Now we need to add a reference to our project. Right-click on the References head-
ing for the Ch01 project in the Solution Explorer pane. Then click on Add Referen-
ce... . In the Reference Manager window, select the Projects category. Now check
the checkbox next to the SlimFramework project. Click on OK and Visual Studio will
add a reference to the SlimFramework project into the Ch01 project. We can now
use classes defined in the SlimFramework project in Ch01 .
Next, we need to add a couple of lines of code to the Main method in our new Ch01
project. Here is the code:
static void Main(string[] args)
{
Application.EnableVisualStyles();
Search WWH ::




Custom Search