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
28
engine/render/tile.go
Normal file
28
engine/render/tile.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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_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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue