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-22 20:39

>>80
He didn't say that. Putting words in other people's mouths is even ruder.

Name: Anonymous 2014-06-22 20:41

>>81
It's clear what he meant, I am sure that he is the ``back to /g/'' guy

Name: Anonymous 2014-06-22 22:16

>>73
Why are you even asking if you have already made up your mind?

>>75
You can put the closure on the observer list and call it directly instead of calling a notify method on it (because there's no need & closures don't usually have methods.)

Or you can skip this nonsense and embed the closure in the event classifier with a setter. Default lamdbas (or checked None instances) exist in the classifer as no-ops. Finally, instead of internal event classification, direct handling of events should be used whenever possible.

Name: Anonymous 2014-06-22 22:49

>>78
Thanks, I didn't know SDL was so shitty.

Name: Anonymous 2014-06-23 4:21

>>76

Because it is still better than any other language in existence.

Name: Anonymous 2014-06-23 4:26

>>75

(register-callback event closure)

Name: Anonymous 2014-06-23 6:39

>>83
Why are you even asking if you have already made up your mind?
Firstly I thinked of something like this after I made this thread
Second I am asking for a better solution since it feels ``shitty''

>>84
If this was the only problem in SDL it would be fine

Name: Anonymous 2014-06-23 7:06

>>87
Second I am asking for a better solution since it feels ``shitty''

If you think this is shitty, just do the easiest thing you can think of, but keep in mind you might have to change your strategy. Event handling is going to need a lot of your attention to get right.

You've got about 16ms each frame to do all the logic and render the frame. That's about 64 million instructions on a modern machine. You could do events in O(n²) and it's not going to amount to much of that. So do what is easiest to debug and forget about how fast it is. If you start dropping frames profile before you optimize or you will end up optimizing the wrong thing.

Name: Anonymous 2014-06-23 7:13

>>88
O-okay, thanks
I wonder how modern multi-purpose engines do these things

Name: Anonymous 2014-06-23 9:03

>>89 it's an implementation detail. If you're really curious, read the source.

Name: Anonymous 2014-06-23 10:41

Name: Anonymous 2014-06-23 10:47

>>91
This music is fucking epic
5/5 breddy good

Name: Anonymous 2014-06-23 11:03

Name: Anonymous 2014-06-23 15:09

This thread did not deserve so much shitposting

Name: Anonymous 2014-06-23 15:41

>>94
this is /prog/
every thread shall contain shitposting
NO EXCEPTIONS

Name: Anonymous 2014-06-23 15:49

>>95
This is *grabs dick*
every thread shall contain *grabs dick*
NO *grabs dick*

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