forked from YusukeKato/RPG
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprint_screen.c
90 lines (72 loc) · 1.66 KB
/
print_screen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <stdio.h>
#include <string.h>
#include "file.h"
#include "print_screen.h"
#define BUF_ROWS 15
static char msg_buf[BUF_ROWS][100];
static char msg_select[100][100];
static int select_rows = 4;
static int my_hp, ememy_hp;
int print_story(char *msg, ...)
{
int i;
static int buf_rows;
char buf[1024];
va_list list;
int var_count = 0;
/* variables list */
for(i = 0; i < strlen(msg) - 1; i++) {
if((msg[i] == '%') &&
(msg[i + 1] == 'd' ||
msg[i + 1] == 's' ||
msg[i + 1] == 'f' ||
msg[i + 1] == 'd' ||
msg[i + 1] == 'u' ||
msg[i + 1] == 'x' ||
msg[i + 1] == 'X'))
{
var_count++;
}
}
va_start(list, var_count);
//var_args(list, int);
system("cls");
printf("----------------------------------------------------------------------\n");
//printf("HP | MY: %5d || EMEMY: %5d \n", my_hp, ememy_hp);
//printf("----------------------------------------------------------------------\n");
if(buf_rows < BUF_ROWS - 1) {
strncpy(msg_buf[buf_rows], msg, sizeof(msg_buf[buf_rows]));
buf_rows++;
} else {
for(i = 0; i < buf_rows - 1; i++) {
strncpy(msg_buf[i], msg_buf[i + 1], sizeof(msg_buf[i]));
}
sprintf(buf, msg);
strncpy(msg_buf[buf_rows], buf, sizeof(msg_buf[buf_rows]));
}
for(i = 0; i < buf_rows; i++) {
printf(" %s", msg_buf[i]); /* Don't output NewLine at End of Line */
}
for(; i < BUF_ROWS; i++) {
printf("\n");
}
printf("\n----------------------------------------------------------------------\n");
va_end(list);
return 0;
}
int set_myhp(int hp)
{
my_hp = hp;
}
int set_ememyhp(int hp)
{
ememy_hp = hp;
}
int get_myhp(void)
{
return my_hp;
}
int get_ememyhp(void)
{
return ememy_hp;
}