why are the tiles still 24bytes...
This commit is contained in:
@@ -11,30 +11,32 @@ import "core:strings"
|
||||
player : Player
|
||||
world : World
|
||||
|
||||
camera : rl.Camera2D
|
||||
|
||||
main :: proc() {
|
||||
|
||||
rl.InitWindow(1280, 720, "Odin game")
|
||||
|
||||
flags : rl.ConfigFlags = {.VSYNC_HINT}
|
||||
rl.SetConfigFlags(flags)
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
player.position.x = CELL_SIZE * 5
|
||||
player.position.y = CELL_SIZE * 5
|
||||
player.mode = .INTERACT
|
||||
|
||||
camera.target = {player.position.x + (CELL_SIZE / 2), player.position.y + (CELL_SIZE / 2)}
|
||||
camera.zoom = 2
|
||||
camera.offset = {f32(rl.GetScreenWidth()) / 2, f32(rl.GetScreenHeight()) / 2}
|
||||
player = {
|
||||
position = {CELL_SIZE * 5, CELL_SIZE * 5},
|
||||
camera = {
|
||||
zoom = 2,
|
||||
target = {player.position.x + (CELL_SIZE / 2), player.position.y + (CELL_SIZE / 2)},
|
||||
offset = {f32(rl.GetScreenWidth()) / 2, f32(rl.GetScreenHeight()) / 2},
|
||||
},
|
||||
mode = .INTERACT,
|
||||
}
|
||||
|
||||
load_tilemap()
|
||||
defer unload_tilemap()
|
||||
|
||||
fill_world_grid_with_nothing(&world)
|
||||
world = create_world("test_world")
|
||||
load_nearby_chunks(&world, player.position)
|
||||
save_world(&world)
|
||||
|
||||
place_random_trees(&world)
|
||||
|
||||
game_loop()
|
||||
}
|
||||
@@ -50,7 +52,7 @@ game_loop :: proc() {
|
||||
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.BLACK)
|
||||
rl.BeginMode2D(camera)
|
||||
rl.BeginMode2D(player.camera)
|
||||
|
||||
draw()
|
||||
|
||||
@@ -59,7 +61,7 @@ game_loop :: proc() {
|
||||
rl.DrawFPS(5,5)
|
||||
|
||||
player_grid_pos := get_player_grid_position(&player)
|
||||
player_grid_pos_tile := get_grid_tile(&world, vec2_to_vec2i(player_grid_pos))
|
||||
player_grid_pos_tile := get_world_tile(&world, vec2_to_vec2i(player_grid_pos))
|
||||
status_string := rl.TextFormat("POS: %v : %v | MODE: %v", player_grid_pos, player_grid_pos_tile.type, player.mode)
|
||||
|
||||
rl.DrawText(status_string, 5, 25, 20, rl.RED)
|
||||
@@ -73,11 +75,7 @@ game_loop :: proc() {
|
||||
}
|
||||
|
||||
update :: proc() {
|
||||
|
||||
handle_player_input(&player, &world)
|
||||
handle_window_resize()
|
||||
camera.target = {player.position.x + (CELL_SIZE / 2), player.position.y + (CELL_SIZE / 2)}
|
||||
|
||||
player_update(&player, &world)
|
||||
}
|
||||
|
||||
draw :: proc() {
|
||||
@@ -85,16 +83,3 @@ draw :: proc() {
|
||||
draw_player(&player)
|
||||
}
|
||||
|
||||
handle_window_resize :: proc() {
|
||||
if rl.IsWindowResized() {
|
||||
camera.offset = {f32(rl.GetScreenWidth()) / 2, f32(rl.GetScreenHeight()) / 2}
|
||||
}
|
||||
}
|
||||
|
||||
print_grid :: proc() {
|
||||
for x in 0..< len(world.grid) {
|
||||
for y in 0..< len(world.grid) {
|
||||
fmt.printfln("[%d, %d] %v", x, y, world.grid[x][y].type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user