1. Начинаем разработку компьютерной игры.

    • ​Окно Windows

      It's time to add to our billet small code to display a blank window on the screen. For starters try to apply header file Precompiled.h. To create a window we need the following classes ATL: CWindowImpl, CWindow and CWinTraits, which are described in the header file atlwin.h. For convenience, create a data structure DesktopWindow (in fact it is the window class). Also override the macro to verify critical resource use functions (ATLVERIFY).

      Now, add the code in a class of our window. We use a macro to the ad window and set its card messages and write functions for minimum functionality.

      DECLARE_WND_CLASS_EX (L "window", CS_HREDRAW | CS_VREDRAW, -1);

      BEGIN_MSG_MAP (DesktopWindow)

      MESSAGE_HANDLER (WM_PAINT, PaintHandler)

      MESSAGE_HANDLER (WM_DESTROY, DestroyHandler)

      END_MSG_MAP ()

      LRESULT PaintHandler (UINT, WPARAM, LPARAM, BOOL &)

      {

      PAINTSTRUCT ps;

      VERIFY (BeginPaint (& ps));

      Render ();

      EndPaint (& ps);

      return 0;

      }

      LRESULT DestroyHandler (UINT, WPARAM, LPARAM, BOOL &)

      {

      PostQuitMessage (0);

      return 0;

      }

      void Render ()

      {

      }

      We now turn to the main program file. Here we create an object of our class and the message loop.

      DesktopWindow Hanoi;

      VERIFY (Hanoi.Create (nullptr, 0, L "The problem of the Towers of Hanoi"));

      MSG message;

      BOOL result;

      while (result = GetMessage (& message, 0, 0, 0))

      {

      if (-1! = result)

      {

      DispatchMessage (& message);

      }

      }

      Now we compile the program, and finally see our empty window.

      Machine translation
      Comments: 0
    • Small sketch

      It is time to think about what kind of results we want to achieve. In this study, I will limit small project, which will be illustrated with all known problem of the Towers of Hanoi.

      So, here is a plan to develop our application:

      • You must create a template for the minimum window using ATL.
      • Using object-oriented programming, we define the structure of the program.
      • Then, the properties window.
      • The next step will connect Direct2D.
      • Let us learn to "draw" boxes of which will consist of the main picture.
      • A little work on the animation.
      • Pomanipuliruem disk Tower of Hanoi with the mouse.
      • And finally, add a button for a more flexible management of the program.

      Let's start with the workpiece.

      Create a new project in the Visual Stidio 2013.

      This will be an empty project Win32.

      We add to our project file 3: HanoiDirect2D.cpp, Precompiled.cpp, Precompiled.h.

      Navigate to the file properties Precompiled.cpp.

      And adjust the item "precompiled headers".

      Finally add a minimal amount of code to make our program work (in our program yet his window, but it does not find errors, and it works).

      // HanoiDirect2D.cpp

      #include "Precompiled.h"

      int __stdcall wWinMain (HINSTANCE module, HINSTANCE, PWSTR, int)

      {

      return 0;

      }

      // Precompiled.cpp

      #include "Precompiled.h"

      // Precompiled.h

      #pragma once

      #include <atlbase.h>

      Machine translation
      Comments: 0
    • Let's try to do something ...

      So, to choose the scope of activities to which we begin: drawing, modeling or programming. And I choose ... programming. Everything else, maybe I did not even touch on in this study.

      You can select any engine ready and start writing scripts for him, as well as delve into the study of its source code to make the necessary changes for the needs of the game. But until we get down to the study of one of the DirectX APIs, and it will Direct2D.

      3fbcbe92-2fa6-11e5-895a-08606e697fd7

      Direct2D has a simple structure and a good start for the first acquaintance with DirectX and Direct3D general in particular. First we need to skim c Component Object Model (COM), which is closely linked with DirectX and ATL, which we use as our primary object structure of the main window.

      Machine translation
      Comments: 0
    • Well see what happens ...

      To begin

      Machine translation
      Full text
      Comments: 0