コード例 #1
0
ファイル: player.go プロジェクト: Biscuit911/gogame
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
}
コード例 #2
0
ファイル: player.go プロジェクト: Nightgunner5/gogame
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
}