Added player movement

This commit is contained in:
2024-01-26 17:14:20 +01:00
parent 2cd93f2a39
commit 8370afd9a1
12 changed files with 148 additions and 23 deletions

View File

@ -3,7 +3,6 @@ package game
import (
"crypto/rand"
"encoding/base64"
"encoding/binary"
"encoding/json"
"errors"
"net"
@ -46,20 +45,14 @@ func (game *Game) Login(data []byte, address *net.UDPAddr, server *Server) error
player.KeepAlive()
response := []byte{Success}
response = appendString(response, account.ID)
response = appendString(response, player.authToken)
response = AppendString(response, account.ID)
response = AppendString(response, player.authToken)
server.Send(packet.Login, response, address)
game.onLogin(player)
return nil
}
func appendString(data []byte, str string) []byte {
data = binary.LittleEndian.AppendUint32(data, uint32(len(str)))
data = append(data, []byte(str)...)
return data
}
// Inform the newly logged in player about existing players.
// Also inform existing players about the newly logged in player.
func (game *Game) onLogin(player *Player) {