ebiten/example/main.go

37 lines
678 B
Go
Raw Normal View History

2013-07-05 15:25:45 +02:00
package main
import (
2014-12-06 22:03:13 +01:00
"flag"
2014-12-05 14:16:58 +01:00
"github.com/hajimehoshi/ebiten/example/blocks"
"github.com/hajimehoshi/ebiten/ui"
2014-12-05 18:26:02 +01:00
"github.com/hajimehoshi/ebiten/ui/glfw"
2014-12-06 22:03:13 +01:00
"log"
"os"
2013-07-05 15:25:45 +02:00
"runtime"
2014-12-06 22:03:13 +01:00
"runtime/pprof"
2013-07-05 15:25:45 +02:00
)
2013-12-18 10:05:28 +01:00
func init() {
runtime.LockOSThread()
2013-12-07 17:35:24 +01:00
}
2014-12-06 22:03:13 +01:00
var cpuProfile = flag.String("cpuprofile", "", "write cpu profile to file")
2013-07-05 15:25:45 +02:00
func main() {
2014-12-06 22:03:13 +01:00
flag.Parse()
if *cpuProfile != "" {
f, err := os.Create(*cpuProfile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
2014-12-05 18:26:02 +01:00
u := new(glfw.UI)
2014-12-06 17:09:59 +01:00
game := blocks.NewGame()
2014-12-06 22:03:13 +01:00
if err := ui.Run(u, game, blocks.ScreenWidth, blocks.ScreenHeight, 2, "Ebiten Demo", 60); err != nil {
log.Fatal(err)
}
2013-07-05 15:25:45 +02:00
}