Coder Social home page Coder Social logo

strife's Introduction

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

strife's People

Contributors

chyroc avatar felixangell avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.