cleanup
This commit is contained in:
parent
46910fa0e7
commit
a784f7bb98
1 changed files with 11 additions and 20 deletions
17
main.odin
17
main.odin
|
@ -4,22 +4,14 @@ import "core:fmt"
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
import "core:time"
|
import "core:time"
|
||||||
|
|
||||||
WIDTH :: 128
|
WIDTH :: 64
|
||||||
HEIGHT :: 128
|
HEIGHT :: 64
|
||||||
AREA :: WIDTH * HEIGHT
|
AREA :: WIDTH * HEIGHT
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
board : [AREA]bool = ---
|
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
|
fmt.print("\e[2J") // clear screen
|
||||||
for {
|
for {
|
||||||
fmt.print("\e[u") // reset cursor
|
|
||||||
print_board(&board)
|
print_board(&board)
|
||||||
update_board(&board)
|
update_board(&board)
|
||||||
time.sleep(time.Millisecond * 50)
|
time.sleep(time.Millisecond * 50)
|
||||||
|
@ -27,6 +19,7 @@ main :: proc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_board :: proc(state: ^[AREA]bool) {
|
print_board :: proc(state: ^[AREA]bool) {
|
||||||
|
fmt.print("\e[u") // reset cursor
|
||||||
for y := 0; y < HEIGHT; y += 2 {
|
for y := 0; y < HEIGHT; y += 2 {
|
||||||
line := strings.builder_make()
|
line := strings.builder_make()
|
||||||
defer strings.builder_destroy(&line)
|
defer strings.builder_destroy(&line)
|
||||||
|
@ -57,9 +50,7 @@ update_board :: proc(state: ^[AREA]bool) {
|
||||||
px := (x + dx + WIDTH) % WIDTH
|
px := (x + dx + WIDTH) % WIDTH
|
||||||
for dy in -1..=1 {
|
for dy in -1..=1 {
|
||||||
py := (y + dy + HEIGHT) % HEIGHT
|
py := (y + dy + HEIGHT) % HEIGHT
|
||||||
if state[px + py * WIDTH]{
|
if state[px + py * WIDTH] do count += 1
|
||||||
count += 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cell := state[x + y * WIDTH]
|
cell := state[x + y * WIDTH]
|
||||||
|
|
Loading…
Reference in a new issue