Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 6 and Version 7 of pps/tutorial_basic


Ignore:
Timestamp:
Sep 30, 2008, 5:27:59 PM (16 years ago)
Author:
rgrieder
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • pps/tutorial_basic

    v6 v7  
    4141== TutorialShip Class ==
    4242We have derived a new type of !SpaceShip for you: !TutorialShip. The back end doesn't have to bother you (you will notice that some functions don't seem to be doing anything at all). [[br]]
    43 At the moment, you are using the !SpaceShip class. We would like to change this. Fortunately this can be done in an XML file where we load the level.
     43At the moment, you are loading an object of the !SpaceShip class. We would like to change this. Fortunately this can be done in an XML file where we load the level.
    4444 1. Go to your media repository (orxonox/Media) and open ''tutorial.oxw'' in the ''level'' folder with a text editor like vim, nano, etc.
    4545 1. Find the second paragraph (about 5th line) and change ''!SpaceShip'' to ''!TutorialShip''
     
    5050 1. You will see a large list of source files (*.cc). You can add "oxonox/TutorialShip.cc" anywhere you like, but it is preferred to organise the file a little bit. So look for !SpaceShip.cc and add things there.
    5151 1. Save and close.
    52 The interesting part: Modifying the C++ code. '''Open orxonox/trunk/src/orxonox/objects/TutorialShip.cc'''. As you have already heard from Fabian, the Core Framework is like a language extension to C++. But it cannot be 100% automatic. That means you have to add a few lines accordingly:
    53  1. Find the constructor (TutorialShip::TutorialShip()) and add '''RegisterObject(TutorialShip)''' as the first statement. This is used for the class hierarchy and for the ObjectLists.
    54  1. do more stuff
    55  1. (???)
    56  1. ...
     52The interesting part: Modifying the C++ code. '''Open orxonox/trunk/src/orxonox/objects/TutorialShip.cc'''. As you have already heard from Fabian, the Core Framework is like a language extension to C++. But it cannot be fully automatic. That means you have to add a few lines accordingly:
     53 1. Find the constructor (TutorialShip::TutorialShip()) and add '''RegisterObject(TutorialShip);''' as the first statement. This is used for the class hierarchy and for the ObjectLists. Whenever you derive from OrxonoxClass or any derivative, this call is necessary.
     54 1. Next will be creating a configurable value in our class. This enables us to configure the TutorialShip from outside (Shell or orxonox.ini). Go to the ''setConfigValues()'' and configure the member variable ''reloadTime_'' with a default value of 0.125. Remember the syntax:
     55{{{ SetConfigValue(''variable name'', ''default value'').description(''description text''); }}}
     56 1. The console command: It enables you to call a static function in the shell. Currently, our TutorialShip cannot fire any projectiles because there is no ConsoleCommand for "fire". This code is static, so we have to go to the beginning of the source code, just after {{{namespace orxonox {}}}. Now add a !ConsoleCommand for the static function ''fire()'' of the TutorialShip:
     57{{{ SetConsoleCommand(''class name'', ''function name'', true).keybindMode(KeybindMode::''mode''); }}}
     58    keybindMode specifies how the console command should be treated when used on a key. ''OnHold'' means the command gets fired continuously, ''OnRelease'' and ''OnPress'' only once. [[br]][[br]]
    5759
    58 '''Now start the game again and do some fancy in-game-stuff'''
    59  1. (???)
     60We haven't done everything yet, but a little function test would be nice. Compile Orxonox and run it just according to instructions above. If it doesn't compile at all, try to understand the error message and if that doesn't help, ask an assistant. [[br]]
     61You should now see exactly what you saw last time. The ship still won't fire anything. To change that we can assign that static ''fire()'' function to a key or button. To do that, open the console with the key just above "tab". To bind a console command to a key, type '''{{{keybind fire}}}''' (keybind is a command itself actually), hit enter and then hit the key or button you would like to assign the command to (preferably the left mouse button...).