Forums Gallery Downloads LOGIN |REGISTER

Hello World Tutorial - A bare bones game from scratch in C++

Help others by sharing your tutorials here.


 

User avatar
crydevJim
Developer
Developer
 
Posts: 337
Member since: 22.06.2013, 21:46
Likes: 210

Hello World Tutorial - A bare bones game from scratch in C++

Postby crydevJim » 15.03.2014, 16:27

Looking at the results of this poll, it seems there is considerable interest in a a tutorial on how to make a "bare bones" game i.e. a "game from scratch". I was interested too, so I decided to tackle it.

Update: Part II of this tutorial is also now available.

Update: Here is the video on YouTube: https://www.youtube.com/watch?v=JKLlenwGfpY

Update: Added changes to GameStartup to allow the game to start with a launcher (GameSDK.exe), ie without the Editor.

In the docs, it tells us:

The code handling the initialization of a CryENGINE game is contained inside Code\Game\GameDll\GameStartup.cpp. The function CGameStartup::Reset() is handling the allocation and initialization of the IGame interface.

For adding any game specific initialization, it is recommended to look into CGame::Init(). This function is called once when the game is loaded. The function CGame::Shutdown() will be called when the game is being shutdown.


Additionally, if you want to start your game from the editor, you'll need to implement IEditorGame.

So after some considerable effort (I must admit :-) ), here is my version of a minimal game in CRYENGINE. It uses just 3 core classes namely CGame, CGameStartup and CEditorGame. I've also only implemented what appear to be the must-have functions, with skeletal implementations of the non-essential functions in the headers.

Take a moment to compare how little code is involved in (e.g.) the Game.cpp file when compared with the same file which ships with the demo.

I hope that by stripping out all but the bare essentials, this will help show how the engine interacts with your game code and vice versa. Learning (and understanding) should be boosted then by adding classes and functionality piece by piece as required. Indeed some additions will certainly be needed to turn this basic application framework into a game.

To use the code, save your code folder as a first step. Then open the solution in Visual Studio - I used VS 2013 and v3.5.8 for these tests - and then right click on all the folders in the Solution explorer and select "delete". Remove also the other .cpp and .h files leaving only resource.h and StdAfx.h and StdAfx.cpp. Now copy the 6 .h and .cpp files below and overwrite the files of the same name under code/GameSDK/GameDll. Then right click on the CryGameSDK project and select Add->Existing Item and add the 6 files below. Your Solution Explorer should now look like this:

SolutionExplorer.jpg

Game.h
Code: Select all
/*************************************************************************
  Crytek Source File.
  Copyright (C), Crytek Studios, 2001-2004.
-------------------------------------------------------------------------
  $Id$
  $DateTime$
  Description:
 
-------------------------------------------------------------------------
  History:
  - 3:8:2004   11:23 : Created by Márcio Martins

*************************************************************************/
#ifndef __GAME_H__
#define __GAME_H__

#if _MSC_VER > 1000
# pragma once
#endif

#include <IGame.h>
#include <IGameFramework.h>
#include <IGameObjectSystem.h>
#include <IGameObject.h>

#define GAME_NAME            "GAMESDK"
#define GAME_LONGNAME      "CRYENGINE GAME SDK"

class CGame : public IGame
{

public:
   CGame();
   virtual ~CGame();

   VIRTUAL bool  Init(IGameFramework *pFramework);
   VIRTUAL bool  CompleteInit() { return true; }
   VIRTUAL void  Shutdown();
   VIRTUAL int   Update(bool haveFocus, unsigned int updateFlags);
   VIRTUAL void  EditorResetGame(bool bStart);
   VIRTUAL void  PlayerIdSet(EntityId playerId) {}
   virtual bool IsReloading() { return false; }
   VIRTUAL IGameFramework *GetIGameFramework() { return m_pFramework; }
   VIRTUAL const char *GetLongName() { return GAME_LONGNAME; }
   VIRTUAL const char *GetName() { return GAME_NAME; }
   VIRTUAL void GetMemoryStatistics(ICrySizer * s) { s->Add(*this); }
   VIRTUAL void OnClearPlayerIds() {}
   VIRTUAL TSaveGameName CreateSaveGameName() { return nullptr; }
   VIRTUAL const char* GetMappedLevelName(const char *levelName) const { return ""; }
   VIRTUAL IGameStateRecorder* CreateGameStateRecorder(IGameplayListener* pL) { return nullptr; }
   VIRTUAL const bool DoInitialSavegame() const { return true; }
   VIRTUAL THUDWarningId AddGameWarning(const char* stringId, const char* paramMessage, IGameWarningsListener* pListener = NULL) { return 0; }
   VIRTUAL void RemoveGameWarning(const char* stringId) {}
   VIRTUAL void RenderGameWarnings() {}
   VIRTUAL void OnRenderScene(const SRenderingPassInfo &passInfo) {}
   VIRTUAL bool GameEndLevel(const char* stringId) { return false; }
   void SetUserProfileChanged(bool yesNo) {}
   VIRTUAL IGame::ExportFilesInfo ExportLevelData(const char* levelName, const char* missionName) const { return IGame::ExportFilesInfo("NoName", 0); }
   VIRTUAL void   LoadExportedLevelData(const char* levelName, const char* missionName) {}
   VIRTUAL const uint8* GetDRMKey(uint32 *pKeySize) { *pKeySize = 0; return NULL; }
   VIRTUAL const char* GetDRMFileList() { return NULL; }
   VIRTUAL void RegisterGameFlowNodes() {}
   VIRTUAL IGamePhysicsSettings* GetIGamePhysicsSettings() { return nullptr; }
   void FullSerialize(TSerialize serializer) {}
   void PostSerialize() {}
   IAntiCheatManager *GetAntiCheatManager() { return nullptr; }
   virtual void LoadActionMaps(const char* filename) {}

   void buildWorld();

protected:

   IGameFramework         *m_pFramework;
};

SC_API extern CGame *g_pGame;

#endif //__GAME_H__

Game.cpp
Code: Select all
/*************************************************************************
Crytek Source File.
  Copyright (C), Crytek Studios, 2001-2004.
-------------------------------------------------------------------------
  $Id$
  $DateTime$
 
-------------------------------------------------------------------------
  History:
  - 3:8:2004   11:26 : Created by Márcio Martins
  - 17:8:2005        : Modified - NickH: Factory registration moved to GameFactory.cpp

*************************************************************************/
#include "StdAfx.h"
#include "Game.h"

CGame *g_pGame = 0;

CGame::CGame()
: m_pFramework(0)
{
   g_pGame = this;
   GetISystem()->SetIGame( this );
}

CGame::~CGame()
{
   m_pFramework->EndGameContext();
   g_pGame = 0;
   GetISystem()->SetIGame( NULL );
}

bool CGame::Init(IGameFramework *pFramework)
{
   m_pFramework = pFramework;
   return true;
}

int CGame::Update(bool haveFocus, unsigned int updateFlags)
{

   //buildWorld();

   bool bRun = m_pFramework->PreUpdate( true, updateFlags );
   m_pFramework->PostUpdate( true, updateFlags );
   return bRun ? 1 : 0;
}

void CGame::EditorResetGame(bool bStart)
{
   //built = false;
}

void CGame::Shutdown()
{
   this->~CGame();
}

GameStartup.h
Code: Select all
/*************************************************************************
Crytek Source File.
Copyright (C), Crytek Studios, 2001-2004.
-------------------------------------------------------------------------
$Id$
$DateTime$

-------------------------------------------------------------------------
History:
- 2:8:2004   15:20 : Created by Márcio Martins

*************************************************************************/

/*************************************************************************
300314: A minimal implementation of an IGameStartup by James Brady
090814: Added some changes to allow startup without the Editor (ie with GameSDK.exe)
*************************************************************************/

#ifndef __GAMESTARTUP_H__
#define __GAMESTARTUP_H__

#if _MSC_VER > 1000
# pragma once
#endif

#include <IGameFramework.h>
#include "CryWindows.h"

#define GAME_FRAMEWORK_FILENAME   "CryAction.dll"
#define GAME_WINDOW_CLASSNAME      "CryENGINE"

class CGameStartup : public IGameStartup
{
public:
   virtual IGameRef Init(SSystemInitParams &startupParams);
   virtual IGameRef Reset(const char *modName);
   virtual void Shutdown();
   virtual int Update(bool haveFocus, unsigned int updateFlags);
   virtual bool GetRestartLevel(char** levelName) { return false; }
   virtual const char* GetPatch() const { return nullptr; }
   virtual bool GetRestartMod(char* pModName, int nameLenMax) { return false; }
   virtual int Run( const char * autoStartLevelName );//Added to start with GameSDK.exe { return 0; }

   static CGameStartup* Create();

   //Added to start with GameSDK.exe
   bool InitWindow(SSystemInitParams &startupParams);

protected:
   CGameStartup();
   virtual ~CGameStartup();
   
private:

   //Added to start with GameSDK.exe
   static LRESULT CALLBACK WndProcHndl(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
   LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
   //end Added to start with GameSDK.exe

   bool InitFramework(SSystemInitParams &startupParams);
   void ShutdownFramework();

   IGame               *m_pMod;
   IGameRef            m_modRef;

   //Added to start with GameSDK.exe
   bool               m_initWindow;

   HMODULE               m_modDll;
   HMODULE               m_frameworkDll;

   IGameFramework         *m_pFramework;
};

#endif //__GAMESTARTUP_H__

GameStartup.cpp
Code: Select all
/*************************************************************************
Crytek Source File.
Copyright (C), Crytek Studios, 2001-2004.
-------------------------------------------------------------------------
$Id$
$DateTime$

-------------------------------------------------------------------------
History:
- 2:8:2004   15:20 : Created by Márcio Martins

*************************************************************************/

/*************************************************************************
300314: A minimal implementation of an IGameStartup by James Brady
090814: Added some changes to allow startup without the Editor (ie with GameSDK.exe)
*************************************************************************/

#include "StdAfx.h"
#include "GameStartup.h"
#include "Game.h"
#include "EditorGame.h"
#include "platform_impl.h"

#define DLL_INITFUNC_CREATEGAME "CreateGameFramework"

extern "C"
{
   GAME_API IGameStartup *CreateGameStartup()
   {
      return CGameStartup::Create();
   }
   GAME_API IEditorGame *CreateEditorGame()
   {
      return new CEditorGame();
   }
}

CGameStartup* CGameStartup::Create()
{
   static char buff[sizeof(CGameStartup)];
   return new (buff)CGameStartup();
}

CGameStartup::CGameStartup() :
      m_pMod(NULL),
      m_modRef(&m_pMod),
      m_modDll(0),
      m_frameworkDll(NULL),
      m_pFramework(NULL),
     m_initWindow(false)//Added to start with GameSDK.exe
{
}

CGameStartup::~CGameStartup()
{
   if (m_pMod)
   {
      m_pMod->Shutdown();
      m_pMod = 0;
   }

   if (m_modDll)
   {
      CryFreeLibrary(m_modDll);
      m_modDll = 0;
   }

   ShutdownFramework();
}

IGameRef CGameStartup::Init(SSystemInitParams &startupParams)
{
   startupParams.pGameStartup = this;

   if (!InitFramework(startupParams))
      return 0;

   ISystem* pSystem = m_pFramework->GetISystem();
   startupParams.pSystem = pSystem;

   IGameRef pOut = Reset(GAME_NAME);

   if (!m_pFramework->CompleteInit())
   {
      pOut->Shutdown();
      return 0;
   }

   return pOut;
}

IGameRef CGameStartup::Reset(const char *pModName)
{
   ModuleInitISystem(m_pFramework->GetISystem(),"CryGame");
   static char pGameBuffer[sizeof(CGame)];
   m_pMod = new ((void*)pGameBuffer) CGame();

   if (m_pMod && m_pMod->Init(m_pFramework))
   {
      return m_modRef;
   }

   return 0;
}

void CGameStartup::Shutdown()
{
   this->~CGameStartup();
}

int CGameStartup::Update(bool haveFocus, unsigned int updateFlags)
{
   // update the game
   if (m_pMod)
   {
      return m_pMod->Update(haveFocus, updateFlags);
   }

   return 0;
}

bool CGameStartup::InitFramework(SSystemInitParams &startupParams)
{
   m_frameworkDll = CryLoadLibrary(GAME_FRAMEWORK_FILENAME);

   if (!m_frameworkDll)
      return false;

   IGameFramework::TEntryFunction CreateGameFramework = (IGameFramework::TEntryFunction)CryGetProcAddress(m_frameworkDll, DLL_INITFUNC_CREATEGAME );

   if (!CreateGameFramework)
      return false;

   m_pFramework = CreateGameFramework();

   if (!m_pFramework)
      return false;

   //Added to start with GameSDK.exe
      if (!startupParams.hWnd)
   {
      m_initWindow = true;

      if (!InitWindow(startupParams))
      {
         // failed to register window class
         CryFatalError("Failed to register CryENGINE window class!");

         return false;
      }
   }
   //end Added to start with GameSDK.exe

   // initialize the engine
   if (!m_pFramework->Init(startupParams))
      return false;

   ModuleInitISystem(m_pFramework->GetISystem(),"CryGame");

   return true;
}

void CGameStartup::ShutdownFramework()
{
   if (m_pFramework)
   {
      m_pFramework->Shutdown();
      m_pFramework = 0;
      CryFreeLibrary(m_pFramework);
   }
}


//Added to start with GameSDK.exe

int CGameStartup::Run( const char * autoStartLevelName )
{

   CryFixedStringT<256> mapCmd ("map TestLevel");
   gEnv->pConsole->ExecuteString(mapCmd.c_str());

   if (!(gEnv && gEnv->pSystem) || (!gEnv->IsEditor() && !gEnv->IsDedicated()))
   {
      ::ShowCursor(TRUE);
   }

   for(;;)
   {
      MSG msg;

      if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
      {
         if (msg.message != WM_QUIT)
         {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
         }
         else
         {
            break;
         }
      }
      else
      {
         if (!Update(true, 0))
         {
            while(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
            {
               TranslateMessage(&msg);
               DispatchMessage(&msg);
            }
            break;
         }
      }
   }


   return 0;
}

LRESULT CALLBACK CGameStartup::WndProcHndl(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
   CGameStartup* self = reinterpret_cast<CGameStartup*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
   return self
      ? self->WndProc(hWnd, msg, wParam, lParam)
      : DefWindowProc(hWnd, msg, wParam, lParam);
}

LRESULT CGameStartup::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
   LRESULT result = 0;

   //Do something with msg

   return result;
}

bool CGameStartup::InitWindow(SSystemInitParams &startupParams)
{
#ifdef WIN32
   WNDCLASS wc;

   memset(&wc, 0, sizeof(WNDCLASS));

   wc.style         = CS_OWNDC | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
   wc.lpfnWndProc   = (WNDPROC)CGameStartup::WndProcHndl;
   wc.cbClsExtra    = 0;
   wc.cbWndExtra    = 0;
   wc.hInstance     = GetModuleHandle(0);
   // FIXME: Very bad way of getting the Icon and Cursor from the Launcher project
   wc.hIcon         = LoadIcon((HINSTANCE)startupParams.hInstance, MAKEINTRESOURCE(101));
   wc.hCursor       = LoadCursor((HINSTANCE)startupParams.hInstance, MAKEINTRESOURCE(105));
   wc.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH);
   wc.lpszMenuName  = 0;
   wc.lpszClassName = GAME_WINDOW_CLASSNAME;

