summaryrefslogtreecommitdiff
path: root/Source/Applications/Demos/GOL.cpp
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-11-14 13:16:01 +0100
committerAlexis211 <alexis211@gmail.com>2009-11-14 13:16:01 +0100
commit4d5c1fcf9b1616db662a5cab0cec5ac878ce5175 (patch)
tree5ae433b358f933a9cec5bc9ef3c30ba9395fe322 /Source/Applications/Demos/GOL.cpp
parent2b9e97b8635c20c5a2b87789b1014489863d1994 (diff)
downloadMelon-4d5c1fcf9b1616db662a5cab0cec5ac878ce5175.tar.gz
Melon-4d5c1fcf9b1616db662a5cab0cec5ac878ce5175.zip
Changed some things in the way init is handled.
Also : - Modified stuff in the GOL simulator - Added support for a kernel-built-in keymap
Diffstat (limited to 'Source/Applications/Demos/GOL.cpp')
-rw-r--r--Source/Applications/Demos/GOL.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/Source/Applications/Demos/GOL.cpp b/Source/Applications/Demos/GOL.cpp
index 6dd1cdf..804c9ae 100644
--- a/Source/Applications/Demos/GOL.cpp
+++ b/Source/Applications/Demos/GOL.cpp
@@ -22,20 +22,22 @@ int main(Vector<String> args) {
}
}
- while (1) {
+ char *tmp = new char[w * h + 1];
+
+ bool run = true;
+ while (run) {
//Display cells
- outvt.moveCursor(0, 0);
for (u32int y = 0; y < h; y++) {
for (u32int x = 0; x < w; x++) {
if (cells[x * h + y]) {
- outvt.setColor(0, 2);
+ tmp[y * w + x] = '#';
} else {
- outvt.setColor(7, 0);
+ tmp[y * w + x] = ' ';
}
- outvt << " ";
}
}
- outvt << "Press Ctrl+h for help";
+ outvt.moveCursor(0, 0);
+ outvt << String(tmp, w*h) << "Press Ctrl+h for help";
//Compute next generation
for (u32int y = 0; y < h; y++) {
@@ -61,9 +63,9 @@ int main(Vector<String> args) {
}
keypress_t kp = invt.getKeypress(false, false);
- if (kp.hascmd && (kp.modifiers & STATUS_CTRL)) {
+ while (kp.hascmd && (kp.modifiers & STATUS_CTRL)) {
if (kp.character == WChar("c")) {
- break;
+ run = false;
} else if (kp.character == WChar("r")) {
for (u32int i = 0; i < 20; i++) {
u64int x = Rand::rand() * w / Rand::max();
@@ -75,16 +77,18 @@ int main(Vector<String> args) {
cells[i] = true;
cells[(2 * i) % (h - i)] = true;
cells[(w * i) % (h * w - i)] = true;
+ cells[(w * i) % (h * w - i) + w] = true;
}
} else if (kp.character == WChar("h")) {
- outvt << "** Melon's demo Game Of Life Simulator help :\n";
+ outvt << "\n\n** Melon's demo Game Of Life Simulator help :\n";
outvt << " - ctrl+c : quit\n";
outvt << " - ctrl+h : show this\n";
outvt << " - ctrl+r : add some random cells\n";
- outvt << " - ctrl+R : add more cells, but not random\n";
+ outvt << " - ctrl+R : add more cells, but not random\n\n";
outvt << "Press any key to return to simultaor...";
invt.getKeypress();
}
+ kp = invt.getKeypress(false, false);
}
Thread::get().sleep(100);