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

C++ Tile Engine from Scratch -- Part 4

#31 SergeantBalthazar  Icon User is offline

  • New D.I.C Head

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

Posted 14 August 2012 - 08:40 AM

Does anyone know when part 5 will be up?
Was This Post Helpful? 0
  • +
  • -

#32 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13493
  • View blog
  • Posts: 53,899
  • Joined: 12-June 08

Posted 14 August 2012 - 08:44 AM

Being the OP hasn't been on since Apr 29 2012, I am going to guess "a while". ;)

You could always write up a tutorial to fill in after this one!
Was This Post Helpful? 0
  • +
  • -

#33 SergeantBalthazar  Icon User is offline

  • New D.I.C Head

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

Posted 14 August 2012 - 09:00 AM

Well, I do have somewhat of an "meh" idea on how to animate sprites, but more than likely, with my skills in programming, it wouldn't work :L
Was This Post Helpful? 0
  • +
  • -

#34 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1361
  • View blog
  • Posts: 3,534
  • Joined: 03-May 10

Posted 14 August 2012 - 09:06 AM

A great way to sharpen your skills is to work on things and try out different approaches and see what works. Every program you fail to write is a learning experience that will help teach you the proper way to do things.
Was This Post Helpful? 0
  • +
  • -

#35 SergeantBalthazar  Icon User is offline

  • New D.I.C Head

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

Posted 14 August 2012 - 09:19 AM

That's true. But it's just, I really don't know another approach. Maybe I should learn a bit more before I try to work on that bit.
Was This Post Helpful? 0
  • +
  • -

#36 Wian_Qid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 30-June 12

Posted 20 August 2012 - 02:55 AM

Sir, I'm sorry for being rude...

Could I gave you suggestion?

Hm, why don't you make the books..
I mean, so we all can read them, also more comfortable to concentrate and finish your tutorial...
Afterwards if there's any error, we would love to ask you by email or in this forums...

I'm sorry if I troubled you guys so much..
Btw, Thanks in advance..
Was This Post Helpful? 0
  • +
  • -

#37 Belthazor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-September 12

Posted 18 September 2012 - 08:06 AM

Hey guys,

First great tutorial i just hoped you had added your version of the SFML 2.0 it would have made this tutorial much easier.

The SFML 2.0 is updated and that makes this tutorial harder to understand but after hours and more hours and even more hours i finally fixed every thing and when i tried to run my code i get this nasty error.

Unhandled exception at 0x755cd36f in 2DGameEngine.exe: Microsoft C++ exception: std::basic_string<char,std::char_traits<char>,std::allocator<char> > at memory location 0x0023f728..



I leaded to Level.cpp Function
void Level::LoadLevel(std::string filename, ImageManager& imageManager)

and when you press continue instead of break then you get this error

Unhandled exception at 0x0138bef1 in 2D Game.exe: 0xC0000005: Access violation reading location 0x00000020.


and it leads to rapidxml.hpp
xml_attribute<Ch> *first_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const
        {
            if (name)
            {
                if (name_size == 0)
                    name_size = internal::measure(name);
                for (xml_attribute<Ch> *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute)
                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))
                        return attribute;
                return 0;
            }
            else
                return m_first_attribute;
        }



Could any one please help me out i don't want that many hours to be wasted.

Thanks in advanced
Was This Post Helpful? 0
  • +
  • -

#38 adomas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-February 13

Posted 11 February 2013 - 11:12 AM

Error	1	error C2039: 'SetImage' : is not a member of 'sf::Sprite'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\tile.cpp	6	1	Project1
Error	2	error C2039: 'SetPosition' : is not a member of 'sf::Sprite'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\tile.cpp	16	1	Project1
Error	3	error C2039: 'Draw' : is not a member of 'sf::RenderWindow'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\tile.cpp	17	1	Project1
Error	4	error C2039: 'LoadFromFile' : is not a member of 'sf::Image'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\imagemanager.cpp	75	1	Project1
Error	5	error C2039: 'Create' : is not a member of 'sf::Image'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\imagemanager.cpp	89	1	Project1
Error	6	error C2039: 'Copy' : is not a member of 'sf::Image'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\imagemanager.cpp	90	1	Project1
Error	7	error C2039: 'Clear' : is not a member of 'sf::RenderWindow'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	42	1	Project1
Error	8	error C2039: 'Top' : is not a member of 'sf::Rect<T>'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	55	1	Project1
Error	9	error C2039: 'Height' : is not a member of 'sf::Rect<T>'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	55	1	Project1
Error	10	error C2039: 'Left' : is not a member of 'sf::Rect<T>'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	57	1	Project1
Error	11	error C2039: 'Width' : is not a member of 'sf::Rect<T>'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	57	1	Project1
Error	12	error C2039: 'Display' : is not a member of 'sf::RenderWindow'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	67	1	Project1
Error	13	error C2039: 'PollEvent' : is not a member of 'sf::RenderWindow'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	74	1	Project1
Error	14	error C1903: unable to recover from previous error(s); stopping compilation	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	74	1	Project1



I have got these errors. Maybe someone know how to fix them?
Was This Post Helpful? 0
  • +
  • -

#39 supereq  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 29-May 13

Posted 29 May 2013 - 03:23 PM

View Postadomas, on 11 February 2013 - 11:12 AM, said:

Error	1	error C2039: 'SetImage' : is not a member of 'sf::Sprite'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\tile.cpp	6	1	Project1
Error	2	error C2039: 'SetPosition' : is not a member of 'sf::Sprite'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\tile.cpp	16	1	Project1
Error	3	error C2039: 'Draw' : is not a member of 'sf::RenderWindow'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\tile.cpp	17	1	Project1
Error	4	error C2039: 'LoadFromFile' : is not a member of 'sf::Image'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\imagemanager.cpp	75	1	Project1
Error	5	error C2039: 'Create' : is not a member of 'sf::Image'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\imagemanager.cpp	89	1	Project1
Error	6	error C2039: 'Copy' : is not a member of 'sf::Image'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\imagemanager.cpp	90	1	Project1
Error	7	error C2039: 'Clear' : is not a member of 'sf::RenderWindow'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	42	1	Project1
Error	8	error C2039: 'Top' : is not a member of 'sf::Rect<T>'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	55	1	Project1
Error	9	error C2039: 'Height' : is not a member of 'sf::Rect<T>'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	55	1	Project1
Error	10	error C2039: 'Left' : is not a member of 'sf::Rect<T>'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	57	1	Project1
Error	11	error C2039: 'Width' : is not a member of 'sf::Rect<T>'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	57	1	Project1
Error	12	error C2039: 'Display' : is not a member of 'sf::RenderWindow'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	67	1	Project1
Error	13	error C2039: 'PollEvent' : is not a member of 'sf::RenderWindow'	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	74	1	Project1
Error	14	error C1903: unable to recover from previous error(s); stopping compilation	c:\users\adomas\desktop\tileenginetutorialpart4source (1)\engine.cpp	74	1	Project1



I have got these errors. Maybe someone know how to fix them?


This might be a bit late but you are probably using a newer version of SFML which has a different capitalization structure try making the first letter of each call lowercase, also your going to be having trouble with the imagemanager class as you need to create a texture from the image file then load a sprite from that. This is why you are getting the error that Sprite has no member called setImage(). I'm actually in the process of working on this right now. Good luck
Was This Post Helpful? 0
  • +
  • -

#40 smhoff  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-October 13

Posted 14 October 2013 - 12:01 PM

This might be a bit late, but I'd guess it's saying it can't find the xml file to parse.
Was This Post Helpful? 0
  • +
  • -

#41 janitar1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 29-October 13

Posted 29 October 2013 - 10:20 PM

Hey, skimming over this years later and find this all very helpful. Im having issues implementing a moving object (player class) to the engine though, would anyone have some tips or pointers on how to do so?
Was This Post Helpful? 0
  • +
  • -

#42 razezar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-October 17

Posted 15 October 2017 - 02:11 AM

Hi, first time poster here.

I'm not sure what the interest level is in this Tile Engine tutorial these days, but in any case I've done a bit of tweaking around with this engine to get it working as was originally intended in Part 4. The necessary changes have been made to suit the more recent iteration of SFML (2.4) . The IDE that I am using is Visual Studio 2017.

If anyone expresses any interest to see my version of the code, I can post it here. In the meantime, here are a few key factors that make it work, as have mostly already been discussed in the comments of this series :

- Use the author (RevTorA)'s source code links as a more accurate guide to a successful engine build, as opposed to the in-post code excerpts as they omit crucial pieces of code & amendments. Especially if you are similar to me and not a seasoned C++ programmer / dabbling in programming again after a very long hiatus.

- Note the necessary changes to the case of variable names within objects, as the compiler is case-sensitive. In these examples many start with an upper-case letter, but they need to start in lower-case to be recognised by the compiler.

- Changes will need to be made to some of the SFML calls, in particular changing *most* usage of the Image class into the Texture class.

However, I found the image class still of use upon initial loading of the tileset image file, then sending the tiles into a texture class.


- For the purposes of this simple tile engine, running the code without deleting 'new' objects on the heap works fine. I'm assuming that this is because there is only one instance of each heap object upon any execution of this bare-bones engine.

However, In the attempt to both To 'future-proof' this engine and follow good programming practice, I have followed others' lead and inserted object deletes in both the Engine deconstructor, and for the engine object itself in 'main' following the engine->Go line.


A future consideration for this engine could be smart pointers / automatic de-allocation of heap memory (something I'm yet to personally dabble in).


If anyone has taken this engine foundation further and implemented features such as a controllable character & NPC's, collisions, event scripting etc. it would be interesting to see.

The author never went any further than Part 4 and does not appear to have been on the scene here for a long time, but if you're reading this: Thanks for a very helpful series. Here's to the coders who have or will attempt to take the code further...
Was This Post Helpful? 0
  • +
  • -

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