add model and texture of the goonion

This commit is contained in:
bdnugget 2024-10-02 14:46:36 +02:00
parent d3de2401f3
commit d4e299c72b
2 changed files with 15 additions and 6 deletions

19
main.go
View File

@ -78,14 +78,15 @@ func DrawMap(mapGrid [][]Tile) {
}
}
func DrawPlayer(player Player, mapGrid [][]Tile) {
func DrawPlayer(player Player, model *rl.Model, mapGrid [][]Tile) {
// Draw the player based on its actual position (PosActual) and current tile height
playerPos := rl.Vector3{
X: player.PosActual.X,
Y: mapGrid[player.PosTile.X][player.PosTile.Y].Height * TileHeight,
Y: mapGrid[player.PosTile.X][player.PosTile.Y].Height*TileHeight + 16.0,
Z: player.PosActual.Z,
}
rl.DrawCube(playerPos, 16, 16, 16, rl.Green) // Draw player cube
// rl.DrawCube(playerPos, 16, 16, 16, rl.Green) // Draw player cube
rl.DrawModel(*model, playerPos, 16, rl.White)
}
func GetTileAtMouse(mapGrid [][]Tile, camera *rl.Camera3D) (Tile, bool) {
@ -208,11 +209,18 @@ func UpdateCamera(camera *rl.Camera3D, player rl.Vector3, deltaTime float32) {
}
func main() {
rl.InitWindow(800, 600, "goonscape")
rl.InitWindow(800, 600, "GoonScape")
defer rl.CloseWindow()
rl.InitAudioDevice()
defer rl.CloseAudioDevice()
model := rl.LoadModel("resources/models/goonion.obj")
defer rl.UnloadModel(model)
tex := rl.LoadTexture("resources/models/goonion.png")
defer rl.UnloadTexture(tex)
rl.SetMaterialTexture(model.Materials, rl.MapDiffuse, tex)
mapGrid := InitMap()
player := Player{
@ -260,7 +268,8 @@ func main() {
rl.ClearBackground(rl.RayWhite)
rl.BeginMode3D(camera)
DrawMap(mapGrid)
DrawPlayer(player, mapGrid)
DrawPlayer(player, &model, mapGrid)
rl.EndMode3D()
rl.EndDrawing()
}

View File

@ -9,4 +9,4 @@ Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd Minion_full_body_A__1002112559.png
map_Kd goonion.png