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

Posts I've Made

In Topic: Where can I learn software engineering, for free?

27 October 2013 - 09:31 PM

How much do you already know?

Do you know the basics: MVC, etc...?

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.

 

 

Always prefer books to tutorials. Tutorials are woefully insufficient for learning anything in depth.

So take a look at the top of this list.

Hey, that looks neat! Thanks a lot! I'll be reading those now. :)


In Topic: [C++] Curious problem with rand()

14 October 2013 - 03:22 PM

 

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?

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 dry.png

 

Hehe, agreed.

 

 

You should use the new C++11 random header instead of rand; it solves this problem, and gives you better guarantees about uniform results.

I've looked into that. It's a but too hardcore for my current needs.

 

 

Often, If you use static initialization on a global level, you can't tell which order the objects are created in.

Usage of rand() here may cause code invoking rand() in a different order than expected.

Of course, if the same build is causing different sequences, that's a different thing ohmy.png.

 

(Also, i must agree with Mir, stl http://www.cplusplus.com/reference/random/ is really sweet - I use it a lot.)

What do you mean by "static initialization on a global level"? Like initializing global variables outside of a function? I avoid doing that. :P


In Topic: [C++] Curious problem with rand()

13 October 2013 - 04:04 PM

 

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?

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 dry.png

 

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. ;-;


In Topic: [Noob question / C++] Color masking

13 October 2013 - 05:46 AM

Gee, sorry for the late response! I had email notifications disabled.

 

 

The easiest way is to just overlay a color and using blending

Your idea of masking individual bits probably wouldn't work like you expected it to, and you have little control over the results

Create a fullscreen quad (-1 to 1) for NDC and just shade any color you want

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!


In Topic: Simple math: how does wxWidgets calculate control position?

07 February 2012 - 02:27 PM

Nevermind, I figured it out. It was too simple... I just needed a night's rest. Posted Image

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

PARTNERS