Init
This commit is contained in:
35
game/tilemap.odin
Normal file
35
game/tilemap.odin
Normal file
@@ -0,0 +1,35 @@
|
||||
package game
|
||||
|
||||
import rl "vendor:raylib"
|
||||
|
||||
TILE_SIZE :: 16
|
||||
TILE_IMAGE_PATH :: "assets/tiles.png"
|
||||
|
||||
tilemap_image : rl.Texture2D
|
||||
|
||||
tilesX : i32
|
||||
tilesY : i32
|
||||
|
||||
load_tilemap :: proc() {
|
||||
tilemap_image = rl.LoadTexture(TILE_IMAGE_PATH)
|
||||
|
||||
tilesX = tilemap_image.width / TILE_SIZE
|
||||
tilesY = tilemap_image.height / TILE_SIZE
|
||||
}
|
||||
|
||||
unload_tilemap :: proc() {
|
||||
rl.UnloadTexture(tilemap_image)
|
||||
}
|
||||
|
||||
draw_tile :: proc(tilemap_pos:rl.Vector2, draw_pos:rl.Vector2, color:rl.Color) {
|
||||
source_rect := rl.Rectangle {
|
||||
x = tilemap_pos.x * TILE_SIZE,
|
||||
y = tilemap_pos.y * TILE_SIZE,
|
||||
width = TILE_SIZE,
|
||||
height = TILE_SIZE
|
||||
}
|
||||
|
||||
rl.DrawTextureRec(tilemap_image, source_rect, draw_pos, color)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user