   if (!RegisterClass(&wc))
   {
      return false;
   }

   if (startupParams.pSystem == NULL || (!startupParams.bEditor && !gEnv->IsDedicated()))
      ::ShowCursor(FALSE);

#endif // WIN32
   return true;
}

EditorGame.h

Code: Select all
/*************************************************************************
  Crytek Source File.
  Copyright (C), Crytek Studios, 2001-2004.
-------------------------------------------------------------------------
  $Id$
  $DateTime$
  Description: Implements the Editor->Game communication interface.
 
-------------------------------------------------------------------------
  History:
  - 30:8:2004   11:17 : Created by Márcio Martins

*************************************************************************/
#ifndef __EDITORGAME_H__
#define __EDITORGAME_H__

#if _MSC_VER > 1000
# pragma once
#endif

#include <IGameRef.h>
#include <IEditorGame.h>

class CEditorGame :   public IEditorGame
{
public:
   CEditorGame();
   virtual ~CEditorGame();

   virtual bool Init(ISystem *pSystem,IGameToEditorInterface *pGameToEditorInterface);
    virtual int Update(bool haveFocus, unsigned int updateFlags);
   virtual void Shutdown();
   virtual bool SetGameMode(bool bGameMode);
   virtual IEntity * GetPlayer() { return nullptr; }
   virtual void SetPlayerPosAng(Vec3 pos, Vec3 viewDir) {}
   virtual void HidePlayer(bool bHide) {}
   virtual void OnBeforeLevelLoad() {}
   virtual void OnAfterLevelLoad(const char *levelName, const char *levelFolder) {}
   virtual void OnCloseLevel() {}
   virtual bool BuildEntitySerializationList(XmlNodeRef output) { return true; }
   virtual bool GetAdditionalMinimapData(XmlNodeRef output) { return true; }

   virtual IFlowSystem * GetIFlowSystem() { return m_pGame->GetIGameFramework()->GetIFlowSystem(); }
   virtual IGameTokenSystem* GetIGameTokenSystem() { return m_pGame->GetIGameFramework()->GetIGameTokenSystem(); }
   virtual IEquipmentSystemInterface* GetIEquipmentSystemInterface() { return nullptr; }

   virtual bool SupportsMultiplayerGameRules() { return false; }
   virtual void ToggleMultiplayerGameRules() {}

   virtual void RegisterTelemetryTimelineRenderers(Telemetry::ITelemetryRepository* pRepository) {}

