Different model per player

This commit is contained in:
bdnugget 2024-10-11 15:58:09 +02:00
parent 1c42ec2802
commit c7f7c083b1

18
main.go
View File

@ -50,6 +50,8 @@ type Player struct {
TargetPath []Tile
Speed float32
ActionQueue []Action // Queue for player actions
Model rl.Model
Texture rl.Texture2D
}
// Initialize the map with some height data
@ -325,6 +327,18 @@ func main() {
defer rl.UnloadTexture(coomerTexture)
rl.SetMaterialTexture(coomerModel.Materials, rl.MapDiffuse, coomerTexture)
models := []struct {
Model rl.Model
Texture rl.Texture2D
}{
{Model: playerModel, Texture: playerTexture},
{Model: coomerModel, Texture: coomerTexture},
}
modelIndex := int(playerID) % len(models)
player.Model = models[modelIndex].Model
player.Texture = models[modelIndex].Texture
rl.SetTargetFPS(60)
// Music
@ -356,9 +370,9 @@ func main() {
rl.ClearBackground(rl.RayWhite)
rl.BeginMode3D(camera)
DrawMap(mapGrid)
DrawPlayer(player, &playerModel, mapGrid)
DrawPlayer(player, &player.Model, mapGrid)
rl.DrawModel(coomerModel, rl.NewVector3(5*TileSize+32, 32, 5*TileSize+32), 16, rl.White)
// rl.DrawModel(coomerModel, rl.NewVector3(5*TileSize+32, 32, 5*TileSize+32), 16, rl.White)
rl.DrawFPS(10, 10)