-
Notifications
You must be signed in to change notification settings - Fork 1
/
structs.h
142 lines (133 loc) · 3.39 KB
/
structs.h
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#if defined(_WIN32) || defined(_WIN64)
#include "curses.h"
#include <Windows.h>
#include <stdlib.h>
#else
#include "ncurses.h" // please download yourself on Mac...
#include <unistd.h>
#endif
struct gameObj
{
int objtype;
int hostile;
int destroyable;
int penetration;
int hurt;
int color;
int hp;
double speed;
int atkspeed;
int damage;
double x, y;
double desx, desy;
int attackcd;
};
struct DefObj
{
int destroyable;
int penetration;
int color;
int hp;
double speed;
int atkspeed;
int damage;
int height, width;
int icon[10][10];
int attackmode;
int atktype;
int hostile;
int movemode;
int destroydes;
};
typedef struct gameObj gameobj;
typedef struct DefObj defobj;
void renderIcon(int x,int y, defobj obje, int color) {
attron(COLOR_PAIR(color));
for (int i = 0;i < obje.height;i++) {
for (int j = 0; j < obje.width; j++) {
move(x + i+10, y + j);
if (obje.icon[i][j] != ' ') addch(obje.icon[i][j]);
}
}
attroff(COLOR_PAIR(color));
return;
}
void displayhp() {
extern playerhp,playerbomb,playerkey,playermoney;
extern char* pl_onetime;
extern char* pl_multime;
move(1, 55);
printw("HP: ");
attron(COLOR_PAIR(3));
for (int i = 0;i < playerhp;i++)
addch(3 | A_ALTCHARSET);
attroff(COLOR_PAIR(3));
move(3, 55);
attron(COLOR_PAIR(2));
addch(10 | A_ALTCHARSET);
attroff(COLOR_PAIR(2));
printw(": %s", pl_multime);
move(5, 55);
attron(COLOR_PAIR(5));
addch(10 | A_ALTCHARSET);
attroff(COLOR_PAIR(5));
printw(": %s", pl_onetime);
move(1, 40);
attron(COLOR_PAIR(2));
printw("$");
attroff(COLOR_PAIR(2));
printw(": %d",playermoney);
move(3, 40);
addch(15 | A_ALTCHARSET);
printw(": %d", playerbomb);
move(5, 40);
attron(COLOR_PAIR(4));
addch(11 | A_ALTCHARSET);
attroff(COLOR_PAIR(4));
printw(": %d", playerkey);
return;
}
void init_Color() {
start_color();
init_pair(1, COLOR_BLACK, COLOR_WHITE); // 1: inverse
init_pair(2, COLOR_YELLOW, COLOR_BLACK); // 2: highlight
init_pair(3, COLOR_RED, COLOR_BLACK);
init_pair(4, COLOR_BLUE, COLOR_BLACK);
init_pair(5, COLOR_GREEN, COLOR_BLACK);
init_pair(6, COLOR_RED, COLOR_WHITE);
return;
}
void init_objlib(defobj lib[]) { // order of input: 1. number of objs
FILE *OBJ; // 2. destroyable, penetration, color, hp, speed, atkspeed, damage, attackspeed
int n; // 3. height, width
OBJ = fopen("objlib.in", "r"); // array icon
fscanf(OBJ, "%d", &n);
for (int i = 0;i < n;i++) {
fscanf(OBJ, "%d", &(lib[i].destroyable));
fscanf(OBJ, "%d", &(lib[i].penetration));
fscanf(OBJ, "%d", &(lib[i].color));
fscanf(OBJ, "%d", &(lib[i].hp));
fscanf(OBJ, "%lf", &(lib[i].speed));
fscanf(OBJ, "%d", &(lib[i].atkspeed));
fscanf(OBJ, "%d", &(lib[i].damage));
fscanf(OBJ, "%d", &(lib[i].attackmode));
fscanf(OBJ, "%d", &(lib[i].hostile));
fscanf(OBJ, "%d", &(lib[i].movemode));
fscanf(OBJ, "%d", &(lib[i].destroydes));
fscanf(OBJ, "%d", &(lib[i].atktype));
fscanf(OBJ, "%d", &(lib[i].height));
fscanf(OBJ, "%d", &(lib[i].width));
for(int j=0;j<lib[i].height;j++)
for(int k=0;k<lib[i].width;k++)
fscanf(OBJ, "%d", &(lib[i].icon[j][k]));
}
fclose(OBJ);
}
void godie() {
clear();
move(20, 40);
attron(COLOR_PAIR(6));
printw("You Died");
attron(COLOR_PAIR(6));
refresh();
}