Draw maze to screen.
This commit is contained in:
parent
a4875fc79b
commit
a3575b5024
1 changed files with 31 additions and 8 deletions
|
|
@ -1,17 +1,40 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"pacman/assets"
|
||||||
|
"pacman/render"
|
||||||
|
"pacman/world"
|
||||||
|
|
||||||
rl "github.com/gen2brain/raylib-go/raylib"
|
rl "github.com/gen2brain/raylib-go/raylib"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
// Define the window's size
|
||||||
rl.InitWindow(400, 300, "pacman")
|
const (
|
||||||
defer rl.CloseWindow()
|
WINDOW_WIDTH = render.WIDTH * 3
|
||||||
|
WINDOW_HEIGH = render.HEIGHT * 3
|
||||||
|
)
|
||||||
|
|
||||||
for !rl.WindowShouldClose() {
|
// Draw the maze.
|
||||||
rl.BeginDrawing()
|
func DrawMaze(maze *world.Maze, x, y uint8) {
|
||||||
rl.ClearBackground(rl.Black)
|
for tile_x := range uint8(world.MAZE_WIDTH) {
|
||||||
rl.DrawText("Hello World", 0, 0, 24, rl.White)
|
for tile_y := range uint8(world.MAZE_HEIGHT) {
|
||||||
rl.EndDrawing()
|
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