Seth Hopkinson's Borland C++ Page

PLEASE NOTE: This is our OLD web page (circa 1996). It is no longer maintained. Some of the information contained on this page may be outdated and/or no longer true. Anything that is "under construction" here, will never be finished. Any broken links will not be repaired.
To view our current web page, Click Here.




Seth Hopkinson's Borland C++ Page


The most commonly asked questions:

Where can I get Borland C++? -- You used to buy it in the stores. If you look around you might be able to find it, or other versions, for very cheap. Borland C++ version 5.x includes a version 4.52 CD in the box. "Turbo C" is the same as "Borland C", they changed the name around version 3.1 or so. (NOTE: Around the year 2000, Borland C++ was phased out and replaced by a product called Borland C++ Builder)

How to make a DOS program in BC45 -- Step by step instructions tell exactly how to make an MS DOS program in Borland C++ 4.x for Windows.

General Information -- Some general information all Borland C++ programmers should read, especially beginners.

What's the difference between C and C++?

What's exactly is Object Oriented Programming? -- No, its NOT creating a program using icons!!!

Should I learn C programming? -- Only if you are already experienced in programming. C/C++ is not a good language for beginners! Let me repeat that again: C/C++ IS NOT A GOOD PROGRAMMING LANGUAGE FOR BEGINNERS!!! If you are new to programming, I strongly suggest you learn another programming language first! Click for more info.

I can be EMailed at hopkins@smartlink.net but due to the tremendous volume of EMail I recieve, it may take awhile for me to send an answer. Comments are appreciated. Questions get on my nerves fast but I may answer it if I am in the mood --- But I won't even bother answering if the info can be found in Online Help or if your question is too vague and general ("How could I make a game like Sceptre of Shalimar?" is a good example. Way too vague. The answer would easily fill a book. Vague questions like this will be ignored).



* How to make a DOS program *

Some ask why I advocate DOS when this is the age of Windows. Well, here's why: Windows is complicated, DOS is simple. A DOS program can be written with a few straight-forward lines of code. But even the simplest Windows program is a staggering Behemoth, with all manner of twisted, convoluted, and bizzarre function calls in it. The Windows version of the famous "Hello World" program is over 80 lines long. And all it does is print "Hello World" on the screen!!!

So, for this reason, I say DOS is the ideal operating system for the beginner. Once you get the hang of C programming, then you can go for Windows.

Here's how to make a DOS program in Borland C++ 4.x:

1. Go into Project Menu, select NEW PROJECT.
2. Put in your filename in "Project path and name" (ie: TEST.IDE).
3. Set Target Type to Application (.exe)
4. Set Platform to DOS (Standard)
5. Set Target Model to Large
6. Click on OK... Project window will pop up.
7. Double click on the .CPP file in the project window and start typing in your program.


Here's a test program to try:


#include <stdio.h>
#include <dos.h>

void main() {
    int x;

    printf("\n\n Are we having fun yet? \n\n");
    for (x=50; x<2000; x++) {
      sound(x);
      delay(3);
    }
    nosound();
}



After you type this in (or Edit Copy/Paste it), you need to compile it. The best way to do this is to go into the "Project" menu and select BUILD ALL.

Once you compile it, there are two ways to run it:

1. You can use the "Lightning Bolt" icon up on top of the screen,

-- OR --

1. Open up a DOS prompt (double click on Dos Prompt icon, or go into the Start Menu and select Dos Prompt).
2. Go into your C++ programs directory, (CD <directory name>)
3. Type in the name of your project (the name of the .EXE file).



* General Information *

1. First off let me say USE THE ONLINE HELP!!! Borland C++ has a fantastic reference manual built right in. Just go into the HELP menu, select CONTENTS, then SEARCH. Every single command is in there, along with examples showing how to use the commands.

2. With Borland C++ 4.52, if you aren't using a project, then you need to choose which platform to compile for. To do this, RIGHT click on the program edit window. Then select TARGET EXPERT. If its a DOS program, pick APPLICATION (*.exe), DOS STANDARD, LARGE memory model. You can also use EASYWIN (.exe) to run text-based DOS programs in a window on the desktop.

3. PROJECTS -- With Borland C++ (either version 4.x or 3.x), if you want to use your own HEADER files, or someone else's Header files, or an external Library (.LIB file), you have to create a PROJECT.
3A. With Borland 4.52, all you do is go into the PROJECT menu and select NEW PROJECT. The Target Expert window will come up. Choose the platform (MS DOS or WINDOWS, as above) and enter the filename for your project (should be same as your CPP and EXE file). Next, LEFT click on the .EXE file in the Project Window, then press INSERT. In the dialog box, type in the filename of the *.cpp, *.h, *.lib or whatever other file you want to add to your program. Do the same (pressing INSERT while the .EXE file is highlighted) for every file you want to include in your program. You can RIGHT click on the .EXE file at any time to bring up the "Target Expert" Window.
3B. Borland C++ 3.1 is similar, except that you do NOT include *.H (header files). Also, instead of using the mouse buttons, everything is done from the PROJECT menu. Use PROJECT/INSERT to add a file to the project. As for platform, the only RELIABLE way to compile a Windows program is to use Borland C++ for Windows. The only RELIABLE way to compile an MS DOS program is to use the MS DOS version of Borland C++. There are TWO separate versions of Borland C++ 3.1, one for Ms Dos, and one for Windows.

4. C is CASE SENSITIVE. This means that upper and lower case DOES matter. If you are having trouble, make sure the command is EXACTLY the same, even down to the CASE of each letter. Most of the time things are all lower case. This is one of the most common problems.

5. Don't forget semicolons on the end of each line! This is the other most common problem. Sometimes forgetting a semicolon will cause an off-the-wall errors much later in the program. If you are getting a error and everything looks right, scrutinize your whole program, look for a missing ; at the end of a line. Presto! All 17 of those errors are gone!!!

6. Finally, save BEFORE you compile and run the program!!! SAVE FIRST!


* Should I learn C++? *

If you are a beginner, try for Visual Basic, QBasic, or Pascal. You will have a much easier time with them. Then later, after you get good at one of these and have written several programs, you can start learning C or C++...
If you try to jump into C right away, you are going to fall fast and hard, and end up frustrated for a very long time. Sure, you will understand the basics of C programming, anyone can. But you will be totally lost when it comes to the more advanced features... I personally know LOTS of people who wanted to get into programming, and tried to learn C/C++ first. And you know what happened? 99% of them gave up. Which is irritating for me because I could tell they would have been good programmers... Thier only problem was they tried to learn too much too quickly!!

Now, if you already have some programming experience, go for it!!! C/C++ is by far the fastest, most efficient, and most powerful language out there. And once you get good at it, its the most fun and straightforward. There's no going back! Thats why most of today's programs are written in C/C++.

The next obvious question is, what's the difference between C and C++?

In really overly-simple terms, C++ is everything C is, and more. C++ has more built-commands and supports more types of variables than C does...
In more complex terms, C++ supports true Object-Oriented Programming.

Ok, So what is "Object Oriented Programming", then?

Object Oriented Programming doesn't mean programming Visually (ie: with Icons and Pictures and Flow Charts), which is a common mis-understanding...
Rather Object-Oriented programming means you can create a very special new type of variable, which we called an Object (in C++ these Objects are known as a CLASS). These Objects can contain Functions (methods), Variables, Arrays, and even other Objects in them. You can also create one Object based on another (this is called "Inheritance"). With one single line of code, the new Object will contain everything that the original Object did. You can then add other Functions, Variables, Arrays, ect to the new Object, and even modify the existing ones (inherited from the old Object). A great time-saver, trust me!!!

Its a little hard for me to explain without giving both a visual example and some sample code... I'm sure if you look up "Object Oriented Programming" in a good internet search engine (such as
www.google.com or www.yahoo.com), someone has done a better job at explaining this than I have!

