Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

174 Neutral

About kman12

  • Rank
  1. kman12

    Rendering Text, need help [solved]

    Since you are using the same stringstream every time in GetScore, you are just appending the score onto the end of the stringstream after each frame. One way to fix this would be to clear the stringstream before using it each time, so changing GetScore to something like std::string Score::GetScore() { m_SS.str(""); m_SS << m_Score; return m_SS.str(); }
  2. kman12

    How to implement a Symmetric Key Cipher

    This is basically just a polyalphabetic substitution cipher. See here for more information and ways to crack it. It's a little different since you are working with whole bytes instead of just letters but it's the same general idea.
  3. kman12

    SDL Font help

    Well, if you're just using it for debugging, SDL actually creates a file in the same directory of the executable called "stdout.txt" which will contain everything you print to the standard output (e.g. printf and std::cout).
  4. kman12

    SDL Font help

    A couple things to check: -Why are you doing TTF_Init() == -1;? It would probably be better to be actually checking that to see if TTF_Init() is working, like if (TTF_Init() == -1) { //exit or something } -Also, you are not checking if the font loads correctly. From the SDL_ttf documentation it should be something like this: TTF_Font *font; font=TTF_OpenFont("font.ttf", 16); if(!font) { printf("TTF_OpenFont: %s\n", TTF_GetError()); // handle error } -Lastly, I'm pretty sure this is unnecessary: if (font == NULL) { return false; } It shouldn't matter what the value of font is yet because it hasn't been assigned to anything yet. In fact, it might even be initializing to NULL depending on how your compiler is set up.
  5. kman12

    move through an image

    I'm not positive about this, but I'm pretty sure that using glTranslate will have no effect on glRasterPos or glDrawPixels, as those deal in window coordinates rather than 3d coordinates. One possibility would be to get rid of the glTranslate call and call glRasterPos with transx and transy instead, but I think that a better alternative would be to create a texture out of your image and then render it on a quad.
  6. This is what I've been using, and it's worked for me. I'm using SDL_Image, but the principle should be the same. This is for PNG's with an alpha channel by the way, I think the glTexImage2D call would be a little different if you were using something without an alpha channel. SDL_Surface *image; int texture_id; glGenTextures(1, (GLuint*)&texture_id); image = IMG_Load(filename); if(image == NULL) { printf("%s",SDL_GetError()); SDL_Quit(); } glBindTexture(GL_TEXTURE_2D, texture_id); glTexImage2D(GL_TEXTURE_2D, 0, 4, image->w, image->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); SDL_FreeSurface(image);
  7. kman12

    Cooperative RTS

    For the sake of correctness, the co-op mode in starcraft was called "Team Free-For-All". kevin
  8. kman12

    The best idea EVAR!!!

    Yes, you do recall correctly :D. A quick google brings up: GmailFS Gmail Drive (based on the same thing but with shell integration in windows) kevin
  9. Rather than averaging all the points, couldn't you just average the two farthest away from each other for each axis? So then it would be exactly in the middle, without a bias depending on how many points there are on either side. kevin
  10. For something like this you could write a quick script in Python using something like PIL. At least that's what I'd do anyway. kevin
  11. Couldn't you just do something like this? std::ifstream in("test.txt"); char buffer[256]; int count; while (!in.eof()) { in.getline(buffer,256,'\n'); if (strlen(buffer)) { count++; } } //now count contains the number of non empty lines
  12. kman12

    Any angle gradient color fill

    Actually now that I think about it you could use that equation I gave before to find the short side of the rectangle for your quad. Once you find the short side you should be able to find the long side pretty easily based on the ratio of the sides. So like if it was originally a 600*400 pixel image, the long side would be long_side = short_side*(3/2) //note that 3/2 is just 600/400 reduced kman
  13. kman12

    Any angle gradient color fill

    The way to calculate how big the quad would need to be at any given angle is ((screen_width/2)/cos(angle))*2 That would be assuming your quad and viewport are square. Otherwise it gets more complicated... The easiest way to do this (probably not the most efficient) would be to just make the quad big enough that even at a 45 degree angle it still covers the whole screen. You could just figure this out with some experimentation. kman edit: if its a rectangular screen and a square quad, the code would be: ((screen_width/2)/cos(angle))*(screen_width/screen_height) I'm fairly sure that will work, as long as you keep the quad centered. Oh and also those equations will give you the length of any side of the quad, since it's assumed that it's square.
  14. kman12

    char to char*

    To convert a std::string to a C style string use std::string example; some_function(example.c_str()); [Edited by - kman12 on April 8, 2005 10:18:34 PM]
  15. kman12

    Linker Error using SDL+ GL

    IIRC, you have to set the project options to multi-threaded DLL somewhere to compile SDL apps in MSVC6. I forget exactly where it is, but maybe someone else remembers. kman
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!