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,46 +0,0 @@
|
|||
package render
|
||||
|
||||
import (
|
||||
"pacman/game/assets"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
// DrawTile draws a single tile at the specified tile coordinates (x, y).
|
||||
//
|
||||
// The coordinates are in tile space, not pixels. The top-left tile is (0, 0),
|
||||
// and the bottom-right is (27, 35) given the fixed resolution and tile size.
|
||||
//
|
||||
// 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
|
||||
|
||||
// For now, just draw simple circles and rectangles.
|
||||
switch tile {
|
||||
case assets.TILE_PACMAN:
|
||||
drawPacman(px, py)
|
||||
case assets.TILE_BLINKY:
|
||||
drawGhost(px, py, rl.Red)
|
||||
case assets.TILE_PINKY:
|
||||
drawGhost(px, py, rl.Pink)
|
||||
case assets.TILE_INKY:
|
||||
drawGhost(px, py, rl.Blue)
|
||||
case assets.TILE_CLYDE:
|
||||
drawGhost(px, py, rl.Orange)
|
||||
case assets.TILE_PELLET:
|
||||
rl.DrawCircle(px+(TileSize/2), py+(TileSize/2), 1, rl.Beige)
|
||||
case assets.TILE_POWER_PELLET:
|
||||
rl.DrawCircle(px+(TileSize/2), py+(TileSize/2), 2, rl.Beige)
|
||||
case assets.TILE_WALL:
|
||||
rl.DrawRectangle(px, py, TileSize, TileSize, rl.DarkBlue)
|
||||
}
|
||||
}
|
||||
|
||||
func drawGhost(x, y int32, col rl.Color) {
|
||||
rl.DrawCircle(x+(TileSize/2), y+(TileSize/2), 3, col)
|
||||
}
|
||||
|
||||
func drawPacman(x, y int32) {
|
||||
rl.DrawCircle(x+(TileSize/2), y+(TileSize/2), 3, rl.Yellow)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue