package game import "core:fmt" import rl "vendor:raylib" import rand "core:math/rand" import "core:strconv" import "core:mem" import "core:strings" player : Player world : World camera : rl.Camera2D main :: proc() { rl.InitWindow(1280, 720, "Odin game") player.position.x = CELL_SIZE * 5 player.position.y = CELL_SIZE * 5 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} load_tilemap() defer unload_tilemap() fill_world_grid_with_nothing(&world) random_trees(&world) game_loop() } game_loop :: proc() { pos_string : string pos_cstring : cstring for !rl.WindowShouldClose() { update() rl.BeginDrawing() rl.ClearBackground(rl.BLACK) rl.BeginMode2D(camera) draw() rl.EndMode2D() rl.DrawFPS(5,5) pos_string = fmt.aprint("Player POS:", get_player_grid_position(&player)) pos_cstring = strings.clone_to_cstring(pos_string) rl.DrawText(pos_cstring, 5, 25, 20, rl.RED) rl.EndDrawing() } delete(pos_string) delete(pos_cstring) } update :: proc() { camera.target = {player.position.x + (CELL_SIZE / 2), player.position.y + (CELL_SIZE / 2)} handle_player_input(&player) } draw :: proc() { draw_world(&world) draw_player(&player) } random_trees :: proc(world:^World) { for x in 0..