示例#1
0
文件: game.go 项目: stephenbinns/ein
func NewGame() *Game {
	e := ein.Init(winWidth, winHeight)

	divider := ein.NewRect((ScreenCenterX)-5, 0, 10, winHeight)
	font := ein.LoadFont("Courier New.ttf", 64)
	bat1Label := ein.NewLabel("0", 100, 50, font)
	bat2Label := ein.NewLabel("0", 600, 50, font)

	bat1 := NewBat(10)
	bat2 := NewBat(winWidth - 20)
	ball := NewBall()

	e.AddEntities(ball, bat1, bat2, bat1Label, bat2Label, divider)

	return &Game{
		Engine:    e,
		bat1:      bat1,
		bat2:      bat2,
		ball:      ball,
		bat1Label: bat1Label,
		bat2Label: bat2Label,
	}
}
示例#2
0
文件: ball.go 项目: stephenbinns/ein
func NewBall() *Ball {
	rect := ein.NewRect(ScreenCenterX, ScreenCenterY, 10, 10)
	return &Ball{rect, initialVelocity, initialVelocity}
}
示例#3
0
文件: bat.go 项目: stephenbinns/ein
func NewBat(x int32) *Bat {
	rect := ein.NewRect(x, ScreenCenterY-50, 10, 100)
	return &Bat{Rect: rect}
}