Tutorial 1 Part 1 - DotNETTechnical 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 C++ dotNET
If there is a solution loaded then Menu bar->File->Close Solution. Now create our workspace.Menu bar->File->New->Project... Then pick "Visual C++ Projects" from the left hand side and "Win32 Project"
Select "Application Settings", select "Console Application" and check "Empty Project" Click "Finish". Solution created
The Solution view should display. If this does not display then you can open
the display by choosing:
Open the menu above the "Tutorial1" entry in the list. Choose "Add->New Folder". Name the new folder "ROL Files".
Adding an extra folder helps to keep ROL files, that describe objects, separate from our other source files. Name the new folder "Compiled Objects"
This folder is where the compiled ROL file output files can go to keep the project tidy. Change "Configuration:" to
"All Configurations".
Choose the "C/C++"->"Code Generation" item.
Change "Configuration:" to "Debug", answer
"Yes"
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 add the ReplicaNet amalgamated source file found in "C:\Program Files\Replica Software\ReplicaNet\ReplicaNetPublic\AmalgamatedReplicaNet.cpp" using similar steps as the above.
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.
Open the menu over "Tutorial1" and choose "Add->Add
New Item..."
This time choose "Text File (.txt)"
Change the "Name:" box to "Application.rol".
Click "Open".
The solution view will then update to contain the new file and put the new file in the "ROL Files" folder.
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 dotNET how to compile ROL files. This uses the custom build rules available to us.
Open the workspace projects settings by opening the menu on "Application.rol" in the
solution view and choosing "Properties"
Select the "Custom Build Step" folder.
Change "Configuration:" to be "All Configurations".
In the "Command Line" 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;$(InputName).h;"
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. DotNET does not inherit settings for newly added files from the folder or file type.
Click "OK".
Now try to build the solution from
"Menu Bar->Build->Build Solution". You will
get a link error about an "unresolved external",
this is normal.
The "Application.rol" file should have generated two source files called "Application.cpp" and "Application.h".
These files, even though they generated by the ROLCompiler, need to be
compiled by dotNET.
To add these files to the project open a menu over "Tutorial1 files" in the workspace view.
Choose "Add->Add Existing Item...".
In the file open dialog, select "Application.cpp" and
Application.h".
Click "Open" to add these files. You might want to add these
generated files to the "Compiled Objects" folder
to keep everything tidy.
Choose Menu bar->Build->Build Solution
You should see this output in the build output window.
Now looking at the "Application.cpp" and "Application.h" (Application.h
is in the "Header Files" folder) 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.