Closed kissdata closed 1 year ago
Hi @kissdata, it is a standard for-loop in Go. You can see an explanation of it here.
We use it in the examples to extract all the Events in current frame until there's no more.
I known it, for-loop with 3 expressions, so does in c/cpp. I now reading the article recommended by wiki.libsdl.org (ranked 6th) , he used a while-loop to process event:
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
// ...
}
if (e.type == SDL_KEYDOWN) {
// ...
}
}
oh 👀 so short, if I use go
recode it, this for-loop looks longer than original statement. I want see if exists a better way to implement it.
When it comes to Event, most of code in examples look like this:
Why the event (a interface) should be written
= sdl.PollEvent()
twice?