-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
146 lines (119 loc) · 3.38 KB
/
main.cpp
File metadata and controls
146 lines (119 loc) · 3.38 KB
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
143
144
145
146
int uni_num = 20; //To število je število za koliko tailov gre v igralno polje
int uni_img_num = 11; //To število je število slik za igro (èe se številka spremeni je potrebno tudi spremeniti število imen v Tile_reader-ju)
const int rarity = 1000;
const int ring = 1;
const int emerald = 50;
const int mining = 10;
const int kill_enemy = 100;
const int ATTACK_BASIC = 0x61; //Osnovni napad (NUMPAD_1 - trenutno)
#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
double cas;
int x_player_pozicija = 1, y_player_pozicija = 1;
#include <time.h>
#include "graphics.h"
#include "Key_Board_Reader.h"
#include "Tile_Reader.h"
#include "non_playing_character.h"
#include "player.h"
double startfps = 0, endfps = 0;
void okno();
void room_loader();
bool map_select = 1;
int main()
{
okno();
while(!GetAsyncKeyState(0x20))
{
setcolor(COLOR(rand()%256,rand()%256,rand()%256 ));
moveto((((uni_num*40)/2)-150), 120+((uni_num-10)*30));
outtext("Use 'WASD' to move and 'NUMPAD_1' to mine!");
moveto((((uni_num*40)/2)-110), 160+((uni_num-10)*30));
outtext("Press 'SPACE' to start the game! ");
swapbuffers();
delay(25);
}
system("color 0a");
srand(time(0));
//uni_num = rand()%30+5;
cout << "Loading: image_to_memory();" <<endl;
image_to_memory();
cout << "Loading: tile_draw();" <<endl;
room_loader();
cout << "Loading: player_reset();" <<endl;
player_reset();
tile_draw();
start:
money = 0;
player_health = (rand()%3-1)+5;
npc_money=1;
while(true)
{
time_t startfps = clock();
//ZAÈETEK PROGRAMA
clearviewport();
if(GetAsyncKeyState(ARROW_UP))
{
npc_money+=10;
}
else if(GetAsyncKeyState(ARROW_DOWN))
{
npc_money-=10;
}
tile_draw();
player();
draw_npc();
stats();
swapbuffers();
if(player_health <= 0)
{
break;
}
//KONEC PROGRAMA
time_t endfps = clock();
endfps = endfps - startfps;
cas = endfps / (double) CLOCKS_PER_SEC;
cas = 1 / cas;
if(GetAsyncKeyState(0x1B))
return EXIT_SUCCESS;
}
clearviewport();
swapbuffers();
clearviewport();
swapbuffers();
while(!GetAsyncKeyState(0x1B))
{
readimagefile("gameover_splashscreen.gif", 0, 0, uni_num*40, uni_num*30);
swapbuffers();
moveto((((uni_num*40)/2)-95), 320+((uni_num-10)*30));
setcolor(COLOR(rand()%256,rand()%256,rand()%256 ));
outtext("Press 'SPACE' to play again!");
if(GetAsyncKeyState(0x20))
goto start;
}
return EXIT_SUCCESS;
}
void okno()
{
initwindow(uni_num*40, (uni_num+3)*30, "Doctor's Dragon 0.0.0.0", 0, 0);
clearviewport();
swapbuffers();
clearviewport();
}
void room_loader()
{
//uni_num = rand()%30+5;
system("cls");
cout << "Loading..." <<endl;
cout << "Loading: tile_template();" <<endl;
tile_template();
cout << "Loading: room_generator();" <<endl;
room_generator();
/*cout << "Loading: gold_generator();" <<endl;
gold_generator();*/
cout << "Loading: preferences_npc();" <<endl;
preferences_npc();
cout << "Loading done!" <<endl;
}