procgen #3
@ -25,7 +25,7 @@ main :: proc() {
|
|||||||
rl.SetTargetFPS(60)
|
rl.SetTargetFPS(60)
|
||||||
|
|
||||||
player = {
|
player = {
|
||||||
position = {CELL_SIZE * 10, CELL_SIZE * 10},
|
position = {CELL_SIZE * 10000, CELL_SIZE * 10000},
|
||||||
camera = {
|
camera = {
|
||||||
zoom = 4,
|
zoom = 4,
|
||||||
target = {player.position.x + (CELL_SIZE / 2), player.position.y + (CELL_SIZE / 2)},
|
target = {player.position.x + (CELL_SIZE / 2), player.position.y + (CELL_SIZE / 2)},
|
||||||
@ -37,7 +37,7 @@ main :: proc() {
|
|||||||
load_tilemap()
|
load_tilemap()
|
||||||
defer unload_tilemap()
|
defer unload_tilemap()
|
||||||
|
|
||||||
world = create_world("test_world", 23462547245)
|
world = create_world("test_world", 23456725245)
|
||||||
save_world(&world)
|
save_world(&world)
|
||||||
|
|
||||||
game_loop()
|
game_loop()
|
||||||
@ -65,7 +65,7 @@ game_loop :: proc() {
|
|||||||
player_grid_pos := get_player_grid_position(&player)
|
player_grid_pos := get_player_grid_position(&player)
|
||||||
player_grid_pos_tile := get_world_tile(&world, vec2_to_vec2i(player_grid_pos))
|
player_grid_pos_tile := get_world_tile(&world, vec2_to_vec2i(player_grid_pos))
|
||||||
current_chunk := get_chunk_from_world_pos(&world, player_grid_pos)
|
current_chunk := get_chunk_from_world_pos(&world, player_grid_pos)
|
||||||
status_string := rl.TextFormat("POS: [%i,%i] : %v | Chunk: %v : %v | MODE: %v", int(player_grid_pos.x), int(player_grid_pos.y), player_grid_pos_tile.type, current_chunk.position, get_biome_from_id(current_chunk.biome_id).name, player.mode)
|
status_string := rl.TextFormat("POS: [%i,%i] : %v | Chunk: [%i,%i] : %v | MODE: %v", int(player_grid_pos.x), int(player_grid_pos.y), player_grid_pos_tile.type, current_chunk.position.x, current_chunk.position.y, get_biome_from_id(current_chunk.biome_id).name, player.mode)
|
||||||
rl.DrawText(status_string, 5, 25, 20, rl.RED)
|
rl.DrawText(status_string, 5, 25, 20, rl.RED)
|
||||||
|
|
||||||
rl.EndDrawing()
|
rl.EndDrawing()
|
||||||
|
@ -93,7 +93,7 @@ handle_player_input :: proc(p:^Player, w:^World) {
|
|||||||
// Movement
|
// Movement
|
||||||
target_pos := get_player_grid_position(p)
|
target_pos := get_player_grid_position(p)
|
||||||
dt := rl.GetFrameTime()
|
dt := rl.GetFrameTime()
|
||||||
move_delay : f32 = 0.0
|
move_delay : f32 = 0.2
|
||||||
if p.move_timer > 0 {
|
if p.move_timer > 0 {
|
||||||
p.move_timer -= dt
|
p.move_timer -= dt
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ will_collide :: proc(w:^World, pos:rl.Vector2) -> bool {
|
|||||||
|
|
||||||
#partial switch tile.type {
|
#partial switch tile.type {
|
||||||
case .SOLID:
|
case .SOLID:
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
@ -149,7 +149,7 @@ get_biome_type :: proc(world_pos: Vec2i, seed: i64) -> Biome {
|
|||||||
|
|
||||||
// Adjust temperature to create larger hot regions
|
// Adjust temperature to create larger hot regions
|
||||||
// This skews the distribution to have more areas with higher temperature
|
// This skews the distribution to have more areas with higher temperature
|
||||||
temperature = math.pow(temperature * 0.5 + 0.5, 0.8) * 2.0 - 1.0
|
// temperature = math.pow(temperature * 0.5 + 0.5, 0.8) * 2.0 - 1.0
|
||||||
|
|
||||||
// Local variations (small details)
|
// Local variations (small details)
|
||||||
local_var := noise.noise_2d(seed, {f64(world_pos.x) * local_scale, f64(world_pos.y) * local_scale}) * 0.1
|
local_var := noise.noise_2d(seed, {f64(world_pos.x) * local_scale, f64(world_pos.y) * local_scale}) * 0.1
|
||||||
@ -162,18 +162,11 @@ get_biome_type :: proc(world_pos: Vec2i, seed: i64) -> Biome {
|
|||||||
normalized_moisture := moisture * 0.5 + 0.5
|
normalized_moisture := moisture * 0.5 + 0.5
|
||||||
normalized_temperature := temperature * 0.5 + 0.5
|
normalized_temperature := temperature * 0.5 + 0.5
|
||||||
|
|
||||||
// DEBUG: Uncomment to log values when testing
|
|
||||||
// fmt.println("pos:", world_pos, "temp:", normalized_temperature, "moisture:", normalized_moisture)
|
|
||||||
|
|
||||||
// Lakes appear in low elevation areas
|
|
||||||
if normalized_elevation < 0.3 {
|
if normalized_elevation < 0.3 {
|
||||||
return lake_biome
|
return lake_biome
|
||||||
}
|
}
|
||||||
|
|
||||||
// ADJUSTED: More generous desert conditions
|
if normalized_temperature > 0.6 && normalized_moisture < 0.3 {
|
||||||
// Deserts appear in hot OR dry areas (not requiring both)
|
|
||||||
// This makes deserts more common and creates larger desert regions
|
|
||||||
if normalized_temperature > 0.55 && normalized_moisture < 0.4 {
|
|
||||||
return desert_biome
|
return desert_biome
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user