8 ms·
Create a simple cross-platform desktop game with Go
- pravj 8y agoWasn't aware of the mentioned "webview" wrapper[1], considering to use it for a side project. Reminds me of the time I created an improved version of the "8-puzzle"[1] game in Go to learn about "channels" and "goroutines". Especially, the use of "select" statement for listening on multiple channels for the main event loop. [1] https://github.com/zserge/webview https://github.com/zserge/webview [2] https://github.com/pravj/puzzl https://github.com/pravj/puzzl
- alienspaces 8y agoThis is cool, thanks for sharing!
- splitbrain 8y agoInteresting, though what this actually does is run a local webserver so I assume it would be even simpler to just open the default web browser pointed to the local server? But then you start thinking that sound output could also be handled via the audio API and one could even play this remotely. So what you created is a webapp? Why even run it locally at all then... just some thoughts. Still a cool idea to circumvent the lack of good native UI support in go I guess.
- messe 8y ago> Why even run it locally at all then Latency?
- zserge 8y agoWebview author here. It does not require local web server actually, it allows to inject js, css, HTML in runtime and bind go structs to is objects through the API, so the result is a self contained web app with no server. Although using a local web server may be more convenient to most web developers.
- pier25 8y agoWhy IE and not Edge for Windows?
- zserge 8y agoIntegrating Edge is my dream. However there is no C API unlike MSHTML. I still have hopes on cppwinrt though. Any help in this direction is highly appreciated.
- sausheong 8y agoI wrote the blog post, thanks Serge for the great library! I considered the self-contained app without the web server method, but I've already done the images before and I'm way more comfortable with Go web programming (I wrote that book too).
- justinclift 8y agoFor cross platform game / 3D development in Go, there are a few frameworks and libraries already in place: https://github.com/avelino/awesome-go#game-development https://github.com/avelino/awesome-go#game-development g3n seems like the most promising recent candidate: http://g3n.rocks http://g3n.rocks https://github.com/g3n/engine https://github.com/g3n/engine Azul3D used to be a promising candidate, but looks to be very dead now. :(
- gameswithgo 8y agoSDL2 + OpenGL as well
- deleted 8y ago[deleted]
- Sir_Cmpwn 8y agoI've been tinkering with writing a simple game in Golang as well. I don't think it's a good idea to lob in an entire web browser for a game, though. I've been using the go-gl stack: https://github.com/go-gl https://github.com/go-gl They have a wrapper for GLFW and OpenGL, I've been using GLES2 which has good compatability with everything. You have to be prepared to learn how to write shaders and use OpenGL, though, so it can be a bit intimidating. Here's the (extremely incomplete and very bad) game I have so far: http://git.sr.ht/~sircmpwn/freefood http://git.sr.ht/~sircmpwn/freefood
- gameswithgo 8y agoIf you are doing 2d you can also do quite well with just the SDL2 wrapper. That gives you enough to do cross platform sound, input, and putting textures on the screen with alpha blending and bilinear interp. So its enough to make mario/ultima/baldurs gate/ style things.
- Sir_Cmpwn 8y agoPersonally I find SDL far too limiting. As soon as you want to write even one shader you have to write all of the graphics code yourself, and at that point it's hardly better than GLFW.
- akavel 8y agoSee also https://github.com/oakmound/oak https://github.com/oakmound/oak if you are interested in a pure-Go library (i.e. one which doesn't need cgo) with no HTML & JS dependencies. (Disclaimer: haven't used it so not sure what's the status; but reportedly it's been used by its author to write a game.)
- justinclift 8y agoTried out the examples bundled with it, and for what it is it seems ok. Looks 2D only (not 3D capable), but if that's the desired target then it's probably a decent choice. :)
- gameswithgo 8y agoYou may also enjoy: https://gameswithgo.org/ https://gameswithgo.org/ A video series where I teach programming via game projects. We do some software rendering, some SDL2, simplex noise, 2d rpgs, and some 3d opengl.
- TeddyDD 8y agoAnother good option is to use Raylib bindigs: https://github.com/gen2brain/raylib-go https://github.com/gen2brain/raylib-go No need for HTML/js and API is pretty simple
- justinclift 8y agoOh, this does look interesting. It mentions support for OpenGL ES 2.0, which (I think) means it'll work with the native OpenGL drivers for the Raspberry Pi family. Could be a good combination for people. :)
- justinclift 8y agoIt turns out there are even Raspberry Pi specific examples in their docs: https://github.com/gen2brain/raylib-go/tree/master/examples/others/rpi/basic_window https://github.com/gen2brain/raylib-go/tree/master/examples/...
- holografix 8y agoNo mention of Ebiten? https://hajimehoshi.github.io/ebiten/ https://hajimehoshi.github.io/ebiten/
- geoka9 8y agoNot sure about game programming, but I really liked this for a portable browser-based GUI for my Go apps: https://github.com/icza/gowut/wiki https://github.com/icza/gowut/wiki