# 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]
3. ## first game help

Quote:Original post by hjarie oi i'm learning c++ and have made my first (simple)game its a rock paper sissors game where 2 players choose their mode and then the computer will see who wins. first question is: when the players input they mode([1]rock [2]paper or [3]sissor) they can se it on screen. now i use cin >> to get the input but is there a function to get the info without showing it onscreen? second question: is the coding any good? here it is *** Source Snippet Removed *** For your first question: afaik this isn't possible in console mode :). Code comments : you should use an initialization list for your constructor ininstead of setting the variables inside of them. So you get: speler::speler() : score(0) { } In c++ most coders use cout instead of printf (as printf is actually c-code), but it's no real error offcourse. also, your score name is not very perfect (I'm dutch myself), you now use a name "set score", which would actually mean: replace existing score with this one, a better name for example is addPoints. Even better would be, as in this game you'll always add one point: addPoint(), without arguments. Other points: your code is to much intertwined in my opinion, you should seperate things more (output in one place, game calculation in one place), but that's very normal for your first games :). You also use a lot of if/else, sometimes (not always) you could replace them with a switch structure. In my opinion it isn't good to make any member public (except some rare cases where constant use of setters & getters would be unusefull), so I'd make 'naam' private also. I hope this comment was a bit helpful.
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.