More tilemap stuff
This commit is contained in:
@@ -30,7 +30,7 @@ main :: proc() {
|
|||||||
sprite = load_sprite(PLAYER_SPRITE_PATH, PLAYER_WIDTH, PLAYER_HEIGHT),
|
sprite = load_sprite(PLAYER_SPRITE_PATH, PLAYER_WIDTH, PLAYER_HEIGHT),
|
||||||
}
|
}
|
||||||
|
|
||||||
player.state = .WALKING
|
set_tile(grid, 10, 10, nothing_tile)
|
||||||
|
|
||||||
for (!raylib.WindowShouldClose()) {
|
for (!raylib.WindowShouldClose()) {
|
||||||
|
|
||||||
@@ -42,9 +42,11 @@ main :: proc() {
|
|||||||
|
|
||||||
raylib.DrawText("Ur mom", 100, 100, 50, raylib.BLACK)
|
raylib.DrawText("Ur mom", 100, 100, 50, raylib.BLACK)
|
||||||
|
|
||||||
|
|
||||||
draw()
|
draw()
|
||||||
|
|
||||||
raylib.EndMode2D()
|
raylib.EndMode2D()
|
||||||
|
raylib.DrawFPS(20, 20)
|
||||||
raylib.EndDrawing()
|
raylib.EndDrawing()
|
||||||
|
|
||||||
update(delta)
|
update(delta)
|
||||||
|
|||||||
@@ -88,3 +88,7 @@ update_tile_anim :: proc(tile: ^Tile, delta: f32) {
|
|||||||
tile.frame_index = tile.animator.current_frame
|
tile.frame_index = tile.animator.current_frame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_tile :: proc(grid: [][]Tile, x: int, y: int, tile: Tile) {
|
||||||
|
grid[x][y] = tile
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ draw_tile_grid :: proc(sheet: ^TilemapSpritesheet, grid: [][]Tile) {
|
|||||||
row := grid[y]
|
row := grid[y]
|
||||||
for x := 0; x < len(row); x += 1 {
|
for x := 0; x < len(row); x += 1 {
|
||||||
tile := &row[x]
|
tile := &row[x]
|
||||||
|
if (tile.type == TileType.NOTHING) do continue
|
||||||
pos := raylib.Vector2{f32(x * int(sheet.tile_width)), f32(y * int(sheet.tile_height))}
|
pos := raylib.Vector2{f32(x * int(sheet.tile_width)), f32(y * int(sheet.tile_height))}
|
||||||
draw_tile(sheet, tile, pos, raylib.Color{255, 136, 0, 255})
|
draw_tile(sheet, tile, pos, raylib.Color{255, 136, 0, 255})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user