I can think of one quick example... Consider a 2D Space Shooter game. Such as Defender, or Galaga, or even the venerable Space Invaders. You have a number of enemies on the screen. You also have lots of bullets on the screen. All of these things are moving around, independent of one-another. How would you represent this in code?

I'll briefly explain two ways:

FIRST WAY TO DO IT is to create a couple arrays. Lets say X[], Y[], XSpeed[], YSpeed[], HitPoints[], GrapicNumber[]

Each alien and bullet would be one element in this array. You'd use a FOR loop to step through the whole array for every frame of the game... This FOR loop would make the alien or bullet move (add XSpeed to X, add YSpeed to Y), Re-Draw the alient or bullet at its new location on the screen (GraphicNumber,X,Y) and check to see if this alien needed to be removed (play blow-up animation, and delete, if HitPoints falls below 0).

This will work. I've done several games this way. The problem is, you have to define the size of the array up-front (at the top of your program). And you can't go over this. So lets say I dim'd the arrays to 100 elements. Well, the game could never have more than a total of 100 aliens and bullets on the screen, ever, unless I went into the code, increased the number of elements, and re-compiled it.

Oh, and deleting an alien/bullet is a bit of chore. Go on, think about that one for a while. How would you do it? EMail me if you want the answer.

SECOND WAY TO DO IT is to use objects.

First we create an object-type called THING.
THING will contain the following variables: X, Y, XSpeed, YSpeed, HitPoints, GraphicNumber
THING will contain the following fucntions: Move(), Draw(), Destroy()
Move() will add XSpeed to X, and YSpeed to Y, and then call Draw().
Draw() will draw this thing on the screen at coordinates (Thing.X, Thing.Y)
Destroy() will remove this thing (yes, there is a built-in function to do this!)

Next, we create another object-type called BULLET. Bullet is a THING with the following additions:
Damage - A variable to determine how much damage this bullet does.
CheckIfGone() - a function which will call Thing.Destroy() if the bullet has gone off-screen.
CheckIfHit() - a function which calls Alien.Hit() (see below) and Thing.Destroy when the bullet hits an Alien.
We will also add to the Move() function a call to CheckIfHit() and CheckIfGone().

Next, we create another object-type called ALIEN. Alien is a THING with the following additions:
SHoot() a function that creates a BULLET object at the Alien's postion, and sets XSpeed, YSpeed so the bullet will fly towards the player (yes, there is a built-in function to do this!).
CheckIfDead() - a function which will call Thing.Destroy() if the Alien's Hit Points falls below 0.
Hit() - a function that will remove Hit Points and plays the Explosion Animation when a bullet hits and Alien. It also calles Alien.CheckIfDead() to see if this Alien needs to be removed.

There are built-in functions to Create and Destroy objects. And its all done dynamically, on-the-fly! Now, in C++ you'll probably need to create something called a "Linked List" to hold all your Objects. Or an Array (of Objects). In other Object Oriented languages (such as BlitzBasic, and Visual Basic) even this is taken care of for you!

In the beginning of your game, you'd call the Create function a bunch of times to create all the Alien Objects.
Whenever the Player or an Alien shoots, you'll call the Create Function to create Bullets
Your FOR loop will go through each object and call Alien.Move() or Bullet.Move() and then Alien.ReDraw() or Bullet.ReDraw().
Whenever a bullet hits something or goes off the screen, it will automatically be removed from the game (the MOVE() function of the BULLET object takes care of this for you).
Whenever an Alien is killed, it will automatically be removed from the game (taken care of by the HIT() function, which is called by the BULLET when it hits an Alien).
So the only thing you really have to worry about every frame is just moving the objects around the screen! The objects themselves take care of everything else!!!
It looks like a lot when I write it out like this, but if you saw actual code, you'd see that the C++ version is a whole lot shorter (and more importantly, simpler) than the C (arrays-only) version.


Come back in the future and there may be more information here.

You are the person to visit Seth Hopkinson's Borland C++ Page since 29 Aug 2004.

Return to Alpha Omega System's Home Page.


This Web Page was created 4 Nov 1996 by Seth Hopkinson. Last Modified 29 Aug 2004.