   virtual void OnDisplayRenderUpdated(bool displayHelpers) {}

private:

   IGameRef         m_pGame;
   IGameStartup   *m_pGameStartup;
};

#endif //__EDITORGAME_H__

EditorGame.cpp
Code: Select all
/*************************************************************************
  Crytek Source File.
  Copyright (C), Crytek Studios, 2001-2004.
-------------------------------------------------------------------------
  $Id$
  $DateTime$
 
-------------------------------------------------------------------------
  History:
  - 30:8:2004   11:19 : Created by Márcio Martins

*************************************************************************/
#include "StdAfx.h"
#include "EditorGame.h"
#include "GameStartup.h"

CEditorGame::CEditorGame()
{
   m_pGame = 0;
   m_pGameStartup = 0;
}

CEditorGame::~CEditorGame()
{
}

extern "C"
{
   GAME_API IGameStartup *CreateGameStartup();
};

bool CEditorGame::Init(ISystem *pSystem,IGameToEditorInterface *pGameToEditorInterface)
{
   SSystemInitParams startupParams;
   startupParams.bEditor = true;
   startupParams.pSystem = pSystem;
   startupParams.bExecuteCommandLine = false;

   m_pGameStartup = CreateGameStartup();
   m_pGame = m_pGameStartup->Init(startupParams);

   if (!m_pGame)
   {
      return false;
   }

   m_pGame->GetIGameFramework()->InitEditor(pGameToEditorInterface);

   gEnv->bServer = true;
   gEnv->SetIsClient(true);
   SetGameMode(false);
      
   return true;
}

//------------------------------------------------------------------------
int CEditorGame::Update(bool haveFocus, unsigned int updateFlags)
{
   return m_pGameStartup->Update(haveFocus, updateFlags);
}

//------------------------------------------------------------------------
void CEditorGame::Shutdown()
{
   SetGameMode(false);
   m_pGameStartup->Shutdown();
}

//------------------------------------------------------------------------
bool CEditorGame::SetGameMode(bool bGameMode)
{
      if(gEnv->IsEditor())
         m_pGame->EditorResetGame(bGameMode);

      IGameFramework * pGameFramework = m_pGame->GetIGameFramework();

   return true;
}


If you want to add some 3D content to test this minimal framework, you can uncomment the function "buildWorld()" in Game.h as well as in the Update() function in Game.cpp. Then add these globals to the top of Game.cpp

Code: Select all
bool built = false;
IEntity* myEntity[10];
float angle = 0.0F;
string letterName[10] =
{
   "Objects/props/misc/3dtext/h.cgf",
   "Objects/props/misc/3dtext/e.cgf",
   "Objects/props/misc/3dtext/l.cgf",
   "Objects/props/misc/3dtext/l.cgf",
   "Objects/props/misc/3dtext/o.cgf",
   "Objects/props/misc/3dtext/w.cgf",
   "Objects/props/misc/3dtext/o.cgf",
   "Objects/props/misc/3dtext/r.cgf",
   "Objects/props/misc/3dtext/l.cgf",
   "Objects/props/misc/3dtext/d.cgf"
};

Then uncomment the line "built = false;" in EditorResetGame() add this function to the bottom of the file:
Code: Select all
void CGame::buildWorld()
{
   if (!built) {
      for (int i = 0; i < 10; i++) {
         SEntitySpawnParams sp;
         sp.pClass = gEnv->pEntitySystem->GetClassRegistry()->GetDefaultClass();
         myEntity[i] = gEnv->pEntitySystem->SpawnEntity(sp);
         myEntity[i]->LoadGeometry(0, letterName[i]);
         myEntity[i]->SetScale(Vec3(60, 60, 80));
         myEntity[i]->SetPos(Vec3(500 - i*50.0f, 0, 50));
      }
      built = true;
   }
   else {
      for (int i = 0; i < 10; i++) {
         angle += 0.001;
         Quat rot;
         rot.SetIdentity();
         rot.SetRotationZ(angle);
         myEntity[i]->SetRotation(rot);
      }
   }
}


Here is a screenshot of the rotating 3D text "Hello World" using this bare bones app in CRYENGINE:

HelloWorld.jpg

Have fun, I hope it helps!

Here is Part II

Edit: Added changes to GameStartup to allow the game to start with a launcher (GameSDK.exe), i.e. without the Editor. For now, the level name is hard-coded as "TestLevel" inside the Run() function. So save your level accordingly and don't forget to select "File > Export to Engine" in the Editor.
Last edited by crydevJim on 09.08.2014, 23:44, edited 5 times in total.
User avatar
saberdam
Junior Dev
Junior Dev
 
