Last active
August 29, 2018 04:03
-
-
Save Verdagon/f950c7e9917b2b866801e732d2a34eeb to your computer and use it in GitHub Desktop.
First working roguelike!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let board = | |
__MutArray(10, {(row) | |
__MutArray(10, {(col) | |
= if {row == 0} { "#" } | |
else if {col == 0} { "#" } | |
else if {row == 9} { "#" } | |
else if {col == 9} { "#" } | |
else { "." } | |
}) | |
}); | |
let mut playerRow = 4; | |
let mut playerCol = 3; | |
let mut running = true; | |
while {running} { | |
__MutArray(10, {(rowI) | |
let row = board.(rowI); | |
__MutArray(10, {(colI) | |
let cell = row.(colI); | |
if {and(rowI == playerRow, colI == playerCol)} { | |
print("@"); | |
} else { | |
print(cell); | |
} | |
}); | |
println(""); | |
}); | |
let key = __getch(); | |
println(key); | |
if {key == 81} { | |
mut (running) = false; | |
} else if {key == 119} { | |
mut (playerRow) = playerRow + -1; | |
} else if {key == 115} { | |
mut (playerRow) = playerRow + 1; | |
} else if {key == 97} { | |
mut (playerCol) = playerCol + -1; | |
} else if {key == 100} { | |
mut (playerCol) = playerCol + 1; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment