ebiten/example/main.go
2013-10-19 02:58:00 +09:00

66 lines
1.4 KiB
Go

package main
import (
"github.com/hajimehoshi/go-ebiten"
"github.com/hajimehoshi/go-ebiten/example/game/blank"
"github.com/hajimehoshi/go-ebiten/example/game/input"
"github.com/hajimehoshi/go-ebiten/example/game/monochrome"
"github.com/hajimehoshi/go-ebiten/example/game/rects"
"github.com/hajimehoshi/go-ebiten/example/game/rotating"
"github.com/hajimehoshi/go-ebiten/example/game/sprites"
"github.com/hajimehoshi/go-ebiten/example/game/testpattern"
"github.com/hajimehoshi/go-ebiten/ui"
"github.com/hajimehoshi/go-ebiten/ui/cocoa"
"github.com/hajimehoshi/go-ebiten/ui/glut"
"os"
"runtime"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
gameName := ""
if 2 <= len(os.Args) {
gameName = os.Args[1]
}
uiName := "cocoa"
if 3 <= len(os.Args) {
uiName = os.Args[2]
}
var game ebiten.Game
switch gameName {
case "blank":
game = blank.New()
case "input":
game = input.New()
case "monochrome":
game = monochrome.New()
case "rects":
game = rects.New()
default:
fallthrough
case "rotating":
game = rotating.New()
case "sprites":
game = sprites.New()
case "testpattern":
game = testpattern.New()
}
const screenWidth = 256
const screenHeight = 240
const screenScale = 2
const title = "Ebiten Demo"
var u ui.UI
switch uiName {
default:
fallthrough
case "cocoa":
u = cocoa.New(screenWidth, screenHeight, screenScale, title)
case "glut":
u = glut.New(screenWidth, screenHeight, screenScale, title)
}
ui.Run(u, game)
}