Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Servant of the Lord

Member Since 24 Sep 2005
Offline Last Active Yesterday, 08:19 PM

Posts I've Made

In Topic: Constructors, Factory Methods and Destructor Questions

Yesterday, 04:38 PM

 

Another downside to be aware of though, is when you use a complex constructor (and no default constructor), you're limiting your class from being usable in some places, e.g. std::vector will no longer work (but std::vector will).

*>
That's not true.  The only requirement for use in std::vector is that a type is assignable and copyable (and in modern C++, those restrictions are relaxed to simply movable), neither of which requires a default constructor.

 


Some containers do have member functions that use default-constructed values as default-parameters.

 

std::vector<MyType> myVector(50), for example. Default-constructs 50 elements. You have to call std::vector<MyType> myVector(50, <some value to copy from>) if you don't have a default constructor.

 

And if you don't have a default constructor OR a copy-constructor, then you can't call resize() (or the resizing std::vector constructors). In that case, you'll have to just call push_back(std::move(value)) or emplace_back(construction params), probably after calling reserve() first.

 

Not show-stopping, but something you have to work around. It's not very convenient when some of the convenience functions are unusable. smile.png


In Topic: Advice for simple 2D game

Yesterday, 02:50 PM

Error    1    error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup    C:\documents\visual studio 2013\Projects\sfml 2.0\sfml 2.0\MSVCRTD.lib(crtexew.obj)
Error    2    error LNK1120: 1 unresolved externals    C:\documents\visual studio 2013\Projects\sfml 2.0\Debug\sfml 2.0.exe


Did you add a function called int main(int argc, char *argv[]) to your code?

I know i atleast included SFML_STATIC in the C++ Preprocessor that many seem to miss.


SFML_STATIC is only supposed to be included in certain circumstances. If it was something that is always included, it'd be included for you automatically. But it's an option, so it's up to the programmer to know when it is correct to use it.

You only use SFML_STATIC if you compile and link against SFML statically. Did you tell CMake to BUILD_SHARED_LIBS? If so, then you can't use SFML_STATIC.

Where and how are you defining SFML_STATIC?

In Topic: Optimizing 2D Tile Map

25 November 2014 - 08:38 PM

Servant of the Lord, yes, they are text files, although by using Boost, switching to binary is very simple.

 

Hold on a second. I don't mean just switching from Load(MyTextFile, AsText) to  Load(MyTextFile, AsBinary). It's still a text file (even if you save it as "binary").

 

I mean rewriting your file format entirely, so nothing is stored in strings, and things are stored directly as integers and bools and whatnot.

I don't mean saving it as an integer stored as a string saved as a 'binary' file. I mean zero conversion from strings to integers.

 

It's almost certainly the string parsing that is killing your load times. dry.png

 

If you have hundreds of files you're trying to load at once, it's probably the hard drive overhead for each file. But if you have a map stored in a single file, and that single file is taking a long time to load, you need to redesign your file format, not just swap out one function call for another. You need to write it so you don't have to process the loaded data (converting strings to ints or whatever). Load it already in a suitable format.

 

Compression is likely not the issue. Databases are likely not the solution.

 

170KB? Not a problem. A single photograph can be several MB (ten times your map file, and that's with compression), but ten year old computers can open them nigh-instantaneously. smile.png

 

Post your map-loading function.


In Topic: The "action" systems that 2D game frameworks all now have...

25 November 2014 - 07:13 PM

Are you seriously saying that that is not common? 

That's how I like to do it. However, Qt, being a desktop application GUI toolkit, wants to control the main messaging loop for me, so I have to write my code to react in response to callbacks. Not too much of a hassle, since I still have React(), Update(), Draw(). Having dozens of different callbacks that I'd need to react to would be annoying, depending on how high-level the API is.


In Topic: Optimizing 2D Tile Map

24 November 2014 - 10:12 PM

Load speeds mostly come down to how your file format is laid out, and the amount of content being loaded.

 

What do your map files look like? Are they text files? If so, you can pretty much get an instant speedboost by using binary files instead.


PARTNERS