Example #1
0
func NewPlayer(id string, name string, out chan<- packet.Packet) (player *Player) {
	player = new(Player)
	player.id = id
	player.Name = name
	player.out = out
	actor.Init("player:"+id, &player.Actor, player)

	out <- packet.Packet{
		Handshake: &packet.Handshake{
			ID: player.ID,
		},
	}

	world.Send <- actor.AddHeld{&player.Actor}
	world.onConnect <- out
	return
}
Example #2
0
func NewPlayer(isLocalPlayer, monkey bool) *Player {
	player := new(Player)
	player.isLocalPlayer = isLocalPlayer
	player.paint = new(PaintContext)
	if monkey {
		player.paint.Sprite = res.Monkey
	} else {
		player.paint.Sprite = res.HumanSuit
	}
	if isLocalPlayer {
		player.paint.Changed = time.Now()
	}
	paintLock.Lock()
	paintContexts[&player.Actor] = player.paint
	paintLock.Unlock()
	actor.Init("client:player", &player.Actor, player)
	return player
}