Game Development Reference
In-Depth Information
BMI SORT8
;NO. GO THROUGH LIST AGAIN
RTS
;YES. LIST IS NOW ORDERED
And here
'
s a bubble sort in C:
void BubbleSort(int numbers[], int array_size)
{
int i, j, temp;
for (i = (array_size - 1); i > 0; i--)
{
for (j = 1; j <= i; j++)
{
if (numbers[j-1] > numbers[j])
{
temp = numbers[j-1];
numbers[j-1] = numbers[j];
numbers[j] = temp;
}
}
}
}
As you can see, assembly language is much more difficult to understand and parse
than C. As technology marched forward and processors became faster and more effi-
cient, it finally started to become feasible to write large parts of the game in C and
leave assembly language for the performance-intensive stuff. Using C allowed devel-
opers to save huge amounts of development time.
As processor speeds and compilers continued to improve, C was eventually replaced
by C++ in most game studios, although there is at least one studio I know of that still
uses straight C. C++ has the power of C with all the cool object-oriented bits added
on top. It
'
s a great language for performance because it still sits pretty close to the
hardware while offering relatively straightforward syntax. The semantics of many lan-
guages used today owe their roots to C and C++.
As great as C++ is, it still has many flaws and is really beginning to show its age. For
example, you have to deal with memory management yourself. Every new must have
a matching delete , which isn
t the case in many higher-level languages. This can be
a blessing or a curse, depending on the problem you
'
re trying to solve. I can write a
C++ program that only allocates memory once during the entire program. This
would be impossible in many scripting languages.
With even faster computers and more complex games, the time was right to start
looking into scripting languages.
'
 
Search WWH ::




Custom Search