• (3 Pages)
  • +
  • 1
  • 2
  • 3

C++ Tile Engine from Scratch -- Part 1

#31 SergeantBalthazar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 14-March 12

Posted 11 September 2012 - 03:33 PM

View Postfrostraver, on 11 September 2012 - 11:31 AM, said:

View Postfrostraver, on 11 September 2012 - 08:22 PM, said:

Hi,

I'm trying to follow this tutorial to get some more inside in how a game engine works.
But I'm getting this error: Error 1 fatal error C1083: Cannot open include file: 'SFML\Graphics.cpp': No such file or directory

I've done the right steps in the Linker though.

Does anybody know what I may have done wrong?

Thanks in advance


EDIT: changed .cpp to .hpp but it still isn't resolved.
It's just 'SFML\Graphics.h'

View PostSergeantBalthazar, on 11 September 2012 - 03:32 PM, said:

View Postfrostraver, on 11 September 2012 - 11:31 AM, said:

View Postfrostraver, on 11 September 2012 - 08:22 PM, said:

Hi,

I'm trying to follow this tutorial to get some more inside in how a game engine works.
But I'm getting this error: Error 1 fatal error C1083: Cannot open include file: 'SFML\Graphics.cpp': No such file or directory

I've done the right steps in the Linker though.

Does anybody know what I may have done wrong?

Thanks in advance


EDIT: changed .cpp to .hpp but it still isn't resolved.
It's just 'SFML\Graphics.h'
Wait, no it's .hpp Sorry, it's been a while ^_^
Was This Post Helpful? 0
  • +
  • -

#32 Delacar  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 31-July 12

Posted 25 November 2012 - 01:14 PM



I was wondering why there is not the sfml audio libraries in this tutorial, I mean just being able to have graphics for me is great but wouldn't sound along side graphics be better?
Was This Post Helpful? 0
  • +
  • -

#33 Delacar  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 31-July 12

Posted 25 November 2012 - 01:31 PM



I'm just curious as to way you use dynamic libraries and not static ones? Also I have been trying for the past 2 months to get sfml to work and have finally found a tutorial that got sfml to work for me, but in the tutorial they use a static library. So I was wondering if dynamic libraries could be switched with static libraries and still get the desired results? Please respond back promptly if at all possible. Thank you for your time, and have wonderful Holidays.
Was This Post Helpful? 0
  • +
  • -

#34 MechZoneProductions  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-June 09

Posted 22 December 2012 - 04:45 PM

------ Build started: Project: noobgame1, Configuration: Debug Win32 ------
main.cpp
c:\documents and settings\work computer 2\my documents\visual studio 2010\projects\noobgame1\noobgame1\main.cpp(10): error C2039: 'Go' : is not a member of 'Engine'
c:\documents and settings\work computer 2\my documents\visual studio 2010\projects\noobgame1\noobgame1\engine.h(6) : see declaration of 'Engine'
c:\documents and settings\work computer 2\my documents\visual studio 2010\projects\noobgame1\noobgame1\main.cpp(14): error C2065: 'MB_IConerror' : undeclared identifier
Engine.cpp
c:\documents and settings\work computer 2\my documents\visual studio 2010\projects\noobgame1\noobgame1\engine.cpp(34): error C2039: 'PollEvent' : is not a member of 'sf::RenderWindow'
c:\program files\microsoft visual studio 10.0\vc\include\sfml\graphics\renderwindow.hpp(45) : see declaration of 'sf::RenderWindow'
c:\documents and settings\work computer 2\my documents\visual studio 2010\projects\noobgame1\noobgame1\engine.cpp(34): fatal error C1903: unable to recover from previous error(s); stopping compilation
Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This is the problem I'm getting, can someone tell me what I'm doing wrong and what possible solutions i could do to fix this issue?
Was This Post Helpful? 0
  • +
  • -

#35 MechZoneProductions  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-June 09

Posted 22 December 2012 - 06:25 PM

View PostMechZoneProductions, on 22 December 2012 - 04:45 PM, said:

------ Build started: Project: noobgame1, Configuration: Debug Win32 ------
main.cpp
c:\documents and settings\work computer 2\my documents\visual studio 2010\projects\noobgame1\noobgame1\main.cpp(10): error C2039: 'Go' : is not a member of 'Engine'
c:\documents and settings\work computer 2\my documents\visual studio 2010\projects\noobgame1\noobgame1\engine.h(6) : see declaration of 'Engine'
c:\documents and settings\work computer 2\my documents\visual studio 2010\projects\noobgame1\noobgame1\main.cpp(14): error C2065: 'MB_IConerror' : undeclared identifier
Engine.cpp
c:\documents and settings\work computer 2\my documents\visual studio 2010\projects\noobgame1\noobgame1\engine.cpp(34): error C2039: 'PollEvent' : is not a member of 'sf::RenderWindow'
c:\program files\microsoft visual studio 10.0\vc\include\sfml\graphics\renderwindow.hpp(45) : see declaration of 'sf::RenderWindow'
c:\documents and settings\work computer 2\my documents\visual studio 2010\projects\noobgame1\noobgame1\engine.cpp(34): fatal error C1903: unable to recover from previous error(s); stopping compilation
Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This is the problem I'm getting, can someone tell me what I'm doing wrong and what possible solutions i could do to fix this issue?


Alright, i have the overhead error corrected. However, I'm faced with a new problem. And thats this.

------ Build started: Project: noobgame1, Configuration: Debug Win32 ------
main.cpp
Engine.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (??0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z) referenced in function "private: bool __thiscall Engine::Init(void)" (?Init@Engine@@AAE_NXZ)
Engine.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z) referenced in function "private: bool __thiscall Engine::Init(void)" (?Init@Engine@@AAE_NXZ)
Engine.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::Close(void)" (?Close@Window@sf@@QAEXXZ) referenced in function "private: void __thiscall Engine::ProcessInput(void)" (?ProcessInput@Engine@@AAEXXZ)
Engine.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::GetEvent(class sf::Event &)" (?GetEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function "private: void __thiscall Engine::ProcessInput(void)" (?ProcessInput@Engine@@AAEXXZ)
Engine.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::IsOpened(void)const " (?IsOpened@Window@sf@@QBE_NXZ) referenced in function "private: void __thiscall Engine::MainLoop(void)" (?MainLoop@Engine@@AAEXXZ)
c:\documents and settings\work computer 2\my documents\visual studio 2010\Projects\noobgame1\Debug\noobgame1.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This is the code.

Engine.h
#ifndef _ENGINE_H
#define _ENGINE_H
#include<SFML\Graphics.hpp>

class Engine
{
private:
//SFML Render Window
sf::RenderWindow* window;
//Initializes the engine
bool Init();
//Main Game Loop
void MainLoop();
//Renders One Frame
void RenderFrame();
//Processes user input
void ProcessInput();
//Updates all Engine internals
void Update();

	public:
	Engine();
	~Engine();

	void go();
	};
	#endif



Engine.cpp
//Dead man walking 2D game engine 
//Prototype 1 "0.0.0.1"
#include "Engine.h"
#include <SFML/Graphics.hpp>

Engine::Engine()
{

	}

Engine::~Engine()
{

	}

bool Engine::Init()
{

	window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "RPG");
	if(!window)
		return false;
			return true;
}

void Engine::RenderFrame()
{

	}

void Engine::ProcessInput()
{
	sf::Event evt;
		//loop through all window events
		while(window->GetEvent(evt))
{
	if(evt.Type == sf::Event::Closed)
		window->Close();
	}
}

void Engine::Update()
{

	}

void Engine::MainLoop()
{
	//Loop untill our window is closed
		while(window->IsOpened())
{
	ProcessInput();
		Update();
		RenderFrame();
	}
}

void Engine::go()
{
	if(!Init())
		throw "Hey buddy, somethings wrong with me. Fix it!\n";
		MainLoop();
}


Main.cpp
#include <Windows.h>
#include "Engine.h"

	int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR 
	pCmdLine, int nCmdShow)
	{
		Engine* engine = new Engine();
		
		try
			{
			engine->go();
				}
				catch(char* e)
			{
			MessageBoxA(NULL, e, "Exception Occured", MB_OK | MB_IConerror);
		}
	}


So now im left with the question, what am i doing wrong now?
Was This Post Helpful? 0
  • +
  • -

#36 AliceLiddell  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-January 13

Posted 09 January 2013 - 04:57 PM

This is a really great tutorial I was recommended by a fellow game designer.

there are a couple typos in your code though, and if I hadn't known C++ so well I would've given up.

Firstly, you never declare a variable with a capitol letter, ever.

Engine.cpp fixed

#include "Engine.h"
#include <SFML\Graphics.hpp>

Engine::Engine()
{

}

Engine::~Engine()
{

}

bool Engine::Init()
{
	window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "RPG");

	if(!window)
		return false;

	return true;
}

void Engine::RenderFrame()
{

}

void Engine::ProcessInput()
{
	sf::Event evt;
	//Loop through all window events
	while(window->pollEvent(evt))
	{
		if(evt.type == sf::Event::Closed)
			window->close();
	}
}

void Engine::Update()
{

}

void Engine::MainLoop()
{
	//Loop until our window is closed
	while(window->isOpen())
	{
		ProcessInput();
		Update();
		RenderFrame();
	}
}

void Engine::Go()
{
	if(!Init())
		throw "Could not initialize Engine";

	MainLoop();
}




Engine.h didn't need any changes but

Main.cpp corrected
#include <Windows.h>

#include "Engine.h"

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
	Engine* engine = new Engine();

	try
	{
		engine->Go();
	}
	catch(char* e)
	{
		MessageBoxA(NULL, e, "Exception Occured", MB_OK | MB_IConerror);
	}
}



MessageBoxA had the wrong parameters, you have to change the last parameter to "MB_IConerror" the first part of the lesson wont compile unless you change those two files. You surely out did yourself making this but just remember a lot of beginner programmers want to read your tutorial, and I recall a few times never being able to get this tutorial to work a while back, its just one of those errors you should correct, and go look over everything else after.
Was This Post Helpful? 0
  • +
  • -

#37 vcjr  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 7
  • Joined: 20-September 08

Posted 31 December 2013 - 02:08 PM

Hey there, most of the code the guy wrote I guess outdated. I'm currently using SFML 2.1 and Visual 2013. I've been doing sfml work for a bit now. But I keep getting errors that I can't seem to find solutions to when looking at them over.

Engine.h
#ifndef _ENGINE_H
#define _ENGINE_H

#include <SFML\Graphics.hpp>

class Engine
{
private:
	//SFML Render Window
	sf::RenderWindow* window;

	//Initialize the Engine
	bool Init();

	//Main Game Loop
	void MainLoop();

	//Renders One Frame
	void RenderFrame();

	//Process user Inout
	void ProcessInput();

	//Update all Engine Internals
	void Update();

public:
	Engine();
	~Engine();

	void Go();					//////Starts the Engine
};

#endif



Engine.cpp
#include "Engine.h"
#include <SFML\Graphics.hpp>

Engine::Engine()
{

}

Engine::~Engine()
{

}

bool Engine::Init()
{
	window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "RGP");

	if (!window)
		return false;

	return true;
}

void Engine::RenderFrame()
{

}

void Engine::ProcessInput()
{
	sf::Event evt;
	    //Loop through all window events
	    while (window.pollEvent(evt))
	   {
		        if (evt.type == sf::Event::Closed)
			            window.close();
	    }

}

void Engine::Update()
{

}

void Engine::MainLoop()
{
	//Loop until our Window is closed
	while (window.isOpen())
	{
		ProcessInput();
		Update();
		RenderFrame();
	}
}

void Engine::Go()
{
	if (!Init())
		throw "Could not Initialize Engine";

	MainLoop();
}



Main.cpp

#include <Windows.h>

#include "Engine.h"

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
	Engine* engine = new Engine();

	try
	{
		engine->Go();
	}
	catch (char* e)
	{
		MessageBoxA(NULL, e, "Exception Occured", MB_OK | MB_IConerror);
	}
}



This is are the Errors I get
	5	IntelliSense: identifier "MB_IConerror" is undefined	c:\Users\Vcjr\Documents\Visual Studio 2013\Projects\TileEngine\TileEngine\Main.cpp	25	53	TileEngine
Error	2	error C2660: 'MessageBoxA' : function does not take 3 arguments	c:\users\vcjr\documents\visual studio 2013\projects\tileengine\tileengine\main.cpp	25	1	TileEngine
Error	3	error C2228: left of '.pollEvent' must have class/struct/union	c:\users\vcjr\documents\visual studio 2013\projects\tileengine\tileengine\engine.cpp	33	1	TileEngine
Error	1	error C2065: 'MB_IConerror' : undeclared identifier	c:\users\vcjr\documents\visual studio 2013\projects\tileengine\tileengine\main.cpp	25	1	TileEngine
Error	4	error C1903: unable to recover from previous error(s); stopping compilation	c:\users\vcjr\documents\visual studio 2013\projects\tileengine\tileengine\engine.cpp	33	1	TileEngine




Here the Build
1>------ Build started: Project: TileEngine, Configuration: Debug Win32 ------
1>  Main.cpp
1>c:\users\vcjr\documents\visual studio 2013\projects\tileengine\tileengine\main.cpp(25): error C2065: 'MB_IConerror' : undeclared identifier
1>c:\users\vcjr\documents\visual studio 2013\projects\tileengine\tileengine\main.cpp(25): error C2660: 'MessageBoxA' : function does not take 3 arguments
1>  Engine.cpp
1>c:\users\vcjr\documents\visual studio 2013\projects\tileengine\tileengine\engine.cpp(33): error C2228: left of '.pollEvent' must have class/struct/union
1>          type is 'sf::RenderWindow *'
1>          did you intend to use '->' instead?
1>c:\users\vcjr\documents\visual studio 2013\projects\tileengine\tileengine\engine.cpp(33): fatal error C1903: unable to recover from previous error(s); stopping compilation
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3