Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Question about event handling

Name: Anonymous 2014-06-21 11:42

Let's say I use SDL (1.2 or 2.0) in my program to handle events, should I use callbacks or the good old giant switch statement?

Name: Anonymous 2014-06-21 20:51

>>1
*I* shall answer you question, good sir, without being rude and without belittling your work.

Try one, see how it goes, then try th' other. Once you have experimented to your satisfaction, you may move on with your life.

Regards,
Invenietis

Name: Anonymous 2014-06-21 20:55

>>40
bookmarked

Name: Anonymous 2014-06-22 5:17

>>6
sup, /g/ s'goin' down /g/ top of the morning /g/ feelin good /g/ shooting niggas up /g/ crackalackin /g/ smokin grass /g/ doin taxes /g/ crackin homos /g/ sackin bonos /g/ cmon /g/ give us a glance /g/ show us your stuff /g/

Name: Anonymous 2014-06-22 5:18

>>6
sup, /g/ s'goin' down /g/ top of the morning /g/ feelin good /g/ shooting niggas up /g/ crackalackin /g/ smokin grass /g/ doin taxes /g/ crackin homos /g/ sackin bonos /g/ cmon /g/ give us a glance /g/ show us your stuff /g/

Name: Anonymous 2014-06-22 12:27

>>40

How is game programming different from any other kind of programming?

Name: Anonymous 2014-06-22 14:13

>>45
Everything is different... as programming an e-mail server is not the same as programming a word processor. Every ``kind of programming'' is different from each other. Even between different game genres.
Check out the design patterns of that e-book and you will understand.

Name: Anonymous 2014-06-22 14:26

Can someone please actually help with the question?

Name: Anonymous 2014-06-22 14:37

>>47
SDL a shit

Name: Anonymous 2014-06-22 14:42

>>48
it does not matter if it is about SDL, it is about any kind of event system

Name: Anonymous 2014-06-22 15:02

>>47
Could you please stop assuming it's the board's obligation to answer every single question you make?

Name: Anonymous 2014-06-22 15:06

>>46

Can you provide an example of fundamental differences between writing a game engine and say E. Coli simulation?

Name: Anonymous 2014-06-22 15:07

>>50
I made only one question here about programming and it is the only programming quetion in the front page
I also used the "Don't bump" functionality to post this
So, what is your problem? I would also like to ask if you are >>2,4,7

Name: Anonymous 2014-06-22 15:35

>>52
I am not.

How are these threads
http://progrider.org/prog/read/1403254313
http://progrider.org/prog/read/1403411006
http://progrider.org/prog/read/1403166961
http://progrider.org/prog/read/1399040031
http://progrider.org/prog/read/1403330382
http://progrider.org/prog/read/1403205144
not programming related? They're all on the front page.

Could you please stop calling everything you don't like ``off-topic''? The aforementioned threads may not have a completely serious mood but that doesn't mean they shouldn't be here. /prog/ likes to fuck around, is that fact that surprising to you?

Name: Anonymous 2014-06-22 15:39

>>53
fuck you

Name: Anonymous 2014-06-22 15:40

>>47
You got answers right away then objected to them on fictional grounds. It seems like what you're really asking for is an argument, which you also got. Enjoy.

Name: Anonymous 2014-06-22 15:48

>>55
The only answers I got were >>2,4,7 that would be also called as ``shitposting''.
what else?

Name: Anonymous 2014-06-22 15:48

hax my anus

Name: Anonymous 2014-06-22 15:51

>>57
hax mine first

Name: Anonymous 2014-06-22 16:02

>>56
If that's shitposting, what do you call >>1?

Name: Anonymous 2014-06-22 16:03

>>59
I do not know how I would call >>1 but I am sure that I would call you a big fat troll

Name: Anonymous 2014-06-22 16:13

I browse /prog/ since 2006 and this is the first! time this happened to me. Every programming question I ever made got high quality replies except this. Looks like from now on I will make my programming questions on the ni/g/g/erland because no programmers are left here

Name: Anonymous 2014-06-22 16:13

>>60
How does you would call you a big fat troll make you feel?

Name: Anonymous 2014-06-22 16:18

>>62
Does >>63 have a nose?

Name: Anonymous 2014-06-22 16:21

>>61
Go ahead.

Name: Anonymous 2014-06-22 16:30

>>64
No thanks

Name: Anonymous 2014-06-22 16:30

>>47
What is the question?

Name: Anonymous 2014-06-22 16:33

>>66
``should I use callbacks or the good old giant switch statement?'' [and why (implied)]

Name: Anonymous 2014-06-22 16:34

>>67
Callbacks, they are more scalable and maintainable.

Name: Anonymous 2014-06-22 16:36

>>68
Using a for/while that calls every callback that may not even be needed would be slower instead of using a nice O(1) switch

Name: Anonymous 2014-06-22 16:37

>>67
Anyway, in case you are not a troll, your confusion stems from the fact you think callbacks are supposed to check the event and decide whether to act or not. Callbacks always act when they are called. You register callbacks using some mechanism provided by the event library. Thus, whether it is O(n) or O(1) to decide which callback to use, is up to the event library implementation.

Name: Anonymous 2014-06-22 16:38

>>69
Well, see >>70.

Name: Anonymous 2014-06-22 16:40

hax my anus

Name: Anonymous 2014-06-22 16:43

>>70
The thing is that I am not using a event library that gives me the possibility of callbacks but I do it myself on top of SDL
I will implement something like this looks like http://www.gamedev.net/topic/646358-event-handlers-in-c/ that gives me O(1)

Name: Anonymous 2014-06-22 17:21

>>40
http://gameprogrammingpatterns.com/observer.html
That guy is surely a retrograde moron. "Observer pattern" and all other "design patterns" are just a boilerplate, completely useless in Scheme and Common Lisp, which you should be using today. I.e. observer pattern was invented to emulates closures.

Name: Anonymous 2014-06-22 17:41

>>74
How would you replicate that behavior with closures? I'm not encouraging the use of OBSERVERS, I'm legitimately curious.

Name: Anonymous 2014-06-22 18:43

>>74
Scheme and Common Lisp, which you should be using today
Why would I use an outdated, obsolete and also unpopular language?

Name: Anonymous 2014-06-22 18:50

>>73
Why don't you use SDL_AddEventWatch? It's O(1)!

http://wiki.libsdl.org/SDL_AddEventWatch
Use this function to add a callback to be triggered when an event is added to the event queue.

>>75
He's retarded. What he is saying is the same with 'lambda calculus is turing complete!'. He won't even show how to implement an observer with a closure -- I guarantee this.

Name: Anonymous 2014-06-22 18:54

>>77
SDL_AddEventWatch
doesn't return and error and /* uh oh */ https://hg.libsdl.org/SDL/file/60edb019f0fe/src/events/SDL_events.c#l496
it also calls every function even if it is not about that event so it has the same problems as using >>28 (something like signal() that has the event as first argument would be better)

Name: Anonymous 2014-06-22 20:29

>>76

How do these people find their way on here?

Name: Anonymous 2014-06-22 20:35

>>79
saying that everyone is from /g/ is rude, please stop

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List