Move maze drawing into renderer package
This commit is contained in:
parent
dd37379bc5
commit
c6b2a837b0
2 changed files with 17 additions and 10 deletions
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"pacman/engine/render"
|
||||
"pacman/game/assets"
|
||||
"pacman/game/renderer"
|
||||
"pacman/game/world"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
|
|
@ -14,15 +15,6 @@ const (
|
|||
WINDOW_HEIGH = render.HEIGHT * 3
|
||||
)
|
||||
|
||||
// Draw the maze.
|
||||
func DrawMaze(maze *world.Maze, x, y uint8) {
|
||||
for tile_x := range uint8(world.MAZE_WIDTH) {
|
||||
for tile_y := range uint8(world.MAZE_HEIGHT) {
|
||||
render.DrawTile(x+tile_x, y+tile_y, maze.At(tile_x, tile_y))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
maze := world.NewMaze(assets.Level1)
|
||||
|
||||
|
|
@ -34,7 +26,7 @@ func main() {
|
|||
|
||||
for !rl.WindowShouldClose() {
|
||||
render.Begin()
|
||||
DrawMaze(&maze, 0, 2)
|
||||
renderer.DrawMaze(&maze, 0, 2)
|
||||
render.End()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
game/renderer/maze.go
Normal file
15
game/renderer/maze.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package renderer
|
||||
|
||||
import (
|
||||
"pacman/engine/render"
|
||||
"pacman/game/world"
|
||||
)
|
||||
|
||||
// DrawMaze - draws the maze.
|
||||
func DrawMaze(maze *world.Maze, x, y uint8) {
|
||||
for tile_x := range uint8(world.MAZE_WIDTH) {
|
||||
for tile_y := range uint8(world.MAZE_HEIGHT) {
|
||||
render.DrawTile(x+tile_x, y+tile_y, maze.At(tile_x, tile_y))
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue