Move tile drawing into game renderer
This commit is contained in:
parent
8a33bb68aa
commit
b61b01a4aa
2 changed files with 10 additions and 10 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package renderer
|
||||
|
||||
import (
|
||||
"pacman/engine/render"
|
||||
"pacman/game/world"
|
||||
)
|
||||
|
||||
|
|
@ -9,7 +8,7 @@ import (
|
|||
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))
|
||||
DrawTile(x+tile_x, y+tile_y, maze.At(tile_x, tile_y))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package render
|
||||
package renderer
|
||||
|
||||
import (
|
||||
"pacman/engine/render"
|
||||
"pacman/game/assets"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
|
|
@ -13,8 +14,8 @@ import (
|
|||
//
|
||||
// The appearance of the tile is determined by the provided assets.Tile value.
|
||||
func DrawTile(x, y uint8, tile assets.Tile) {
|
||||
px := int32(x) * TileSize
|
||||
py := int32(y) * TileSize
|
||||
px := int32(x) * render.TileSize
|
||||
py := int32(y) * render.TileSize
|
||||
|
||||
// For now, just draw simple circles and rectangles.
|
||||
switch tile {
|
||||
|
|
@ -29,18 +30,18 @@ func DrawTile(x, y uint8, tile assets.Tile) {
|
|||
case assets.TILE_CLYDE:
|
||||
drawGhost(px, py, rl.Orange)
|
||||
case assets.TILE_PELLET:
|
||||
rl.DrawCircle(px+(TileSize/2), py+(TileSize/2), 1, rl.Beige)
|
||||
rl.DrawCircle(px+(render.TileSize/2), py+(render.TileSize/2), 1, rl.Beige)
|
||||
case assets.TILE_POWER_PELLET:
|
||||
rl.DrawCircle(px+(TileSize/2), py+(TileSize/2), 2, rl.Beige)
|
||||
rl.DrawCircle(px+(render.TileSize/2), py+(render.TileSize/2), 2, rl.Beige)
|
||||
case assets.TILE_WALL:
|
||||
rl.DrawRectangle(px, py, TileSize, TileSize, rl.DarkBlue)
|
||||
rl.DrawRectangle(px, py, render.TileSize, render.TileSize, rl.DarkBlue)
|
||||
}
|
||||
}
|
||||
|
||||
func drawGhost(x, y int32, col rl.Color) {
|
||||
rl.DrawCircle(x+(TileSize/2), y+(TileSize/2), 3, col)
|
||||
rl.DrawCircle(x+(render.TileSize/2), y+(render.TileSize/2), 3, col)
|
||||
}
|
||||
|
||||
func drawPacman(x, y int32) {
|
||||
rl.DrawCircle(x+(TileSize/2), y+(TileSize/2), 3, rl.Yellow)
|
||||
rl.DrawCircle(x+(render.TileSize/2), y+(render.TileSize/2), 3, rl.Yellow)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue