Exemplo n.º 1
0
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,
	}
}
Exemplo n.º 2
0
func NewBall() *Ball {
	rect := ein.NewRect(ScreenCenterX, ScreenCenterY, 10, 10)
	return &Ball{rect, initialVelocity, initialVelocity}
}
Exemplo n.º 3
0
func NewBat(x int32) *Bat {
	rect := ein.NewRect(x, ScreenCenterY-50, 10, 100)
	return &Bat{Rect: rect}
}