RCRPG/C: Difference between revisions
m
Fixed syntax highlighting.
m (→Code: cbreak() < cbreak) |
m (Fixed syntax highlighting.) |
||
(7 intermediate revisions by 5 users not shown) | |||
Line 1:
{{collection|RCRPG}}
This [[
==What's in use==
Line 6 ⟶ 7:
* [[wp:ncurses|ncurses]] library for advanced terminal I/O
* functions (also with variable number of arguments)
* enumerations
* structures, their allocation and pointers
Line 38 ⟶ 39:
{{works with|POSIX}}
{{libheader|ncurses}}
<
#include <stdlib.h>
#include <stdbool.h>
#include <stdarg.h>
#include <time.h>
#include <string.h>
Line 83:
};
const char *str_dirs = "nsewud";
struct room {
Line 95:
/* descriptions */
const char *descriptions[] = {
"cold dark room",
"very stinky room",
Line 108:
};
const char *objs[] = {
"nothing", "sledge", "ladder", "gold", "equipped sledge"
};
const char *dirnames[] = {
"north", "south", "east", "west", "up", "down"
};
Line 186:
rooms[room_i]->visited = false;
rooms[room_i]->description = rangerandom(0, sizeof(descriptions)/sizeof(
/* put some random object - sledge or gold */
Line 214:
/* show description */
void print_cmd(int y, int x, const char *str)
{
int i, l;
Line 408:
case 'u':
case 'd':
d =
if ( ((my_pos.ns + incdir[d].ns) >= NS_LIMIT) ||
((my_pos.ew + incdir[d].ew) >= EW_LIMIT) ||
Line 508:
case 'u':
case 'd':
d =
if ( currentroom->dirs[d] == NULL ) {
clrtoeol();
Line 593:
free_rooms();
nocbreak(); echo(); endwin();
return EXIT_SUCCESS;
}
}</syntaxhighlight>
|