Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

162 Neutral

About qbic

  • Rank
  1. Did you try to move your rendering code after you check for events? I'm quite possitive that would solve your problems.
  2. I tried out your program on my computer and i ran just fine... I have some suggestions for your source though that might make it run better for you: * Check for errors from SDL_init and SDL_SetVideoMode * Do the drawing and buffer swaps AFTER event polling
  3. qbic

    Looping over enums

    Right, sorry. class_types should be class_types[]... And yes i think it's legal wo write that inside a class, even though maybe i personaly wouldn't :) I'd prefer having that outside the class and just keep a vaiable in the class specifying the class of the charachter.
  4. qbic

    Looping over enums

    Sounds to me like you'd be better off using a struct after the enum. My first though of a was to solve the problem would be to add something like this. This would make class_types real easy to iterate. enum { CLASS_MAGIC, CLASS_BOWMEN, CLASS_HERO }; struct { int type; const char *name; } class_types = { { CLASS_MAGIC, "Magician" }, { CLASS_BOWMAN, "Bowman" }, { CLASS_HERO, "Hero" }, {0, NULL} };
  5. qbic

    SDL Mouse event Issues??

    You're parsing the event wrong... it should be: while (SDL_PollEvent(&event)) { .... } Check the manual page for SDL_PollEvent for more info
  6. I think this is what you're looking after: SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_MOUSEBUTTONDOWN: switch (event.button.button) { case SDL_BUTTON_LEFT: printf("Left mouse button pressed.\n"); printf("At position %dx%d\n", event.button.x, event.button.y); // Get position of the button press break; case SDL_BUTTON_MIDDLE: printf("Middle mouse button pressed.\n"; break; case SDL_BUTTON_RIGHT: printf("Right mouse button pressed.\n"; break; default:break; } break; default:break; } }
  7. This is just a sloppy idea, but: int strToInt(const char *str) { int sum = 0; int mul = 1; int str_length = strlen(str); for (int i = str_length-1; i >= 0; i--) { sum += atoi(str) * mul; mul *= 10; } return sum; } Could be optimized, but you get the idea...
  8. Whats wrong with doing it this way? int atoi(char c) { if (c >= '0' && c <= '9') return c - '0'; return -1; // Not a valid number }
  9. Quote:Original post by michael879 I dont understand that at all, I understood what the other guy posted, it just isnt working right, he might have missed something? Just use it... Change the 'BINNAME' variable to the name of the binary, and change the 'SOURCE' variable to the source code in you're project and you're set. Now if you type 'make' you program will compile. type 'make clean' to remove all object files and the binary, and 'make depend' to calculate the dependencies (they will be stored in the makefile aswell)... Happy coding!
  10. I've written this make skeleton that i use in almost all my projects: CC = g++ CFLAGS = -W -Wall -O2 LDFLAGS = BINNAME = skel SOURCE = main.cpp driver.cpp debug.cpp OBJS = $(SOURCE:.cpp=.o) all: $(OBJS) $(CC) -o $(BINNAME) $(OBJS) $(LDFLAGS) clean: rm -f *.o $(BINNAME) depend: makedepend -- $(CFLAGS) -- $(SOURCE) 2> /dev/null .cpp.o: $(CC) $(CFLAGS) -c $< -o $@
  11. qbic

    OpenGL .DDS Fileformat

    A sweet! sence i'm using linux i didn't have access to the DirectDraw headers, that's exacly what i wanted! That MSDN resource looked pretty good to, gonna have a good look at that aswell. Thank you gues very much!
  12. I'm trying to write a img->.dds file converter using SDL and OpenGL. (Could't find anyone for linux) I've been revese engereered it until now sence i only can find text's about how o load them. I simply wonder if anywony can points me to a .dds reference or something. I esepecially wanna how the header looks like, couse i think i've gotten the hang of how the compression is made (compressing it using S3TC extension.
  13. qbic

    SDL stdout redirection

    I haven't tried this anytime but this is the solution that comes to my mind: FILE *stdoutBackup; FILE *sdloutBackup; // Init stdoutBackup = stdout; SDL_Init(); sdloutBackup = stdout; stdout = stdoutBackup; .... // At exit stdout = sdloutBackup; SDL_Quit();
  14. Both zip and rar's compression algorithm (i even think they use the same) are supported by zlib. Just find a good spec about them, and you can implement it with zlib.
  15. You can use zlib for rar archives aswell. If you don't know how it's done, this lib is for you: http://www.unrarlib.org/
  • 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!