# kire

Member

15

112 Neutral

• Rank
Member
1. ## Improved Word Jumble!

Quote:Original post by DeathLetum hehe my bad im kinda sleepy and hmm im using C++ and i didint really understand what you said in ur post He says that if you loop over the array (or vector, whatever you use) you can get wordlength like this: for(int i = 0; i < arrayLength; i++) { /// char* strings: score += strlen(arrayWithWords[i]); /// C++ strings: score += arrayWithWords[i].size(); } off course this is a very basic example ;)
2. ## Poker game help

Quote:Original post by Brash Benson No, you pretty much have the right idea. I'm no Poker expert either, but I know the basics and that sounds about right. I just wish there was an easier way to do it than "if card 1 is different than card 2, 3, 4, and 5, check the next card against all others, etc". What a pain :( Some pseudo-code straights: val = card.value(); int straightCount = 1; while(in_array(++val,otherCardsValues)) { straightCount++; } val = card.value(); while(in_array(--val,otherCardsValues)) { straightCount--; } And this in a loop so you can do this for cards 1->4. I can't think of anything better, but it doesn't look like a real pain to me, I've written worse. Checking on equal would be quite more easy i'd guess. edit: Ow, I used pseudocode for the in_array because i'm not sure java support such a function (I don't program in java often), it isn't hard to implement one yourself however. edit nr.2: this code only lets you see there is a straight, not which cards create it. edit nr.3: as i was to stupid to think of ordering cards in advance myself (look post beneath this one), the pseudo code i posted is easy to edit to create a (shorter) algorithm for straight-checking. [Edited by - kire on September 6, 2006 2:09:16 PM]

4. ## VC EE Linking Problem: Conflicts between libcmtd.lib and MSVCRTD.lib

indeed, make sure you link both sdl, sdlmain (and i think user32) Mostly an ignore is not needed, you could get a warning but everything will work smooth.
5. ## OpenGL not working in Dev-C++

@sirbone72: You could try a different linking-sequence, however I'm not sure that will solve this problem. Also: are you sure your library-files are updated? for example, I get reference errors if I use this: -lSDL -lSDLmain it has to be -lSDLmain -lSDL
6. ## OpenGL UI

There are different ways, not? you could simply go for orthogonal rendering and use the depth buffer to create a display order in your elements, each element could then be a 2 dimensional polygon. Then you can draw textures or text to that polygon. Tbh I'm not sure myself & better suggestions are more than welcome, i'm also creating a basic UI-system atm, but I'm only creating the UI logic atm, not how it should be drawn.
7. ## Need help with some code

Quote:edit:By the way, is there any way in c++ like php to set it so that you can get an array to continue in alphabetic order after setting the first couple so I don't have to type out all of the letters? char myArray[26] for(char c = 'a'; c <= 'z'; c++) { myArray[c-'a'] = c; }
8. ## SDL keyevent

"Best" solution I think is to work with gametime passed, a velocity and keystates. On keydown you put this keystate on "pressed", so you don't always have to resend this item. When the keystate is not pressed, you do nothing, which is fairly fast enough I guess, what you would do for moving forward is e.g. something like this: if(forward_key_pressed) { translate(VelocityVector*passed_time_since_previous_frame); } offcourse, in order to let it work decently you need a clear system that manages frames and such. The repeat is good for a quick fix, but isn't the nicest solution.
9. ## What are virtual functions

Quote:Original post by samoz so is a virtual function in C++ the same as an abstract method in Java then? not at all. An abstract method (or "pure virtual") in c++ would look like this: virtual void abstractMethod() = 0; The virtual is the keyword that helps making polyformism in c++ easier. The decent explanation stands above ;). [Edited by - kire on September 4, 2006 1:56:41 PM]
10. ## SDL crashes, burns. Memory issue?

If you use a function with unknown pointer-input at least check for not null. @evillive: in that function he must use a pointer if he wants to pass by reference ;). It would be quite ridiculous to set the screen data of a local copy.