ebiten/example/main.go

66 lines
1.4 KiB
Go
Raw Normal View History

2013-07-05 15:25:45 +02:00
package main
import (
2013-10-14 04:34:58 +02:00
"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"
2013-10-18 19:58:00 +02:00
"github.com/hajimehoshi/go-ebiten/example/game/testpattern"
2013-10-14 17:49:30 +02:00
"github.com/hajimehoshi/go-ebiten/ui"
2013-10-14 04:34:58 +02:00
"github.com/hajimehoshi/go-ebiten/ui/cocoa"
2013-10-15 02:12:43 +02:00
"github.com/hajimehoshi/go-ebiten/ui/glut"
2013-07-05 15:25:45 +02:00
"os"
"runtime"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
gameName := ""
if 2 <= len(os.Args) {
gameName = os.Args[1]
}
2013-10-15 02:12:43 +02:00
uiName := "cocoa"
if 3 <= len(os.Args) {
uiName = os.Args[2]
}
2013-07-05 15:25:45 +02:00
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()
2013-10-15 02:12:43 +02:00
default:
fallthrough
2013-07-05 15:25:45 +02:00
case "rotating":
game = rotating.New()
case "sprites":
game = sprites.New()
2013-10-18 19:58:00 +02:00
case "testpattern":
game = testpattern.New()
2013-07-05 15:25:45 +02:00
}
2013-10-15 02:12:43 +02:00
const screenWidth = 256
const screenHeight = 240
2013-07-05 15:25:45 +02:00
const screenScale = 2
2013-10-15 02:12:43 +02:00
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)
2013-07-05 15:25:45 +02:00
}