diff --git a/main.go b/main.go index 6730bc0..5aa48a7 100644 --- a/main.go +++ b/main.go @@ -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() } diff --git a/resources/models/goonion.mtl b/resources/models/goonion.mtl index 02a93c1..1fa6c60 100644 --- a/resources/models/goonion.mtl +++ b/resources/models/goonion.mtl @@ -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