Game Development Reference
In-Depth Information
Fig. 7.1
Adding a new class to a project
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Painter
{
class Cannon
{
}
}
Every class that is added to the project by default gets its own file. The name of
this file is the same as the name of the class that it contains. You may name the
files differently, and you may also put multiple classes below one and other in a
single file. However, your project becomes a lot messier if you do that, and it will
be much more difficult to find everything. Therefore, keep every class in a single
file, and name the file the same as the class. Visual Studio already puts the class in
a common project namespace, and there are a couple of using instructions that it
thinks might be of use. We will only need the first one ( using System; ) so leave that
one in, and remove the others. Also remove the namespace because we do not use it
in the Painter program.
As you can see, the Cannon class is completely empty. Even if a class does not
yet contain any member variables or methods, we can already use it by declaring a
Search WWH ::




Custom Search