strife:一个Go中使用的简单2D游戏框架

网友投稿 959 2022-10-28

strife:一个Go中使用的简单2D游戏框架

strife:一个Go中使用的简单2D游戏框架

strife

A simple game framework that wraps around SDL2.

example

The biggest example use of the Strife framework is the Phi text editor

Though there are some smaller examples demonstrating components of the Strife API in the examples/ folder.

note/disclaimer

This is a work in progress. It provides a very minimal toolset for rendering shapes, images, and text as well as capturing user input. This is not at a production level and is mostly being worked on when the needs of my other projects (that depend on this) evolve.

There is no documentation either! If you want to use it you will have to check out the examples. I may get round to writing some documentation but the API is very volatile at the moment.

installing

Simple as

$ go get github.com/felixangell/strife

Make sure you have SDL2 installed as well as the ttf and img addons:

$ brew install SDL2 SDL2_ttf SDL2_img

getting started

This is a commented code snippet to help you get started:

func main() { // create a nice shiny window window := strife.SetupRenderWindow(1280, 720, strife.DefaultConfig()) window.SetTitle("Hello world!") window.SetResizable(true) window.Create() // this is our event handler window.HandleEvents(func(evt strife.StrifeEvent) { switch event := evt.(type) { case *strife.CloseEvent: println("closing window!") window.Close() case *strife.WindowResizeEvent: println("resize to ", event.Width, "x", event.Height) } }) // game loop for { // handle the events before we do any // rendering etc. window.PollEvents() // if we have a window close event // from the previous poll, break out of // our game loop if window.CloseRequested() { break } // rendering context stuff here // clear and display is typical // all your rendering code should // go... ctx := window.GetRenderContext() ctx.Clear() { // ...in this section here ctx.SetColor(strife.Red) ctx.Rect(10, 10, 50, 50, strife.Fill) // check out some other examples! } ctx.Display() }}

license

MIT

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:sharding-method- 全数据库兼容的服务层 Sharding 框架
下一篇:php设计模式之桥接模式
相关文章

 发表评论

暂时没有评论,来抢沙发吧~