Beispiel #1
0
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
}
Beispiel #2
0
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
}