Jump to content

  • Log In with Google      Sign In   
  • Create Account

SeeForever

Member Since 06 Dec 2007
Offline Last Active Oct 28 2013 09:12 PM

Topics I've Started

Where can I learn software engineering, for free?

27 October 2013 - 04:59 PM

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.


[C++] Curious problem with rand()

13 October 2013 - 06:02 AM

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.


[Noob question / C++] Color masking

30 September 2013 - 06:25 PM

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!


Simple math: how does wxWidgets calculate control position?

06 February 2012 - 05:15 PM

Hello guys and girls! Posted Image

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! Posted Image

[SDL] How to handle keyboard text input?

31 January 2012 - 02:08 PM

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!

PARTNERS