Work in progress update...
This commit is contained in:
parent
fef67ce320
commit
89f33081e4
70
xungeons.c
70
xungeons.c
@ -31,12 +31,21 @@ enum { fighting, blocking, shooting, spellcasting, evoking, trading, healing, lo
|
|||||||
|
|
||||||
enum { warrior, mage, thief, priest, archer, alchemist, warlock, merchant, classes };
|
enum { warrior, mage, thief, priest, archer, alchemist, warlock, merchant, classes };
|
||||||
|
|
||||||
|
static char * point_name [points] = { "HP = ", "MP = ", "SP = ", "XP = " };
|
||||||
|
|
||||||
|
static char * attribute_name [attributes] = { "Strength : ", "Dexterity : ", "Agility : ", "Intelligence : " };
|
||||||
|
|
||||||
|
static char * skill_name [skills] = { "Fighting", "Blocking", "Shooting", "Spellcasting", "Evoking", "Trading", "Healing", "Lockpicking" };
|
||||||
|
|
||||||
|
static char * class_name [classes] = { "Warrior", "Mage", "Thief", "Priest", "Archer", "Alchemist", "Warlock", "Merchant" };
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
char clip, style, colour, symbol;
|
char clip, style, colour, symbol;
|
||||||
} const tiles [] = {
|
} const tiles [] = {
|
||||||
{ 1, normal, white, ' ' },
|
{ 1, normal, white, ' ' },
|
||||||
{ 0, bold, grey, '.' },
|
{ 0, bold, grey, '.' },
|
||||||
{ 1, bold, grey, '#' }
|
{ 1, bold, grey, '#' },
|
||||||
|
{ 1, reverse, blue, '-' },
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@ -87,6 +96,7 @@ static struct termios new_terminal;
|
|||||||
static int signal;
|
static int signal;
|
||||||
static int screen_width;
|
static int screen_width;
|
||||||
static int screen_height;
|
static int screen_height;
|
||||||
|
static int screen_side;
|
||||||
static char * screen;
|
static char * screen;
|
||||||
static int level_width;
|
static int level_width;
|
||||||
static int level_height;
|
static int level_height;
|
||||||
@ -135,6 +145,8 @@ static void initialize_screen (void) {
|
|||||||
screen = calloc ((unsigned long int) (12 * screen_width * screen_height + 4), sizeof (* screen));
|
screen = calloc ((unsigned long int) (12 * screen_width * screen_height + 4), sizeof (* screen));
|
||||||
|
|
||||||
strcpy (screen, "\033[H");
|
strcpy (screen, "\033[H");
|
||||||
|
|
||||||
|
screen_side = 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deinitialize_screen (void) {
|
static void deinitialize_screen (void) {
|
||||||
@ -180,8 +192,8 @@ static void synchronize_screen (void) {
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.x = clamp (player.x, 0, (char) level_width);
|
player.x = clamp (player.x, 0, (char) level_width - 1);
|
||||||
player.y = clamp (player.y, 0, (char) level_height);
|
player.y = clamp (player.y, 0, (char) level_height - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void generate_level (void) {
|
static void generate_level (void) {
|
||||||
@ -203,12 +215,10 @@ static void generate_level (void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < height; ++i) {
|
for (i = 0; i < height; ++i) {
|
||||||
level [(i + y) * level_width + x] = 2;
|
level [(i + y) * level_width + x] = level [(i + y) * level_width + x + width - 1] = 2;
|
||||||
level [(i + y) * level_width + x + width - 1] = 2;
|
|
||||||
}
|
}
|
||||||
for (j = 0; j < width; ++j) {
|
for (j = 0; j < width; ++j) {
|
||||||
level [y * level_width + j + x] = 2;
|
level [y * level_width + j + x] = level [(y + height - 1) * level_width + j + x] = 2;
|
||||||
level [(y + height - 1) * level_width + j + x] = 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,6 +230,14 @@ static void generate_level (void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < level_height; ++i) {
|
||||||
|
level [i * level_width] = level [i * level_width + level_width - 1] = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < level_width; ++j) {
|
||||||
|
level [j] = level [(level_height - 1) * level_width + j] = 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void generate_party (void) {
|
static void generate_party (void) {
|
||||||
@ -251,7 +269,7 @@ static void generate_party (void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main (void) {
|
int main (void) {
|
||||||
int i, x, y;
|
int i, j, x, y;
|
||||||
|
|
||||||
srand (time (0));
|
srand (time (0));
|
||||||
|
|
||||||
@ -267,16 +285,38 @@ int main (void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y = 0; (y < screen_height) && (y + player.y < level_height - 1); ++y) {
|
for (y = maximum (0, player.y - screen_height / 2); (y < player.y + screen_height / 2) && (y < level_height); ++y) {
|
||||||
for (x = 0; (x < screen_width) && (x + player.x < level_width - 1); ++x) {
|
for (x = maximum (0, player.x - screen_width / 2); (x < player.x + screen_width / 2) && (x < level_width); ++x) {
|
||||||
i = (int) level [(y + player.y) * level_width + (x + player.x)];
|
i = (int) level [y * level_width + x];
|
||||||
screen_put (tiles [i].style, tiles [i].colour, tiles [i].symbol, x, y);
|
screen_put (tiles [i].style, tiles [i].colour, tiles [i].symbol, screen_width / 2 + x - player.x, screen_height / 2 + y - player.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_put (bold, cyan, '@', screen_width / 2, screen_height / 2);
|
screen_put (bold, cyan, '@', screen_width / 2, screen_height / 2);
|
||||||
|
|
||||||
screen_print (bold, grey, "Warrior", screen_width - 24, 0, 24);
|
//~player.weapon [i] = random (0, 3);
|
||||||
|
//~player.armour [i] = random (0, 3);
|
||||||
|
//~for (j = 0; j < points; ++j) {
|
||||||
|
//~player.point [i] [j] = random (12, 24);
|
||||||
|
//~}
|
||||||
|
//~for (j = 0; j < attributes; ++j) {
|
||||||
|
//~player.attribute [i] [j] = random (1, 4);
|
||||||
|
//~}
|
||||||
|
//~player.skill [i] = rand () % skills;
|
||||||
|
//~player.class [i] = rand () % classes;
|
||||||
|
for (i = 0; i < members; ++i) {
|
||||||
|
screen_print (bold, blue, class_name [(int) player.class [i]], screen_width - screen_side, i * (2 + 1 + attributes + 1) + 0, screen_side);
|
||||||
|
screen_print (bold, white, skill_name [(int) player.skill [i]], screen_width - screen_side, i * (2 + 1 + attributes + 1) + 1, screen_side);
|
||||||
|
//~for (j = 0; j < points; ++j) {
|
||||||
|
//~int length = strlen (point_name [player.point [i]]);
|
||||||
|
//~screen_print (bold, white, point_name [j], screen_width - screen_side, i * (2 + 1 + attributes + 1) + 2 + j, screen_side);
|
||||||
|
//~screen_print (bold, white, player.point [i], screen_width - screen_side, i * (2 + 1 + attributes) + 2 + j, screen_side);
|
||||||
|
//~}
|
||||||
|
//~for (j = 0; j < attributes; ++j) {
|
||||||
|
//~screen_print (bold, white, attribute_name [j], screen_width - 24, i * (2 + 1 + attributes + 1) + 2 + 1 + j, screen_side);
|
||||||
|
//~}
|
||||||
|
screen_print (bold, white, "--------------------------------", screen_width - screen_side, i * (2 + 1 + attributes + 1) + 2 + 1 + attributes, screen_side);
|
||||||
|
}
|
||||||
|
|
||||||
synchronize_screen ();
|
synchronize_screen ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user