예제 #1
0
파일: game.go 프로젝트: syndr0m/gotris
func Game(engine *mygameengine.MyGameEngine) *mygameengine.Board {
	loadAssets(engine)
	gameBoard := mygameengine.NewBoard()
	world := NewWorld()
	world.OnGameOver(func() {
		world.Stop()
		engine.Boards().SetCurrent(engine.Boards().Get("intro"))
	})
	gameBoard.OnStart(world.Start)
	gameBoard.OnKeyDown(keyHandler(world))
	gameBoard.OnRepaint(repaintHandler(engine, world))
	return gameBoard
}
예제 #2
0
파일: intro.go 프로젝트: syndr0m/gotris
func Intro(engine *mygameengine.MyGameEngine) *mygameengine.Board {
	engine.Assets().Png(IMG_ROTATING_BG)
	engine.Assets().Png(IMG_TITLE)
	engine.Assets().Png(IMG_PRESS_SPACE)

	intro := mygameengine.NewBoard()
	intro.OnKeyDown(func(key int) {
		fmt.Println("intro: KEY DOWN", key)
		if key == mygameengine.KEY_SPACE {
			engine.Boards().SetCurrent(engine.Boards().Get("game"))
		}
	})
	intro.OnRepaint(func(screen *image.Image) {
		frame := intro.GetFrame()
		drawIntroBackground(screen, frame, engine.Assets().Get(IMG_ROTATING_BG))
		screen.BlitAt(engine.Assets().Get(IMG_TITLE), 130, 140)
		drawIntroText(screen, frame, engine.Assets().Get(IMG_PRESS_SPACE))
		drawIntroMask(screen, frame, engine.GetFps())
	})
	return intro
}