feat: add Game of Life simulation mechanics
Implement Conway rules with tick timing, pause/resume, single stepping, speed control, and paused-only cell editing with drag painting. Update default key bindings for pause/step/speed. Mark verification complete.
This commit is contained in:
@@ -60,11 +60,14 @@ int config_parse_mods(const char *s, uint32_t *out_mods, char **out_key) {
|
||||
while (t) {
|
||||
char *tt = trim(t);
|
||||
if (*tt) {
|
||||
char *alias = tt;
|
||||
if (strcmp(tt, "+") == 0) alias = "plus";
|
||||
else if (strcmp(tt, "-") == 0) alias = "minus";
|
||||
if (n == cap) {
|
||||
cap = cap ? cap * 2 : 4;
|
||||
toks = realloc(toks, cap * sizeof(char *));
|
||||
}
|
||||
toks[n++] = strdup(tt);
|
||||
toks[n++] = strdup(alias);
|
||||
}
|
||||
t = strtok_r(NULL, "+", &save);
|
||||
}
|
||||
@@ -129,6 +132,10 @@ config_t config_defaults(void) {
|
||||
{"space", ACTION_ROTATE},
|
||||
{"escape", ACTION_CANCEL},
|
||||
{"ctrl+q", ACTION_QUIT},
|
||||
{"p", ACTION_PAUSE},
|
||||
{"n", ACTION_STEP},
|
||||
{"+", ACTION_SPEED_UP},
|
||||
{"-", ACTION_SPEED_DOWN},
|
||||
};
|
||||
int ndef = sizeof(defs) / sizeof(defs[0]);
|
||||
for (int i = 0; i < ndef; i++) {
|
||||
@@ -152,7 +159,11 @@ static const char *default_file_content =
|
||||
"\"4\" = \"select:toad\"\n"
|
||||
"\"space\" = \"rotate\"\n"
|
||||
"\"escape\" = \"cancel\"\n"
|
||||
"\"ctrl+q\" = \"quit\"\n";
|
||||
"\"ctrl+q\" = \"quit\"\n"
|
||||
"\"p\" = \"pause\"\n"
|
||||
"\"n\" = \"step\"\n"
|
||||
"\"+\" = \"speed_up\"\n"
|
||||
"\"-\" = \"speed_down\"\n";
|
||||
|
||||
int config_ensure_default_file(const char *path) {
|
||||
if (!path) return -1;
|
||||
|
||||
Reference in New Issue
Block a user