# Jolle

Member

205

178 Neutral

• Rank
Member
1. ## Better card shuffling routine

I think I've heard that "rand() * DeckCount / RAND_MAX" gives statistically better results than "rand() % DeckCount", and as above said, just srand once.
2. ## how can i parsed command line...?

Check http://www.wischik.com/scr/howtoscr.html, it has a part about the parsing (although it's ugly). Google is your friend.
3. ## how to set rendertarget to texture map?

I've heard that the easiest way if you want mutlisampling, just draw to the main backbuffer and copy it.
4. ## what is the name of this problem (if it exists)

It may look like trivial recursion, but it seems it isn't. Anyway I didn't find the trivial stuff about it, but I manage to write some Haskell code that solves the problem. Maybe I missed some vital trick that makes it much easier, I dunno. f 0 = [[]] f n = concat [[x : z | z <- f (n - x), z == [] || head z <= x] | x <- [n, n - 1 .. 1]] stylish = putStr . unlines . map (init . tail . show) . f Main> stylish 5 5 4,1 3,2 3,1,1 2,2,1 2,1,1,1 1,1,1,1,1 (zeroes not included, it didn't make any sense)
5. ## random number

As said by many people already, you should only call srand once. The code you show above calls it for every random number you generate.
6. ## Easy word wrapping? [Mostly Solved]

Here's some code I used in an old app. It uses a lot of bad things, but the basic word wrap technique isn't very bad. (And yeah, you don't spell length that way) char** WrapLine(char* str, int w) { static char* lines[16]; int currentLine = 0; int place = 0; while (str[place] != 0) { int lenght = w / FONTW; if (strlen(&str[place]) < lenght) lenght = strlen(&str[place]); else { while (str[place + lenght] != ' ' && lenght != 0) lenght--; if (lenght == 0) lenght = w / FONTW; } lines[currentLine] = new char[lenght + 1]; memcpy(lines[currentLine], &str[place], lenght); lines[currentLine][lenght] = 0; place += lenght; if (str[place] == ' ') place++; currentLine++; } lines[currentLine] = NULL; return lines; }
7. ## New to Opengl

I've never really liked the nehe tutorials. I found them messy and unpedagogic. When I was new to OpenGL they didn't help much. But each to his own I guess.
8. ## Problem with recv (Winsock)

atoi wants a null terminating string, doesn't it? edit: also, always check n.
9. ## the settlers...this is not a "i wanna make something similar" post. :)

Too bad they've completely destroyed the settlers concept.
10. ## Home grown or save your time?

Use the one in stl.
11. ## Condition testing

It will skip "another == one_more", but will check something_else. If it was "if( something && veryLargeLongRunningFunction() )", the function would only be run if something was true.
12. ## SOLVED, C++ vector of vectors hell

Unless you loop the code you show from World.cpp three times, m_Cycles will only have one vector. Edit: Otherwise I think it works as you want it to. Edit: Edit: When pushing m_Values into m_Cycles, what is added to m_Cycles is a copy of m_Values, so you won't need more m_Values vectors.
13. ## Check out my Particle Engine

http://members.gamedev.net/ryan_zec/OpenGL_Demos/SDLGameParticleEngine.zip clicky Looks nice.
14. ## Socket Descriptor Range

In other words, use a hash table.
15. ## fps affected by mouse

It would help if you posted your main loop.