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.


Member Since 04 Jan 2013
Offline Last Active Private

#5193681 [4X / TBS] Diplomacy...

Posted by wintertime on 19 November 2014 - 03:22 PM

In Alpha Centauri you could send a unit into some other players territory, who then gets the option to ask you for retreat for violating his territory, and then you get the option to accept and get the unit teleported back or have a vendetta started. I think thats a good mechanism to prevent "peaceful" invasions blocking someones territory with the only options of staying eternally annoyed at it or having the role of agressor attached to you, when the other party actually started this and then possibly the senate denying you even that when your state was a republic in Civilization.

#5192962 Proper C++ header file?

Posted by wintertime on 15 November 2014 - 04:36 AM

For a proper header file you should not include a bunch of files you do not need. Only add them if you cant forward declare a class and prefer having the include in the cpp file, but minimize these, too.

And use descriptive names where you dont need to guess if, for example, loc is location (cant be, a string location is weird?), lines of code(uhh no, why?) or something else.

It would be good to learn about how to use const references and the constructor initializer list, to see how these prevent useless copying.

Try following the "tell, dont ask" principle and only add get/set methods if you cant replace them by methods that do the real work inside the class. The remaining one-line-methods could then be put into the header so they can be inlined.

#5192839 Live filesystem changes

Posted by wintertime on 14 November 2014 - 07:14 AM

Just get an account on https://bitbucket.org/ and make a repository! You can have unlimited free private and public repositories and choose between git and Mercurial.

If you dont change the same file at same time a merge is mostly going automatically anyway and much safer than you both constantly having to endure a broken build as the other is typing in more code that gets synchronized too early.

#5191658 Novice C++ programmer, looking for ways to create art for game and such

Posted by wintertime on 07 November 2014 - 07:09 AM

This guy does some decent tutorials, its all vector graphics, pretty much focused towards programmers smile.png



This is what I thought of telling, too. He got so many nice tutorials on http://2dgameartforprogrammers.blogspot.de/ and I think its much easier to create something good looking using a tool for making vector graphics ( Inkscape ) compared to tediously doing pixel graphics by hand-choosing colors for single pixels.

#5189080 a problem with opengl and glfw

Posted by wintertime on 25 October 2014 - 08:54 AM

Put -lopengl32 last, not first, because the linker does not know other libraries depend on it before having worked on these.

Also it would be better to not use glu, its outdated and there are better ways of setting the projection and getting mipmaps made.

And you should order the constructor initializer list in the same way as the class members, fix the bug with the access to the uninitialized variable and fix the setting thats not recognized.

#5188297 Reading PNG format (deflate compression)

Posted by wintertime on 21 October 2014 - 06:38 AM

I think you would learn more about png image format (as compared to deflate compression) if you just use zlib and concentrate on the other bits of the format at first. Later you can always add on your own deflate decoder, after being able to decode all png chunks including all registered ancillary chunks.

#5188217 C++ Serialize OpengGL pixel data in bitmap formatted byte array

Posted by wintertime on 20 October 2014 - 06:26 PM

Looks like you read the pixels as RGB although .bmp is in BGR, which you could get from OpenGL, too.

#5184945 Questions on first Win32 windows application

Posted by wintertime on 04 October 2014 - 08:02 AM

1. That stems from their confused sense of Unicode and a wrong thinking of needing to keep compatibility with ASCII.

Read http://utf8everywhere.org/ on how to better handle this!

2. Sometimes its needed as a function parameter, but there is also another function to retrieve it if you dont have it.

3. Its a callback you provide, only the function address matters and you can choose any name you like for it. Under some circumstances it may be even useful to have more than one.

4. There are a countless number of messages that get put into a queue, which you there retrieve with GetMessage and pass along to Dispatchmessage, which internally calls your callback function. When clicking the x all kinds of mouse messages get through first and then when the click is confirmed you get a WM_CLOSE, to which the typical response is calling DestroyWindow, which sends the WM_DESTROY and there you call PostQuitMessage, which sends WM_QUIT, which should make your message loop exit from a special return value from GetMessage. Its all pretty complicated and thats why most messages you are not interested in are forwarded to DefWindowProc, which is like your window procedure, but premade for default handling.

5. You cant just add a magic number to a (hidden) pointer and expect the program to still work. Read up on what alternative values you can provide to change it.

#5171148 Need Help with amortization formula

Posted by wintertime on 02 August 2014 - 12:01 PM

Why dont you ask your teacher (thats his job) how function parameters work, how return values are used, how to find descriptive variable names and how to translate a formula into a C++ function?

#5170281 Setting up GLFW in Code::Blocks

Posted by wintertime on 30 July 2014 - 05:27 AM

Why didn't you read http://www.glfw.org/docs/latest/build.html ? You need to correctly link all dependencies and you should not link both the static and the dll version of the GLFW library at same time.

And you better use the -l option for adding a library: https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Link-Options.html#Link-Options

#5168040 In need of some architecture help

Posted by wintertime on 20 July 2014 - 05:44 PM

You can let windows remember some data for you that you can retrieve inside the window procedure and cast back to the type of your window class.


#5140629 Exactly what's the point of 'int32_t', etc.

Posted by wintertime on 20 March 2014 - 06:13 AM

 No really, they specified they are in twos complement, but the problem is the few types that applies to are optional: Exact-width integer types
1 The typedef name intN_t designates a signed integer type with width N, no padding
bits, and a two’s complement representation. Thus, int8_t denotes a signed integer
type with a width of exactly 8 bits.
2 The typedef name uintN_t designates an unsigned integer type with width N. Thus,
uint24_t denotes an unsigned integer type with a width of exactly 24 bits.
3 These types are optional. However, if an implementation provides integer types with
widths of 8, 16, 32, or 64 bits, it shall define the corresponding typedef names.

It would be nice if they just specified everything had to be twos complement and maybe even little endian, but they are supporting ones complement, sign-magnitude and big endian and keep a huge number of things undefined. Hopefully someday computers running ones complement, sign-magnitude or big endian need not be considered anymore.

#5140139 Exactly what's the point of 'int32_t', etc.

Posted by wintertime on 18 March 2014 - 04:53 PM

I think the standards committee finally realized it was foolish to not make all types fixed size in the first place, because most libraries included Rube Goldberg Contraptions using the preprocessor to derive from a million compiler and platform specific defines its own incompatible version of fixed size types that end up being not the same size sometimes. Though in its extreme pursuit for compatibility they couldn't get themselves to just say short/int/long/long long are now always 16/32/64/128 bits, but had to add a few dozen new types. And the most useful fixed size versions are not guaranteed to be there, only the fast and least versions that are near useless, so people will still not use them and can enjoy using 100 types per program for a few decades longer. rolleyes.gif

#5139311 Need help: a vector of different extended classes

Posted by wintertime on 15 March 2014 - 03:45 PM

Contrary to what the other people said, the simplest solution is to not throw all entities into one vector only to later having to check their type through virtual calls.

The point of templates is that they know the exact type:

vector<EntityArrow> arrows;

Btw., if you create a large hierarchy of classes derived from Entity you'll probably discover later that it leads to problems. You'll be tempted to duplicate some aspects or move unrelated things up in the hierarchy where they not belong, because not all objects can be categorized into a regular tree. Better to avoid that from beginning and use composition instead of inheritance.

#5139306 How to efficiently divide files up?

Posted by wintertime on 15 March 2014 - 02:42 PM

You can download LibreOffice Calc for free and use that, no need to use Excel. I think the easiest format to read in a simple table is csv, no need for xml in that case.