New answers tagged

1

Yes, setting a global variable and then calling a method which behaves differently based on its value is a dangerous anti-pattern known as "Accumulate and Fire". The remedy is to pass all data which is required by a method as parameters. In your case the solution is to not use generic event handlers to enter a state. Give each state an unique Enter method ...


1

A fine way to handle in a discrete way communications between entities is the Oberver pattern. Take a look at it. each entity who need observation will need to add an observer to its list public void AddObserver(Observer o) { obs_l.Add(o); } Then when you define your Notify function you will baasically pass a reference to the object calling, if it is ...


0

SDL2 actually generates key repeat events automatically. You need to manually filter repeated key events out by checking the repeat member of a SDL_KeyboardEvent. This is something that did not automatically happen in SDL1, so that's why the behaviour is different. See SDL_KeyboardEvent for more info.



Top 50 recent answers are included