Jump to content
  • Advertisement

Hexed

Member
  • Content Count

    44
  • Joined

  • Last visited

Community Reputation

175 Neutral

About Hexed

  • Rank
    Member
  1. Hexed

    C Strings (ugh)

    Hey Zahlman, I think I'll stick with C. Thanks for the added perspective, I love seeing different ways of accomplishing a common goal.
  2. Hexed

    C Strings (ugh)

    Quote:Original post by Sneftel Yes, it is. (beware: itoa() is not.) Oh yea that's what I was thinking of. Thanks guys.
  3. Hexed

    C Strings (ugh)

    Hey thanks for reply looks good, is atoi() portable?
  4. I am not good with strings in C, please tell me how you would go about the solution: Textures are loaded into a game engine, and if the filename(s) provided starts with an underscore ('_') it is interpreted as an animation. The name of the animation is provided as a string and follows the template "_name_nnn.ext", where nnn is a three-digit number containing the number of frames in the animation, and ext is the file extension. The corresponding animation frames are named similarly, e.g. "_name_000.ext" would be the first frame. How would you extract the number of frames from the string? How would you construct a string for the filename of each animation frame? Currently my code is a mess and I just think I'm going about it the wrong way. I dare not show the original function this came from, so I've made a sample program outlining the current state of things, take a look: int main (void) { char strGivenName[256], strFrameName[256]; char strNumFrames[4], strFileExtension[4]; int i, intNumFrames; size_t fnlen; // clear arrays memset (strNumFrames, NULL, 4); memset (strFileExtension, NULL, 4); // This will be the filename provided strcpy (strGivenName, "data/textures/_animation_030.png"); // Get string lenth so we can extract frame count and extension later fnlen = strlen (strGivenName); // Copy frame count only into another string strncat (strNumFrames, &strGivenName[fnlen-7], 3); // Then use sscanf to convert to integer sscanf (strNumFrames, "%d", intNumFrames); // Then save the file extension to another string strncat (strFileExtension, &strGivenName[fnlen-3], 3); // Now we have the information needed to produce the actual filenames for (i = 0; i < intNumFrames; i++) { // Start out with filename provided strcpy (strFrameName, strGivenName); // Overwrite the last 7 characters with frame number and extension sprintf (&strFrameName[fnlen-7], "%.3d.%s", i, strFileExtension); printf ("%s\n", strFrameName); } return (0); }
  5. Hexed

    Some more SDL tutorials

    Thanks rob that was extremely helpful.
  6. Hexed

    SDL Mouse Input

    Hey thanks for the reply! I was beginning to think no one on this forum knew what a mouse was. ;) Anyway, yes this sounds like it could possibly work. I'm not a big fan of workarounds/hacks though, so I'm going to look into using SDL_GetMouseState() to calculate my own relative positions. Maybe that will work. Later.
  7. Hexed

    Problem with OpenIL..

    I let DevIL do all the work for me. Here's my code. gameloop.cpp / GameInit (): // Initialize DevIL ilInit (); iluInit (); ilutInit (); ilutRenderer (ILUT_OPENGL); gameres.cpp / BodLoadObject (): // Read object file header if (!GetLine (Buffer, 256, fp)) { fclose (fp); return (0); } sscanf (Buffer, "%s %d %d %d", TextureFile, &NumVerts, &NumTVerts, &NumPolys); Object->texture = ilutGLLoadImage (TextureFile); gameres.cpp / BwdLoadWorld (): for (i = 0; i < NumTexs; i++) { if (!GetLine (Buffer, 256, fp)) { fclose (fp); return (0); } sscanf (Buffer, "%s", TextureFile); sector01.texture = ilutGLLoadImage (TextureFile); } And that's all the code I have pertaining to texture loading.
  8. Hexed

    Some more SDL tutorials

    Hey do you know if it's possible to use SDL_ttf along side SDL_opengl? That would be convenient.
  9. Quote:Original post by Fruny I believe they already do that. Check out the occasional text ad at the top of the page, or in the column at the right of the front page. I am convinced they're actually AdSense ads. Hmm, I don't see AdSense ads. They would be labeled "Ads by Google."
  10. Hexed

    Problem with OpenIL..

    Hey what's up. I am using DevIL/OpenIL in my engine, but honestly I've never tried anything over 256x256 until you posted. Well I resized a PNG graphic to 512x512 and DevIL loaded it fine. I'm running Win32 using SDL/OpenGL with VC7 compiler.
  11. Hexed

    the best language fo games

    DOS batch files are the best for game programming.
  12. My two cents: I generally hate advertisements, but hey whatever floats your boat. The nice folks who run GameDev.net give all of us a great resource for game programming. And the best part is, it's free to all. They run this websites using money out of their pockets, and they need some sort of income to pay for server/bandwidth costs, and advertising is a good way to achieve this. On a relative scale, gamedev is one of least intrusive websites when it comes to advertisements. I can't stand those huge animated flash advertisements, with audio no less, you know what I'm talking about. IntelliTXT is the lesser evil in my eyes, but still evil if you ask me. The reason IntelliTXT generates a high click-through rate is because it tries to hide itself as a link within the content. To me, this is a scam, and the company behind this is a scam artist. I'm willing to bet that half the click-throughs are unknowing users thinking that this is a link to another page as intended by the original author. I'm sure some of you guys have done this too, at least once. And this will happen regardless if the "adlink" is green, blue, orange, purple, whatever. It's disguised as a normal link. And have you considered the fact that approximately 10% of the male population is affected by color blindness? To the staff of GameDev.net, I respect your decision to implement advertisements within your website, but please do me a favor and look into Google AdSense. This is another "context sensitive" advertisement method, and has great revenue potential. Best of all it doesn't intrude on content. If you don't like AdSense then try another, there are several other good ones. But please get rid of IntelliTXT. Or do what you like, whatever... - Hexed
  13. Hexed

    SDL Mouse Input

    Hey I'm writing a 3D/FPS game engine, and I'm having this one annoying problem with mouse input handling. The game loop calls ProcessMouse() every frame to get mouse input via SDL_GetRelativeMouseState(), and it uses these values return to increase/decrease rotation/pitch. This works pretty well, but the issue is that when the program starts, the rotation/pitch seems to be somewhat random. When I disable the mouse input handling this is not an issue. Here's the applicable C source: Init: SDL_WM_GrabInput(SDL_GRAB_ON); // Take focus SDL_ShowCursor(SDL_DISABLE); // Hide mouse cursor SDL_GetRelativeMouseState (NULL, NULL); // Reset relative position Per frame: int ProcessMouse (void) { int mx, my; Uint8 state; float sensitivity = 0.25; state = SDL_GetRelativeMouseState (&mx, &my); if (state & SDL_BUTTON (1)) { // Left mouse button pressed } if (state & SDL_BUTTON (2)) { // Middle mouse button pressed } if (state & SDL_BUTTON (3)) { // Right mouse button pressed } // Rotate camera based on mouse movement player01.angle.y -= mx * sensitivity; player01.angle.x -= my * sensitivity; // Clamp pitch value if (player01.angle.x &lt; -90) { player01.angle.x = -90; } if (player01.angle.x &gt; 90) { player01.angle.x = 90; } return (0); }
  14. Luke: Can't turn that down. zed: Looks nice, wish there was a libcollada ;) [Edited by - Hexed on July 10, 2005 10:41:17 PM]
  15. Hexed

    looking for GLUT replacement

    javacooldude, sound interesting, link?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!