Created
August 29, 2018 04:02
-
-
Save Verdagon/9ecda8f72bbc1a045a430f799f43edeb to your computer and use it in GitHub Desktop.
Eventual 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 = | |
Array(10, {(row) | |
Array(10, {(col) | |
= if (row == 0 or col == 0 or row == 9 or col == 9) { "#" } | |
else { "." } | |
}) | |
}); | |
let mut playerRow = 4; | |
let mut playerCol = 3; | |
let mut running = true; | |
while (running) { | |
each board {(row) | |
each board {(cell) | |
if (rowI == playerRow and 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