Writing space invaders with Go
sausheong.github.io
sausheong.github.io
Does Go even have some "standard" SDL bindings? I was googling the other day (with the aim of learning Go through doing something fun) and I found like 6 results only on the first page. Didn't go and try any of them because to be honest that's depressing... i bet that if there are 6 different bindings none is feature complete.
Is Go useful just for server side stuff then?
And to the twitch guy I'm sorry, I'm old enough to prefer written documentation :)
You were recommended one binding for SDL and one for GL. Obviously they're different.
glfw and SDL are similar things, in that one may use one or the other to do basic operating system tasks like "get a window" which you can then draw to with opengl (or vulkan or whatever)
Even if you were programming in C++ you would have the choice between glfw or SDL for that kind of thing (or directly talking to your operating system's API!), so Go is not adding any confusion here that doesn't exist already.
I talk a bit about this in the EP 6 stream that you are too old for =) (I prefer written docs too! EDIT here: https://www.khronos.org/opengl/wiki/Related_toolkits_and_API... )
My main confusion is I know some SDL and OpenGL, but no Go. Thus, I don't know how to choose a SDL binding. Fighting with the binding is not a good thing when you want to learn a new language by doing a space invaders clone :)
Thank you mr/mrs/whatever gameswithgo! That's what I wanted to hear!
Go is a general purpose programming language, so it's suitable for basically anything in the Java/Python/.Net world modulo availability of libraries.
They do a very good job of making the API relatively idiomatic to Go without adding overhead, and I haven't run into any bugs yet.
I have been using them as part of a twitch series that teaches programming via small game projects. I go through how to get SDL2 up and running in episode 6:
https://www.twitch.tv/jackmott42/videos/all
There are aspects of Go that should make it better for game related programming. The low latency GC is a very good thing, compiling to native binaries means quicker start up time, and better responsiveness than a JIT, and easier distribution. Fast compile times are also very nice for many game programming workflows.
Wow.
I'd consider that pretty amazing and useful for displaying visual information like charts, flame graphs, latency plots etc.
Is this a (de-facto) standard? If not, it should be!
Surprisingly there's nothing similar for Linux distributions - iTerm is for Mac only.
>> Terminals can display images?
(I learned this the hard way: I once had a rather poplar 404 page featuring a variant of the game [1], until I received a cease and desist letter from Taito…)
[1] Compare: https://gizmodo.com/this-space-invaders-404-page-is-the-funn...
This implementation starts with the aliens going at what might be considered "full speed", and is probably much more difficult.
[1] https://github.com/dyu/ffi-overhead/blob/master/README.md
There appear to be improvements coming for 1.10 and 1.11: https://github.com/golang/go/issues/14939
You don't necessarily have to make a large number of calls into C per frame when using opengl though, I'm not sure it would be a deal breaker.
# Go 500000000 in 53058 ms
# C 500000000 in 1989 msIt would be about 13,000 calls into C per frame, to waste 1 ms with call overhead.
1ms would still be a lot when you only have ~16ms to work with,but I don't think even AAA games make within an order of magnitude of that many opengl calls per frame? Even writing in pure C you want to batch things as much as possible. I think typical is well under 1000 calls per frame, but I've only got experience with small hobbyist projects.
I don't see how FFI overhed would be a big deal for modern GL code. Most of the bindings happen only once. Then, sure, you update some buffers and ask the shaders to draw, but the buffer updates are likely limited by available bandwidth between primary memory and GPU, and the actual drawing is done in-GPU by shaders -- the single FFI call to start that process does not seem like a big deal in comparison.
Very cool!
I was thinking I might see Go in a device-control application, but alas not. The program uses a modern computer's video system. The original Space Invaders code likely had to shift pixels out to the video display in realtime. So a different programming feat entirely, but still cool!
- The built-in concurrency primitives are designed with real time systems in mind, freeing you from the need of constructing a cyclic executive and scheduling manually.
- The tools to deal with time constraints and diagnose why deadlines were not met are very high quality. The Ravenscar profile essentially guarantees that all scheduling decisions are known statically.
- Not strictly real time related, but since real time systems are often safety priority systems I'll mention it anyway: Ada makes memory management hard to get wrong.
If you're interested, I think Programming Real-time with Ada 2005 over at Embedded.com[1] provides a really good overview. Many of those features are meant for safety critical hard deadline systems and are consequently overkill for bedroom experiments, but for those projects you can just take the default basics and get 98% of the way there.
(If the article seems outdated in some aspects, recall that there were some further imptovements to the standard in 2012.)
[1]: https://www.embedded.com/design/prototyping-and-development/...
[1] https://github.com/JamesDunne/axewitcher-ovg [2] https://github.com/JamesDunne/golang-openvg
I think a moderator should consider merging this thread with the original, if possible.