Showing posts with label Learn C sharp Gaming Chapter 7. Show all posts
Showing posts with label Learn C sharp Gaming Chapter 7. Show all posts

Wednesday, April 13, 2011

Learn C sharp Gaming Chapter 7


Basics of Structures and Classes
In the olden days of computer programming, programming languages were quite simple,
and you could create only a limited number of variables. This, obviously, made programs
very limited and quite ugly, to boot. For example, you would be creating programs like the
following in an older language:
int SpaceshipArmor;
int SpaceshipPower;
int SpaceshipFuel;
int EnemyArmor;
int EnemyPower;
int EnemyFuel;
As you can imagine, this gets to be a tangled mess rather quickly, and makes it very difficult
to manage your code.

Using classes and structures makes your life easier by encapsulating data into an easy-to
use packet of data.
Creating Classes and Structures
Basically, the idea behind classes and structures is to create your very own kind of object
using pieces of what was already in the language. A structure is essentially a data type that
can hold other pieces of data inside of it, allowing you to build your own types of data; it
is sort of like a building block. For example, here’s a structure describing a simple spaceship
object in C#:
struct Spaceship
{
public int fuel;
public int armor;
public int power;
}

note

AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...