• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

131 Neutral

About SeeForever

  • Rank
  1. I've never heard of it called "MVC" but I looked it up and I pretty much already knew that. I always separate input, logic, and rendering from one another as much as possible and then I separate different parts of the logic into independent classes whenever the opportunity arises. That last part is what I usually end up doing long after I started coding - I'd like to be able to plan for it in advance. Here's a recent example:   During design I planned it like this: - class World keeps track of tile coordinates, time, and weather - class Person walks on the world - class Animal walks on the world - class Vehicle walks on the world   But then I ended up doing it like this: - class World keeps track of tile coordinates, time, and weather (no change there) - class Entity stands on the world - class MobileEntity inherits Entity and adds facilities for moving from tile to tile - class BattleEntity inherits nothing and adds facilities for taking and dealing damage - Person, Animal, and Vehicle all inherit MobileEntity and BattleEntity   Turns out I underestimated the complexity of what ended up having to be the classes Entity and MobileEntity.     Hey, that looks neat! Thanks a lot! I'll be reading those now. :)
  2. I'm pretty decent at programming but I suck terribly at designing things. My designs never pan out and I always end up throwing most of the initial planning away and coding in spaghetti. It works as expected, but it's spaghetti and it's hard to document. So is there any nice place with tutorials on this subject? I prefer language-nonspecific tutorials or C++ which is what I use 99% of the time. Thanks in advance.
  3. [C++] Curious problem with rand()

    Either your own code has another srand/rand hidden in it somewhere that you've missed, or a bit of 3rd party code does. That sounds like the only logical explanation.   This is why globals/singletons are bad    Hehe, agreed.     I've looked into that. It's a but too hardcore for my current needs.     What do you mean by "static initialization on a global level"? Like initializing global variables outside of a function? I avoid doing that. :P
  4. [C++] Curious problem with rand()

    Either your own code has another srand/rand hidden in it somewhere that you've missed, or a bit of 3rd party code does. That sounds like the only logical explanation.   This is why globals/singletons are bad    I thought so. I don't want to blame SDL of messing with the state of rand() but I don't see how my code could be doing it, if it runs fine with my custom version. ;-;
  5. This isn't a problem per se as I have solved it, but it intrigues me.   Basically rand() isn't generating the same sequence of numbers for the same seed. My program is very long and split into over 40 classes so it wouldn't make sense to post everything here, but check this: after 2 days of playing around with different parts of my code I ended up replacing every call to rand() and srand() to custom versions, and now everything works fine. Now I run my program 10 times with the same seed and it always generates identical output, but that is not the case with the stdlib version.   I tried to reproduce this by writing a small program that outputs rand() results to files but it works as expected so I'm guessing either the C/C++ runtime or one of the third-party libraries I'm using is calling rand() behind the scenes at some point. Is that possible or is all this just a coincidence somehow?   I'm using the following software: Compiler: MinGW 4.7.2 Libraries: SDL 2.0.0 along with SDL_Image and the png/zlib libraries it comes with Thanks in advance if anyone knows.
  6. OpenGL [Noob question / C++] Color masking

    Gee, sorry for the late response! I had email notifications disabled.     What I ended up doing was something similar to that, except instead of making the entire texture red (for example) rendered every texture twice, one at glColor4f(1,1,1,0.5) and one at glColor4f(1,0,0,0.5). It did the trick. :)   Thanks!
  7. Hello. I'm working on a 2D program with OpenGL and I'm looking for a way to mask individual bits of colors. Something like glColorMask() but with float arguments instead of booleans, if that makes any sense.   To be more specific, I want the world environment in my program to have a blueish/whitish tone during winter and a slight orange tone during summer.   My program consists of flat square textures layered on top of each other. There are no 3D objects, so the advanced lighting mechanisms of OpenGL would be a little overkill.   Thanks in advance!
  8. Nevermind, I figured it out. It was too simple... I just needed a night's rest. [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] Splitters (like in wxWidgets) are controls that go in other splitters. Splitters break space up into equal portions then inside those you put more splitters. Okay you're right, it's hard to describe without pictures! [img]http://public.gamedev.net//public/style_emoticons/default/angry.png[/img]
  9. Hello guys and girls! [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] I made my own GUI system for my game. I just needed buttons, text boxes and a couple custom controls so it wasn't too hard to make. It worked fine for a bit but I couldn't stand the ugliness of pixel-based positioning, and it started getting annoying to code one particular part of the game that relies on the GUI heavily. Then I remembered how wxWidgets works: it divides the GUI into squares, one control per square, and then you can align and stretch the control in there to get the desired position. I tried to make something similar but I got stuck figuring out how to calculate the positions for the squares. Right now I have this: control1 | control2 control3 | control4 It works as expected for a 2x2 (or 3x3 or 4x4) grid but what if I want to put a control5 in the same square as control2? So that control4 would be aligned across control2 and control5. The way I have it set up right now, it divides the top row in 3 equal parts and the bottom row in 2 equal parts and this is not what I want. control1 and control3 need to be aligned vertically. I know it's a matter of simple math but I've been stuck for days thinking about it and playing around with algorithms and I just can't figure it out... Can someone help me out? Thanks in advance! [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]
  10. Simple GUI suggestions

    I'm working on one for my game right now. In fact I came here today to ask a design question about GUIs. You may wanna keep an eye out for my thread, it may have useful info for ya if you wanna make your own. [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]
  11. [SDL] How to handle keyboard text input?

    Hey I've followed the LazyFoo tutorials before! How come I missed this one? Thanks a lot Jakez, that's exactly what I was looking for! [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
  12. Hello everyone! I have a GUI in a game I'm developing. I have two text input boxes. I can input text into it using SDL_KEYDOWN events but how would I go about translating the modifier keys like shift and caps lock to turn letters into capitals and numbers into symbols? I'm looking for something locale-independent. I can just check for the 'shift' key modifier and then apply it manually to whichever key was pressed but like, I would do '!' for '1', but not everyone is using an U.S. keyboard layout. Does SDL have something built-in for this? If not, is there a cross-platform library for it? Or am I stuck calling OS-specific functions? Thanks in advance!
  13. Hello everyone, I'm very new to OpenGL, but I've used SDL for a while. I'm trying to use them together because I can't stand to look at my $200+ video card sit there doing nothing while my CPU strains at 100%. Also to try something different. My game is just a basic 2D fighter-platformer. It worked fine with just SDL, but when I applied OpenGL (after some playing around, of course) I can't seem to get the transparency portion right. I don't need blending, just color-keying (alpha testing, right?) but I get black squares instead of transparency. Also, some of my textures seem smoother than what I made in Photoshop. It's like OpenGL is trying to expand them by 1 or 2 pixels and I don't see why. I've looked all over the OpenGL docs but no matter what I try, I don't get the effect I want. I'll post the relevant code snippets in the order in which they're executed. First I have this in my main() function: /* Initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) { sdl_error("SDL_Init"); return -1; } /* Set OpenGL attributes */ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); /* Set up the SDL window */ Screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_OPENGL); if (!Screen) { sdl_error("SDL_SetVideoMode"); return -1; } /* Enable textures */ glEnable(GL_TEXTURE_2D); /* Set up 2D projection */ glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 1); glMatrixMode (GL_MODELVIEW); /* Disable the depth buffer */ glDisable(GL_DEPTH_TEST); /* Make transparent black the clear color */ glClearColor(0, 0, 0, 0); /* Enable alpha testing */ glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_LESS, 1.0f); Then I load images into SDL_Surfaces and then convert them to OpenGL textures with this algorithm: GLuint surface_to_texture(SDL_Surface *surface) { GLuint texture; glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, 4, surface->w, surface->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, surface->pixels); return texture; } My render function is just this: glClear(GL_COLOR_BUFFER_BIT); /*many calls to draw_quad()*/ SDL_GL_SwapBuffers(); I draw the textures with this function: void draw_quad(int x, int y, int width, int height, GLuint texture) { glBindTexture(GL_TEXTURE_2D, texture); glBegin(GL_QUADS); glTexCoord2i(1, 0); glVertex2d(x, y); glTexCoord2i(0, 0); glVertex2d(x+width, y); glTexCoord2i(0, 1); glVertex2d(x+width, y+height); glTexCoord2i(1, 1); glVertex2d(x, y+height); glEnd(); } Thanks to anyone who can help!
  14. I see. Computer science it is, then! Thanks everyone! Now, what would be the best affordable schools? I can't get any sort of financial aid.
  15. Hello GameDev, I'm 19 years old and I think it's time for me to quit being so lazy and start going to school again. I've been interested in programming since I was 14 and I've made a few games for Windows and the PSP. Nothing impressive, but still, I'm not new. ;) How should I go about this? Game-specific school or regular programming school? What courses should I take? Anything I should watch out for? I looked at a few schools (DeVry, Game Institute, etc.) but I don't know anything about schools so that's why I'm asking you guys to enlighten me. Thanks in advance!
  • Advertisement