User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision Both sides next revision
cppdev:startnewgame [2012-10-31 13:27]
Carsten created
cppdev:startnewgame [2012-10-31 23:00]
Carsten completed the text
Line 1: Line 1:
 ====== Starting your own Game or Application ====== ====== Starting your own Game or Application ======
  
-FIXME  THIS TEXT IS WORK-IN-PROGRESS,​ I'll finish it soon!   --- //[[carsten.fuchs@cafu.de|Carsten]] 2012-10-31 12:03//+After you took [[cppdev:​gettingstarted|the first steps with the Cafu source code]], you're ready to use it to develop your own game or application.
  
-After you took [[cppdev:​gettingstarted|the first steps with the Cafu source code]], ​you're ready to use Cafu to develop your own game or application project.+This section lists the most commonly used methods for starting new projects and explains the required ​steps to give you a good start.
  
-There are many good ways to work with Cafu. 
-This section lists the most commonly used, and the required steps to give you a good start. 
  
 +===== Working directly with DeathMatch =====
  
-===== Overview =====+Modifying the DeathMatch game "in situ" may seem like a totally silly /​*off-putting,​ ridiculous*/​ idea, but in some cases it can be a worthwhile consideration nevertheless:​
  
-Cafu is designed ​to make the development of new games and applications easy. +If you want to quickly try something out (e.g. a new entity class), or if you work on something ​that is not directly ​or entirely a completely new game (for example, any changes to the core engine)the game DeathMatch might be a welcome testbed.
-It separates the core engine ​(the technical framework ​that is the common basis for each game or appfrom the program code and the resources for each game.+
  
 +Also, if you wish to communicate and collaborate with people who are not directly involved with your game code, the DeathMatch code can be a good common ground.
  
  
-MODs, +===== Using DeathMatch as a basis =====
-like plug-ins ​ / ardchitectute +
-multiple at the same time +
-Games/ +
-each mod can be game or application+
  
-not stop from modifyin ​the core engine+The "​normal"​ and recommended way to start a new game is to create a copy or clone of the example game DeathMatch under a different name. This is useful because it immediately provides you with the proper directory structure, working code, and example files.
  
 +==== Creating the clone ====
  
-===== Working with DeathMatch =====+Creating the copy is straightforward:​
  
-Working with the DeathMatch ​example game as-is may seem totally off-putting to youbut in some cases it might be a worthwhile consideration nevertheless:​+  - In ''​Games'',​ duplicate ​the directory ''​DeathMatch''​ and rename the resulting copy as desirede.g. ''​MyGame''​. 
 +  - Delete the directory ''​build'' ​in ''​Games/​MyGame/​Code''​.
  
-If you want to quickly try something out (e.g. a new entity class), or if you work on something that is not directly or entirely a completely new game (for example, any changes to the core engine), ​the game DeathMatch might be a welcome testbed.+The second step is necessary because previous builds of DeathMatch may have created files whose copy can confuse ​the linker when it is creating ​the program library for ''​MyGame''​ for the first time.
  
- +To implement these steps, ​you can use any method you likefor example a file manager like Windows Explorer, or the command-lineThis example shows how you can do it under Linux:
-===== Copying DeathMatch ===== +
- +
-The "​normal"​ and recommended way to start a new game is to create a copy of our example game DeathMatch. This is useful because it immediately provides ​you with the proper directory structureworking code, and example ​files. +
- +
-==== Copy the directory ==== +
- +
-Change into the ''​Games/''​ directory and to create ​duplicate of the ''​DeathMatch/''​ directory there. Name the duplicated directory by the name of your game, e.g. ''​MyGame/''​.+
 <code bash> <code bash>
 $ cp -r Games/​DeathMatch/​ Games/​MyGame/​ $ cp -r Games/​DeathMatch/​ Games/​MyGame/​
 +$ rm -rf Games/​MyGame/​Code/​build
 </​code>​ </​code>​
  
-==== Delete leftover build files ====+==== Using your new game ====
  
-If you have built game DeathMatch beforeit's a good idea to prevent leftover files from interfering with your new game by deleting directory ''​build''​ in ''​Games/​MyGame/​Code''​. +Technicallythe above steps are all that is required ​to create the basis for your new game:
-<code bash> +
-$ rm -rf Games/​MyGame/​Code/​build +
-</​code>​+
  
 +  * When you re-run ''​scons''​ as documented at [[cppdev:​gettingstarted]],​ the code of your new game will automatically be picked up, compiled and linked.
 +  * When you start CaWE, it will automatically recognize the new game and show it in the "​Configure",​ "New Map", "New GUI", ... etc. dialogs. If "Start Engine"​ is checked in the "​Compile"​ menu, it will also start the Cafu Engine with the new game.
 +  * If you run the Cafu Engine from the command prompt, make sure to add parameter <​code>​-svGame MyGame</​code>​to the command-line,​ and see below how to get rid of it again.
  
 +==== Tips and Tricks ====
  
-  ​- When you then re-run ''​scons'' ​as documented at [[cppdev:​gettingstarted]], the code of your new game will automatically be picked upcompiled and linked. +  ​* If you want to run ''​MyGame'' ​by default (without ''​-svGame''​)see the section about the variable ''​GameLibs''​ in file ''​CompilerSetup.py'':<​code python>​ 
-  - If you run the Cafu engine from the command ​prompt, make sure to add parameter <​code>​-svGame ​MyGame</​code>​ +# When you're developing ​your own game, you might want to keep game DeathMatch 
-  ​- When you start CaWEit will automatically recognize ​the new game and show it in the "​Configure",​ "New Map", "New GUI", ​... etcdialogs. If "Start Engine"​ is checked in the "​Compile"​ menuit will also start the Cafu Engine with the new game. +# for reference. Cafu should ​run your game by default (first in list), whereas 
-  ​- Also see [[cppdev:​gamecodeoverview]] for details about the game directory. +# DeathMatch would be readily available via the -svGame ​command-line option: 
- +GameLibs = ["MyGame", "​DeathMatch"​] 
-You may wish to update all internal paths that still point into the "​DeathMatch"​ directory from ''​Games/​DeathMatch/''​ to ''​Games/​MyNewGame/''​. Under Linux, you can do it automatically like this: +</​code> ​Note that you have to re-run ''​scons''​ in order to changes take effect. 
-<code bash> +  ​* In ''​MyGame''​some paths in the code and scripts still point to ''​Games/​DeathMatch/​...''​For the beginningthat's ok -- your game will find some of its resources in game DeathMatch, and you can update these occurrences step by step at any later time (or even intentionally keep things like this)
-$ find Games/​GameName -type f -exec sed -i '​s/​DeathMatch/​GameName/​g'​ {} \; +  ​* Last but not least, check out [[cppdev:​gamecodeoverview]] for details about the files and subdirectories in the game directory.
-</​code>​+
  
  
 ===== Things not to do ===== ===== Things not to do =====
  
-Here is a list of possible courses of action that we suggest ​''​not'' ​to use in order to start a new game:+Here is a list of possible courses of action that we suggest ​//not// to use in order to start a new game:
  
 ==== Renaming DeathMatch ==== ==== Renaming DeathMatch ====
Line 71: Line 62:
 Renaming DeathMatch, instead of properly copying it, would principally work, if it was not for these factors: Renaming DeathMatch, instead of properly copying it, would principally work, if it was not for these factors:
   * It does not agree well with version control systems (Git or Subversion). If you follow our recommendation to checkout the Cafu source code from our Git or Subversion repositories,​ so that you can keep track of our latest developments while developing your own game in parallel, then renaming the DeathMatch directory is (indeed not impossible, but) somewhat incompatible with the way how these repositories work.   * It does not agree well with version control systems (Git or Subversion). If you follow our recommendation to checkout the Cafu source code from our Git or Subversion repositories,​ so that you can keep track of our latest developments while developing your own game in parallel, then renaming the DeathMatch directory is (indeed not impossible, but) somewhat incompatible with the way how these repositories work.
-  * Many paths in code and scripts still point to ''​Games/​DeathMatch/​...''​. If you rename DeathMatch, all these paths are broken, and your game will not work without fixing them first. If you instead copy DeathMatch, your game will find some of its resources in game DeathMatch, and you can update these occurrences step by step at any later time (or even intentionally keep things like this).+  * Some file paths in code and scripts still point to ''​Games/​DeathMatch/​...''​. If you rename DeathMatch, all these paths are broken, and your game will not work without fixing them first. If you instead copy DeathMatch, your game will find some of its resources in game DeathMatch, and you can update these occurrences step by step at any later time (or even intentionally keep things like this).
  
 ==== Start from scratch ==== ==== Start from scratch ====
cppdev/startnewgame.txt · Last modified: 2013-01-07 12:07 (external edit)