plomlompom tries to build his own roguelike. Currently, it doesn't do
much interesting, apart from managing some ncurses windows in a bizarre
-fashion. You can move around a player and meet a number of different
-enemies. They move randomly and will only accidentally hit you. You have
-5 hitpoints to lose before death; they have either 1, 3 or 9. The map
-get generated randomly, too. There is only one save file (named
-"savefile"), and it gets overwritten each new turn. To start over with
-a new world, delete it.
+fashion.
+
+You can move around a player and meet a number of different enemies.
+They move randomly and will only accidentally hit you. You have 5
+hitpoints to lose before death; they have either 1, 3 or 9. Your score
+grows by killing enemies, to the amount of hitpoints each killed enemy
+started with.
+
+The map get generated randomly, too.
+
+There is only one save file (named "savefile"), and it gets overwritten
+each new turn. To start over with a new world, delete it.
Install/run
-----------
struct World * world = (struct World *) win->data;
char text[100];
snprintf(text, 100,
- "Turn: %d\nHitpoints: %d", world->turn, world->player->hitpoints);
+ "Turn: %d\nHitpoints: %d\nScore: %d",
+ world->turn, world->player->hitpoints, world->score);
draw_with_linebreaks(win, text, 0);
}
exit_err(0 == file, &world, err_o);
if ( read_uint32_bigendian(file, &world.seed)
|| read_uint32_bigendian(file, &world.turn)
+ || read_uint16_bigendian(file, &world.score)
|| read_uint16_bigendian(file, &player.pos.y)
|| read_uint16_bigendian(file, &player.pos.x)
|| read_uint8(file, &player.hitpoints)
else
{
world.seed = time(NULL);
+ world.score = 0;
err_o = "Trouble recording new seed (fopen() in main()) / "
"opening 'record_tmp' file for writing.";
struct Win win_keys = init_win(&win_meta, "Keys",
0, 29, &world, draw_keys_win);
struct Win win_info = init_win(&win_meta, "Info",
- 2, 20, &world, draw_info_win);
+ 3, 20, &world, draw_info_win);
uint16_t height_logwin = win_meta.padframe.size.y
- (2 + win_info.frame.size.y);
struct Win win_log = init_win(&win_meta, "Log",
struct KeysWinData * keyswindata; /* Pointer to key edit window metadata. */
uint32_t seed; /* Randomness seed. */
uint32_t turn; /* Current game turn. */
+ uint16_t score; /* Player's score. */
char * log; /* Pointer to the game log string. */
struct Map * map; /* Pointer to the game map cells. */
struct ItemDef * item_def; /* Pointer to the item definitions. */
m_prev->map_obj.next = monster->map_obj.next;
}
}
+ uint8_t score = md->hitpoints_start;
+ world->score = world->score + score;
free(monster);
}
}
exit_err(0 == file, world, err_open);
if ( write_uint32_bigendian(world->seed, file)
|| write_uint32_bigendian(world->turn, file)
+ || write_uint16_bigendian(world->score, file)
|| write_uint16_bigendian(world->player->pos.y + 1, file)
|| write_uint16_bigendian(world->player->pos.x + 1, file)
|| write_uint8(world->player->hitpoints, file)