Refactor into cmd, engine and game packages to make the code more clear
This commit is contained in:
parent
ebf8e820f1
commit
dd37379bc5
9 changed files with 6 additions and 6 deletions
40
cmd/main/game.go
Normal file
40
cmd/main/game.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"pacman/engine/render"
|
||||
"pacman/game/assets"
|
||||
"pacman/game/world"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
// Define the window's size
|
||||
const (
|
||||
WINDOW_WIDTH = render.WIDTH * 3
|
||||
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)
|
||||
|
||||
rl.InitWindow(WINDOW_WIDTH, WINDOW_HEIGH, "pacman")
|
||||
defer rl.CloseWindow()
|
||||
|
||||
// Initialize renderer
|
||||
render.Init()
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
render.Begin()
|
||||
DrawMaze(&maze, 0, 2)
|
||||
render.End()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue