Tutorial 1 Part 1 - VC6Technical terms used in this tutorial can be found in the glossary. This tutorial assumes the ReplicaNet files are in the default location used by the installer. This tutorial shows:
Start Microsoft Visual Studio C++ 6.0
If there is a workspace loaded then Menu bar->File->Close Workspace. Now create our workspace.Menu bar->File->New...->"Projects" Tab->Win32 Console Application
Check that "An empty project" is enabled. This dialog tells you what files are about to be created for the project. Click "OK". Workspace created
The Workspace view should display. If this does not display then you can open
the display by choosing:
Open the menu above the "Tutorial1 files" entry in the list. Choose "New Folder...".
Click "OK".
Click "OK". Change "Settings For:" to
"All Configurations".
Choose the "C/C++" tab again.
Change "Settings For:" to "Win32 Debug".
Click "OK".
|
Gives |
To edit each file you can double click the file name and the file will display. The newly created "main.cpp" file should be empty.
Now we can start writing our ReplicaNet program.
Double-click the "main.cpp" filename to edit the file and add this code to the "main.cpp" file.
Menu bar->File->New->"Files" Tab->Choose "Text File"
Change the "File name:" box to "Application.rol".
Click "OK".
The workspace view will then update to contain the new file and put the new file in the "ROL Files" folder.
Click the cross box to the left of "ROL Files" in the workspace view to see the newly added "Applicatio.rol" filename.
Double-click the "Application.rol" filename to edit the file and add this code:
Tip: When editing rol files, the file must end with a carriage return otherwise the RNROLCompiler will display the message "warning : EOF encountered while close braces needed".
Now we need to tell VC6 how to compile ROL files. This uses the custom build rules available to us.
Open the workspace projects settings by opening the menu on "Tutorial1" in the workspace view and choosing "Settings..."
Open the "ROL Files" folder and select the "Application.rol" file.
Change "Settings For:" to be "All Configurations".
Choose the "Custom Build" tab.
In the "Commands" box change in to be:
"..\ReplicaNetPublic\RNROLCompiler\bin\rnrolcompiler.exe $(InputName).rol $(InputName).cpp $(InputName).h"
In the "Outputs" box change it to contain "$(InputName).cpp" and "$(InputName).h" on two
separate lines.
The dialog should look like:
Tip: Remember how to update the custom build settings because you will need to repeat it for every ROL file you add to your application. VC6 does not inherit settings for newly added files from the folder or file type.
Click "OK".
The "Application.rol" file will generate two source files called "Application.cpp" and
"Application.h" when the project is built.
These files, even though they are not generated yet, need to be
compiled.
To add these files to the project open a menu over "Tutorial1 files" in the workspace view.
Choose "Add File to Project...".
In the file open dialog, change the "File name:" box to "Application.cpp".
Click "OK" and answer "Yes" to the warning box that tells you about the file not existing.
Add "Application.h" using the same method as for "Application.cpp" remembering to use the "Application.h" name this time. Answer yes again to the question about the file not existing.
You might want to add these generated files to the
"Compiled Objects" folder to keep everything tidy.
Choose Menu bar->Build->Rebuild All
You should see this output in the build output window.
Now looking at the "Application.cpp" and "Application.h" you should see some generated code from the ROL compiler.
NOTE: At the top of these two source files is "/* Auto-generated with RNROLCompiler
Vx.x.x.x don't edit */" which tells you the files get generated by the ROL Compiler. Changes in these files will get lost if they are edited.
At this stage the application does not do much except allocate a new ReplicaNet class.
Now we can start to add C++ classes. These classes could be objects in a game that control enemies or the player, for example.
This is covered in tutorial 1 part 2.