RCRPG/C: Difference between revisions

m
Fixed syntax highlighting.
m (→‎Code: restored changes previously made by underscore (lost since I had modified my local copy))
m (Fixed syntax highlighting.)
 
(6 intermediate revisions by 5 users not shown)
Line 1:
{{collection|RCRPG}}
This [[Category:RCRPGC]]This version of [[:Category:RCRPG|RCRPG]] implements a single key text interface based on [[wp:ncurses|ncurses]].
 
==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}}
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
Line 82 ⟶ 83:
};
 
const char *str_dirs = "nsewud";
 
struct room {
Line 94 ⟶ 95:
 
/* descriptions */
const char *descriptions[] = {
"cold dark room",
"very stinky room",
Line 107 ⟶ 108:
};
 
const char *objs[] = {
"nothing", "sledge", "ladder", "gold", "equipped sledge"
};
 
const char *dirnames[] = {
"north", "south", "east", "west", "up", "down"
};
Line 185 ⟶ 186:
 
rooms[room_i]->visited = false;
rooms[room_i]->description = rangerandom(0, sizeof(descriptions)/sizeof(void *descriptions) - 1);
 
/* put some random object - sledge or gold */
Line 213 ⟶ 214:
/* show description */
 
void print_cmd(int y, int x, const char *str)
{
int i, l;
Line 592 ⟶ 593:
free_rooms();
nocbreak(); echo(); endwin();
return EXIT_SUCCESS;
}</lang>
}
}</syntaxhighlight>
9,476

edits