Exemplo n.º 1
0
// New TODO doc
func New(x, offset, size float32, s *sprite.Context, group *sprite.Group) (*Wall, error) {
	// TODO should take a group in as a argument
	w := Wall{
		Sprite: s,
		width:  32.0 * 2,
		offset: offset,
		size:   size,
	}

	topRect, err := shapes.NewRect(640.0-w.width, w.offset+w.size/2.0, 64.0, 480.0)
	if err != nil {
		return &w, fmt.Errorf("could not create top rect: %v", err)
	}
	w.TopRect = topRect

	bottomRect, err := shapes.NewRect(640.0-w.width, w.offset-w.size/2.0, 64.0, 480.0)
	if err != nil {
		return &w, fmt.Errorf("could create bottom rect: %v", err)
	}
	w.BottomRect = bottomRect

	// TODO: this should probably be added outside of player
	group.Add(&w)
	return &w, nil
}
Exemplo n.º 2
0
// New TODO doc
func New(x, y float32, s *sprite.Context, group *sprite.Group) (*Player, error) {
	// TODO should take a group in as a argument
	p := Player{
		Sprite: s,
		Alive:  true,
	}

	rect, err := shapes.NewRect(x, y, float32(p.Sprite.Width), float32(p.Sprite.Height))
	if err != nil {
		return &p, fmt.Errorf("could create rect: %v", err)
	}
	p.Rect = rect

	// TODO: this should probably be added outside of player
	group.Add(&p)
	return &p, nil
}