From a784f7bb98bac695e6059cff3bf62931444d0e2e Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Thu, 2 May 2024 13:27:53 +0200 Subject: [PATCH] cleanup --- main.odin | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/main.odin b/main.odin index 882e0a8..97bbf7f 100644 --- a/main.odin +++ b/main.odin @@ -4,22 +4,14 @@ import "core:fmt" import "core:strings" import "core:time" -WIDTH :: 128 -HEIGHT :: 128 +WIDTH :: 64 +HEIGHT :: 64 AREA :: WIDTH * HEIGHT main :: proc() { board : [AREA]bool = --- - - // board[0] = true - // board[1] = true - // board[WIDTH] = true - // for x in 4..<14 { - // board[x + WIDTH*8] = true - // } fmt.print("\e[2J") // clear screen for { - fmt.print("\e[u") // reset cursor print_board(&board) update_board(&board) time.sleep(time.Millisecond * 50) @@ -27,12 +19,13 @@ main :: proc() { } print_board :: proc(state: ^[AREA]bool) { - for y := 0; y < HEIGHT; y += 2{ + fmt.print("\e[u") // reset cursor + for y := 0; y < HEIGHT; y += 2 { line := strings.builder_make() defer strings.builder_destroy(&line) - for x in 0.. 2) - new_state[x + y * WIDTH] = new_cell + } + cell := state[x + y * WIDTH] + new_cell := (count == 3 && !cell) || (cell && count < 5 && count > 2) + new_state[x + y * WIDTH] = new_cell } } for i in 0..