• home
  • forum
  • my
  • kt
  • download
  • How to begin writing games in C++

    Author: 2007-09-03 16:36:56 From:

    Tank 3 Creation Document

    Hi, folks!

    So you want to know how I created Tank 3? Ok, I've written a commented
    time line for you and mixed some General info, tips and tricks into it.
    So you can read what the basic steps of creating Tank 3 were. The lines
    in italic and bold print are the news that I published on my homepage,
    www.infinitecode.com.
    Enough talk, let's begin!

    The idea

    3.12.2000
      started to think about a new
      game, maybe Tank 3.0 ?!?
    In december 2000 I had the idea to write a sequel to my earlier games
    "Tanksim" and "Tank 3D". I chose to write a sequel to these games,
    because I already had some experience in Tank games. And, as I did
    my military service from Juli 2000 to April 2001, I was quite addicted
    to tanks at that time.
    For those of you who haven't written a game yet, here are some general
    tips about ideas and choosing the genre of your game:
    - Don't try to imitate a special game, like Command & Conquer, Starcraft
    or Quake 3, you can't reach them, if you don't have the experience yet.
    - Don't expect too much of your game. Especially your first games should
    be considered as a training of programming games
    - Start with something simple like Tetris or some scrolling shooter like
    "Space Invaders"
    - Select a genre that you have experience with. If you don't know the
    basics of BSP and portal rendering, you shouldn't try to write a
    quake-like game.

    Selecting the programming language and
    graphics interface


    The typical gaming language is C++, but I've also written games with
    Pascal and Delphi. So if you know more than one programming language,
    think carefully about which one you use.
    The second important point is which graphics interface to use. You can
    use the following for example (some of them are really outdated):

    VGA mode 320x200 (used in many DOS games)

    This one is outdated today. In DOS times, this was a good place to begin.
    I used it for Tanksim. You should know a bit of assembler to use it
    efficiently.

    SVGA (DOS games)

    Also outdated. You should know quite a lot of assembler to make the
    graphics fast.

    Windows GDI

    The graphical driver interface of Windows. I used this in Nebula. You can
    do quite a lot with it but you have to know a lot about graphics, as there
    is no 3D acceleration.

    DirectX, OpenGL and Glide

    These interfaces are basically the same. I used DirectX in Tank 3 and
    Glide in Tank 3D. You can use 3D acceleration with them. Knowledge of
    Matrix operations and trigonometry is very useful.
    9.12.2000
      started writing the new
      graphics engine for
      Tank 3.0

    Interruptions

    16.12.2000
      got the new tasks for the
      programming contest I'm
      participating in. Maybe
      Tank 3.0 will have to
      wait two or three weeks.
      sorry!
    This will happen very often during your work. You have another important
    project that you need time for, or you have to learn for the tests in school
    (if you still go to school), or anything else. One of my biggest problems at
    the beginning was that I never finished a project. At the beginning I was very
    entusiastic, but later I had to make a break that stopped the enthusiasm.
    And when I had time again after the break, I thought about a new game/project.
    "One of your most important resources is your enthusiasm"
    So it's very important that you keep your motivation.
    12.01.2001
      Tank 3.0 page created.
      Here you can see the
      creation process of
      Tank 3.0
    Putting news of Tank 3 onto my homepage was one good idea, because this way I
    got much feedback from other people, who encouraged me to work on and told me
    what is still missing in the game.

    Benchmarks

    07.01.2001
      Tank 3.0's terrain is
      starting to work. Time
      for a terrain buffer
      and terrain textures...
    27.01.2001
      Trying if Delphi 5.0
      works better than
      Delphi 3.0
    17.02.2001
      Experimenting with
      DirectX
    22.02.2001
      Got DirectX working.
    Normally, it is a good idea to write a concept document before beginning
    to program the game. But sometimes it might be advisable to begin with
    some coding before you really start to write the game to check out what
    kind of engine you can make and what you better dont do. I did this before
    I started writing Tank 3 and found my way to C++ and DirectX after trying
    Pascal, Delphi and OpenGL in some "Benchmarking" programs.

    Beta testing

    27.02.2001
      Wrote a demo of
      Tank 3.0.
    08.03.2001
      New Tank 3.0 directx
      beta version!
    19.03.2001
      Finished and uploaded the
      Beta version 3 of
      Tank 3.0.
    31.03.2001
      Uploaded tank 3
      beta 4.
    It's always good to have someone with a different point of view who helps
    you a bit. I decided to make an open beta test on my homepage to get
    much feedback on the game.

    Compatibility

    01.05.2001
      Finally have time for
      programming...
      (the military service time was over)
      I've updated Tank 3.0
      to directx7. Works with
      3Dfx now. Beta 5 with
      dx7 will come soon!
    DirectX brought some compatibility problems with it. I used DirectX 2.0 at
    beginning, because most of the DirectX tutorials on the net used DirectX 2.0.
    But 3Dfx worked only since DirectX 5.0. So I had to update the complete source
    code. That was quite a lot of work. When I updated all the variables and
    changed the procedures, nothing worked. After a while I managed to get a black
    screen. After another 2 days I managed to see some triangles, but they were
    very distorted. Later I found one hard-to-find bug that had to do with the
    update of a DirectX structure. After that everything worked, despite of
    transparency. Later, I found a line well-hidden in a documentation file that
    said that the lighting mode was changed and I had to shut off lighting to
    display transparent triangles now. This update was one of the hardest tasks
    that I've faced during programming and it costed me a week of bug-finding.

    Features ("is it a bug or a feature?")

    05.05.2001
      Trying to implement
      trees into Tank 3.0...
      That's far more complex
      than I thought. Having
      lots of problems with
      the transparent
      surfaces...
    The trees were a good feature, as they made the terrain much less "boring".
    But you should careful about features, especially graphics features that don't
    change anything of the gameplay. Concentrate on finishing the important things
    of the game before adding "cool" features. Features can make the game atmosphere
    very rich, but a good gameplay is much more important!
    06.05.2001
      Uploaded Tank 3 beta 5.
      Implemented trees and
      collision detection.
      The new beta uses
      DirectX 7, which
      supports more 3d cards
      than the older version.

    The interface

    12.05.2001
      Building the user
      interface and working
      on the missions...
    Make sure you have a good interface. I used an interface that is very much
    similar to Command&Conquer. In some genres, there are interfaces that are
    "the standard". Fell free to use them! There is no need to "reinvent the wheel"
    here.

    milestones

    15.05.2001
      The beta-version 6 of
      Tank 3.0 will come soon!
      The game begins to be
      playable. I'm working on
      the first missions at the
      moment.
    Set yourself milestones that you work towards. The first milestone is, when the
    important parts of the engine work. The second important milestone is the point,
    where the interface and the "key functions" of the game work.

    sound

    16.05.2001
      Beta 6 is up!
      The game is playable as
      a strategy game now and
      has 3 missions (will
      highly increase in next
      versions) and sound!!!
      More details on the
      tank3 page.
    Many games don't have any sound at all. Sound is a very important feature to make
    an atmosphere. As this is a feature rather that a gameplay element, implement it
    after getting the game playable.

    Optimizing

    19.05.2001
      Updated Beta 6 to 6.2
      Is already uploaded.
      Fixed some bugs and
      increased framerate.
    Don't spend too many of your resources in speed optimizing at the beginning. Of
    course you can do some "basic" optimizing when you write the code, and if you
    implement structures like sinus tables, you should use them at the beginning
    already. But doing the "hardcore" optimizing is something to do after getting
    the game playable.
    21.05.2001
      Uploaded beta 7. More
      types of tanks and
      more missions.

    More compatibity problems...

    23.05.2001
      I'm working night and
      day on the 3Dfx problem
      with Tank 3.0
    23.05.2001
      Improved compatibility
      to 3Dfx. Uploaded
      improved Beta 7.1
    29.05.2001
      Uploaded Tank 3 Beta 8
      Greatly improved
      Missions, some new 3D-
      Objects, improved
      Hardware detection.
      Should work with
      Voodoo2 now.
    30.05.2001
      There are still
      problems with newer
      graphics cards. Wait
      a few days until I've
      fixed it or use Beta 7
      instead (Tank 3 page).
    31.05.2001
      Beta 8 works with
      newer graphics cards
      like GeForce 2 and
      Voodoo3 now.

    More interruptions...

    31.05.2001
      I'll be on holidays
      from Friday to Monday.
    Well, it rained all the time during my holidays...
    05.06.2001
      I'm back from my
      holidays. Fixed the
      Voodoo2 mouse problem.
    06.06.2001
      I'm working on
      turning the beta
      version into a
      full Tank 3.0
      "final"
    version.
    10.06.2001
      I'm writing a
      graphic mission
      editor for Tank 3,
      so users can design
      missions for the
      game.
    11.06.2001
      Uploaded Tank 3 Beta 9
      with mission editor.
      If you design good
      missions, please mail
      them to me, so they
      are published with
      the game.
    19.06.2001
      Tank 3 Beta 10 with
      lots of changes
      uploaded
    23.06.2001
      Finally made the first
      "final" version of
      Tank 3.0. This doesn't
      mean that I stop working
      on it. Uploaded the
      new file with some
      changes.
    01.07.2001
      I'm working on a 3D
      model editor for Tank 3.
      Next, I'll make the
      models more detailed.
    05.07.2001
      Tank 3.1 will come soon!

    Terrain resolution

    05.07.2001
      Uploaded Tank 3.1
      Lots of changes again!
    When I wrote version 3.1, I wanted to add a detail texture to the terrain. This
    needed a lot of time, because I had to render the terrain twice. I managed to
    increase the speed by rendering the terrain with less triangles. This made the
    terrain a bit unsmoother, but it increased speed so that I could use the
    detail texture.
    You might also encounter some speed problems when you add more graphics detail.
    So you have to find some kind of a balance between nice graphics and speed.
    Write your game, so that most people can run it at an acceptable speed or (better)
    use an options menu, where you can change the detail. An options menu is one
    thing that is missing in Tank 3.

    Difficulty

    11.07.2001
      Made the first two
      missions easier.
      Uploaded a new
      version 3.11
    At the beginning I made the mission so hard that the player needs several tries
    to get it done. For game fun it is better to make at least the first missions
    easy, so the player can learn how to play the game. I made the difficulty easier
    in Tank 3 for several times.
    11.07.2001
      Uploaded version 3.12
      with better mission
      orders, gameplay
      "bugfixes", and
      easier missions.

    12.07.2001
      Fixed a speed bug
      and improved menu
      contrast. The new
      version is uploaded.
    11.08.2001
      Finally found some time
      to fix the hardware
      detection bug. Now
      you can use software
      rendering when you have
      an old graphics card.
      However, software mode
      is VERY slow.
      The 3.12 version has
      the new hardware
      detection now.
      I've also updated the
      Tank3 source code page.

    Source Compatibility (for open source projects)

    16.09.2001
      I've made the complete
      source code of tank 3
      compilable with MS
      Visual C++.
      The new version 3.13
      is already uploaded
      and the source code
      is updated.
    If you make an open source project, make sure that the source is compilable
    with the most compilers out there. For Tank 3 it was important to make it
    compatible with the most common compiler (at that time Microsoft Visual C++).

    I hope the hints in this documentation help you a bit to write your own games.
    And watch out for more tutorials on www.infinitecode.com!

    discuss this topic to forum

    relation tutorial

    No relevant information

    New

    Hot