Posts: 160
Member since: 30.11.2010, 17:20
Likes: 63

Re: Hello World Tutorial - A bare bones game from scratch in

Postby saberdam » 17.03.2014, 17:48

Thank you !
User avatar
IWillByte
Just getting started
Just getting started
 
Posts: 29
Member since: 26.01.2014, 05:53
Likes: 4

Re: Hello World Tutorial - A bare bones game from scratch in

Postby IWillByte » 23.03.2014, 01:25

Thank you so much!!! I have been having an extremely hard time wrapping my head around how things interact. Often I get overwhelmed to the point where I don't work on my game for days. This will really help me learn. :love:

Edit: Getting this compiler error.
1>------ Skipped Build: Project: CryCommon (CryCommon\CryCommon), Configuration: Debug Win32 ------
1>Project not selected to build for this solution configuration
2>------ Skipped Build: Project: CryAction, Configuration: Debug Win32 ------
2>Project not selected to build for this solution configuration
3>------ Build started: Project: CryGameSDK, Configuration: Debug Win32 ------
3> EditorGame.cpp
3> GameStartup.cpp
3>BasicEventListener.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
3> Creating library C:\Neon Newt\Barebones\Code\Solutions\..\..\Bin32\CryGameSDK.lib and object C:\Neon Newt\Barebones\Code\Solutions\..\..\Bin32\CryGameSDK.exp
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual struct IEntity * __thiscall CEditorGame::GetPlayer(void)" (?GetPlayer@CEditorGame@@UAEPAUIEntity@@XZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::SetPlayerPosAng(struct Vec3_tpl<float>,struct Vec3_tpl<float>)" (?SetPlayerPosAng@CEditorGame@@UAEXU?$Vec3_tpl@M@@0@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::HidePlayer(bool)" (?HidePlayer@CEditorGame@@UAEX_N@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::OnBeforeLevelLoad(void)" (?OnBeforeLevelLoad@CEditorGame@@UAEXXZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::OnAfterLevelLoad(char const *,char const *)" (?OnAfterLevelLoad@CEditorGame@@UAEXPBD0@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::OnCloseLevel(void)" (?OnCloseLevel@CEditorGame@@UAEXXZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall CEditorGame::BuildEntitySerializationList(class XmlNodeRef)" (?BuildEntitySerializationList@CEditorGame@@UAE_NVXmlNodeRef@@@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall CEditorGame::GetAdditionalMinimapData(class XmlNodeRef)" (?GetAdditionalMinimapData@CEditorGame@@UAE_NVXmlNodeRef@@@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual struct IFlowSystem * __thiscall CEditorGame::GetIFlowSystem(void)" (?GetIFlowSystem@CEditorGame@@UAEPAUIFlowSystem@@XZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual struct IGameTokenSystem * __thiscall CEditorGame::GetIGameTokenSystem(void)" (?GetIGameTokenSystem@CEditorGame@@UAEPAUIGameTokenSystem@@XZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual struct IEquipmentSystemInterface * __thiscall CEditorGame::GetIEquipmentSystemInterface(void)" (?GetIEquipmentSystemInterface@CEditorGame@@UAEPAUIEquipmentSystemInterface@@XZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::ToggleMultiplayerGameRules(void)" (?ToggleMultiplayerGameRules@CEditorGame@@UAEXXZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::RegisterTelemetryTimelineRenderers(struct Telemetry::ITelemetryRepository *)" (?RegisterTelemetryTimelineRenderers@CEditorGame@@UAEXPAUITelemetryRepository@Telemetry@@@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::OnDisplayRenderUpdated(bool)" (?OnDisplayRenderUpdated@CEditorGame@@UAEX_N@Z)
3>C:\Neon Newt\Barebones\Code\Solutions\..\..\Bin32\CryGameSDK.dll : fatal error LNK1120: 14 unresolved externals
User avatar
crydevJim
Developer
Developer
 
Posts: 337
Member since: 22.06.2013, 21:46
Likes: 210

Re: Hello World Tutorial - A bare bones game from scratch in

Postby crydevJim » 23.03.2014, 11:54

IWillByte wrote:Thank you so much!!! I have been having an extremely hard time wrapping my head around how things interact. Often I get overwhelmed to the point where I don't work on my game for days. This will really help me learn. :love:

Edit: Getting this compiler error.
1>------ Skipped Build: Project: CryCommon (CryCommon\CryCommon), Configuration: Debug Win32 ------
1>Project not selected to build for this solution configuration
2>------ Skipped Build: Project: CryAction, Configuration: Debug Win32 ------
2>Project not selected to build for this solution configuration
3>------ Build started: Project: CryGameSDK, Configuration: Debug Win32 ------
3> EditorGame.cpp
3> GameStartup.cpp
3>BasicEventListener.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
3> Creating library C:\Neon Newt\Barebones\Code\Solutions\..\..\Bin32\CryGameSDK.lib and object C:\Neon Newt\Barebones\Code\Solutions\..\..\Bin32\CryGameSDK.exp
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual struct IEntity * __thiscall CEditorGame::GetPlayer(void)" (?GetPlayer@CEditorGame@@UAEPAUIEntity@@XZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::SetPlayerPosAng(struct Vec3_tpl<float>,struct Vec3_tpl<float>)" (?SetPlayerPosAng@CEditorGame@@UAEXU?$Vec3_tpl@M@@0@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::HidePlayer(bool)" (?HidePlayer@CEditorGame@@UAEX_N@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::OnBeforeLevelLoad(void)" (?OnBeforeLevelLoad@CEditorGame@@UAEXXZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::OnAfterLevelLoad(char const *,char const *)" (?OnAfterLevelLoad@CEditorGame@@UAEXPBD0@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::OnCloseLevel(void)" (?OnCloseLevel@CEditorGame@@UAEXXZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall CEditorGame::BuildEntitySerializationList(class XmlNodeRef)" (?BuildEntitySerializationList@CEditorGame@@UAE_NVXmlNodeRef@@@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall CEditorGame::GetAdditionalMinimapData(class XmlNodeRef)" (?GetAdditionalMinimapData@CEditorGame@@UAE_NVXmlNodeRef@@@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual struct IFlowSystem * __thiscall CEditorGame::GetIFlowSystem(void)" (?GetIFlowSystem@CEditorGame@@UAEPAUIFlowSystem@@XZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual struct IGameTokenSystem * __thiscall CEditorGame::GetIGameTokenSystem(void)" (?GetIGameTokenSystem@CEditorGame@@UAEPAUIGameTokenSystem@@XZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual struct IEquipmentSystemInterface * __thiscall CEditorGame::GetIEquipmentSystemInterface(void)" (?GetIEquipmentSystemInterface@CEditorGame@@UAEPAUIEquipmentSystemInterface@@XZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::ToggleMultiplayerGameRules(void)" (?ToggleMultiplayerGameRules@CEditorGame@@UAEXXZ)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::RegisterTelemetryTimelineRenderers(struct Telemetry::ITelemetryRepository *)" (?RegisterTelemetryTimelineRenderers@CEditorGame@@UAEXPAUITelemetryRepository@Telemetry@@@Z)
3>EditorGame.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CEditorGame::OnDisplayRenderUpdated(bool)" (?OnDisplayRenderUpdated@CEditorGame@@UAEX_N@Z)
3>C:\Neon Newt\Barebones\Code\Solutions\..\..\Bin32\CryGameSDK.dll : fatal error LNK1120: 14 unresolved externals

You're welcome.
I updated the opening post with a screen shot that shows the files that are needed in the Visual Studio solution. Check that you only have those files and remove any others, then rebuild.
User avatar
FruitLoops
Junior Dev
Junior Dev
 
Posts: 143
Member since: 31.01.2014, 17:03
Location: Porsgrunn, Norway
Likes: 53

Re: Hello World Tutorial - A bare bones game from scratch in

Postby FruitLoops » 23.03.2014, 16:49

Thank you for this it be much helpful.
One question that arises when I see this tutorial.
Is if you are making a commercial game is this the way you have to do it?
To avoid any copyright issues?
User avatar
crydevJim
Developer
Developer
 
Posts: 337
Member since: 22.06.2013, 21:46
Likes: 210

Re: Hello World Tutorial - A bare bones game from scratch in

Postby crydevJim » 23.03.2014, 17:25

FruitLoops wrote:Thank you for this it be much helpful.

You're very welcome. :-)

FruitLoops wrote:One question that arises when I see this tutorial.
Is if you are making a commercial game is this the way you have to do it?

I bleieve you could also take the demo game code and modify it. I think that's what it's there for, as a template for how to use the API to do various things.

But on questions like this a CRYTEK staff member would have to provide the official position of course.
User avatar
IWillByte
Just getting started
Just getting started
 
Posts: 29
Member since: 26.01.2014, 05:53
Likes: 4

Re: Hello World Tutorial - A bare bones game from scratch in

Postby IWillByte » 24.03.2014, 22:24

I am able to compile now! Turns out I was missing the brackets and some of the returns for most of the function in EditorGame.h. I loaded my dev level and it looks like everything, including guns, etc, are still there. Is that normal? I though I removed everything but the core C++ files.
User avatar
IWillByte
Just getting started
Just getting started
 
Posts: 29
Member since: 26.01.2014, 05:53
Likes: 4

Re: Hello World Tutorial - A bare bones game from scratch in

Postby IWillByte » 26.03.2014, 07:33

Also, are you going to be making more tutorials using the barebones SDK? I would like to learn how to implement certain things (without the huge amount of inheritance that's in the demo).
User avatar
crydevJim
Developer
Developer
 
Posts: 337
Member since: 22.06.2013, 21:46
Likes: 210

Re: Hello World Tutorial - A bare bones game from scratch in

Postby crydevJim » 26.03.2014, 07:36

IWillByte wrote:Also, are you going to be making more tutorials using the barebones SDK?

Yes, that's the plan.
User avatar
IWillByte
Just getting started
Just getting started
 
Posts: 29
Member since: 26.01.2014, 05:53
Likes: 4

Re: Hello World Tutorial - A bare bones game from scratch in

Postby IWillByte » 26.03.2014, 08:19

crydevJim wrote:
IWillByte wrote:Also, are you going to be making more tutorials using the barebones SDK?

Yes, that's the plan.


Awesome!
User avatar
crydevJim
Developer
Developer
 
Posts: 337
Member since: 22.06.2013, 21:46
Likes: 210

Re: Hello World Tutorial - A bare bones game from scratch in

Postby crydevJim » 26.03.2014, 08:33

IWillByte wrote:I am able to compile now! Turns out I was missing the brackets and some of the returns for most of the function in EditorGame.h. I loaded my dev level and it looks like everything, including guns, etc, are still there. Is that normal? I though I removed everything but the core C++ files.

Well done.

It is normal that you can see meshes in your level. The engine is displaying them for you. And you should be able to use the editor to create and place new geometry and save them as cgf files, using the designer etc. You shouldn't have any custom objects with behaviors however. So no vehicles, boids or other custom Entities, because you didn't provide code for them yet.

So this barebones example shows what the engine and editor do for you even before you write any real game code.
User avatar
thefoofighter
Not my first Rodeo
Not my first Rodeo
 
Posts: 463
Member since: 25.08.2011, 22:20
Location: Deutschland
Likes: 45

Re: Hello World Tutorial - A bare bones game from scratch in

Postby thefoofighter » 26.03.2014, 08:53

Good work Jim keep them coming :)
User avatar
crydevJim
Developer
Developer
 
Posts: 337
Member since: 22.06.2013, 21:46
Likes: 210

Re: Hello World Tutorial - A bare bones game from scratch in

Postby crydevJim » 26.03.2014, 09:03

thefoofighter wrote:Good work Jim keep them coming :)

Thanks! I hope to get some time for this again at the weekend.
User avatar
FruitLoops
Junior Dev
Junior Dev
 
Posts: 143
Member since: 31.01.2014, 17:03
Location: Porsgrunn, Norway
Likes: 53

Re: Hello World Tutorial - A bare bones game from scratch in

Postby FruitLoops » 26.03.2014, 12:59

crydevJim wrote:
thefoofighter wrote:Good work Jim keep them coming :)

Thanks! I hope to get some time for this again at the weekend.

So you will be continuing the tutorial until its a working game ?
Its very intresting thats for sure, thanks again.

Edit: Am trying to figuer out how to get GameSDK.exe to work with this.
Any tips?
Cheers!
User avatar
crydevJim
Developer
Developer
 
Posts: 337
Member since: 22.06.2013, 21:46
Likes: 210

Re: Hello World Tutorial - A bare bones game from scratch in

Postby crydevJim » 26.03.2014, 22:02

FruitLoops wrote:So you will be continuing the tutorial until its a working game ?
Its very intresting thats for sure, thanks again.

Yes, thanks. That's the idea.

FruitLoops wrote:Am trying to figuer out how to get GameSDK.exe to work with this.
Any tips?
Cheers!

Yep, I believe you'll have to implement functions in GameStartup like WndProc(), Run() and ProcessMessage(). You can check that they are called in the demo game with breakpoints when you use GameSDK.exe for your debugging session, but not when you start with Editor.exe.

I was going to come back to that after I get things working from the ground up with the Editor first.


 
Connect and collaborate with CRYENGINE developers in the official Forums.
Visit the Gallery to share what you have created and be inspired by what others are creating with CRYENGINE.
Community