Alright, I just finished the basic engine for a game I'm making, called DungeonMan. Right now, it runs in the terminal and doesn't accept user input, just simulates someone going through a linear dungeon and battling occasional monsters. Right now I've been working on it for 2 days, and I hope to have it finished within 7. Features I want to implement:
-Graphics (Allegro or OpenGL)
-3D dungeon instead of straight line
-More monsters and battle options
-Boss fights
-Interactive store
Bugs that need fixing:
-None so far :)
Technical stuff:
-I want to make it so instead of writing a battle script for EVERY monster, I can set predefined variables for each monster like name, evasion rate, HP, and whatnot.
If anyone can tell me how to do any of the things listed above, I would love to hear it. Source code and .exe follow.
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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
#include <cstdlib>
#include <windows.h>
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <time.h>
#include <ctime>
#include <conio.h>
using namespace std;
//Formatting and graphics
int tick = 1;
//Random variables
int lowest = 1, highest = 10;
int range = (highest - lowest) + 1;
int random = rand();
//Game mechanics
int dun_distance = 1;
int goal_distance = 100;
int points = 0;
int encounters = 0;
int level = 1;
int exp = 0;
int gain_exp = 0;
int old_exp = 0;
int next_exp = 10;
int next_exp2 = 10;
int next_exp_vis = 10;
int monster = 0;
int curmonster_hp;
int monster_hp = 0;
int monster_level = 0;
int gold = 0;
int oldgold = 0;
int gold_gain = 0;
int attack = 0;
int oldstr_gain = 2;
int str_gain = 2;
int oldstr = 3;
int str = 3;
int olddex_gain = 4;
int dex_gain = 4;
int olddex = 3;
int dex = 3;
int main(); //main prototype
int level_up(){
system("cls");
cout << "Level up!" << endl;
Sleep(1000);
oldstr_gain = str_gain;
str_gain = oldstr_gain * 1.5;
str = oldstr + str_gain;
cout << "+ " << str_gain << " strength!" << endl;
Sleep(500);
olddex_gain = dex_gain;
dex_gain = olddex_gain * 1.25;
dex = olddex + dex_gain;
cout << "+ " << dex_gain << " dexterity!" << endl;
exp = 0;
next_exp = next_exp2 * 1.5;
level++;
Sleep(3000);
system("cls");
main();
}
int shop(){
cout << "You come across a travelling merchant!" << endl;
system("cls");
main();
}
int encounter(){
rand();
random = lowest+int(range*rand()/(RAND_MAX + 1.0));
if (random <= 4){
if (level <= 3)
monster = 1;
else if (level <= 10)
monster = 2;
else if (level <= 20)
monster = 3;
else if (level <= 35)
monster = 4;
else if (level <= 50)
monster = 5;
else
monster = 6;
}
else if (random <= 7){
if (level <= 3)
monster = 7;
else if (level <= 10)
monster = 8;
else if (level <= 20)
monster = 9;
else if (level <= 35)
monster = 10;
else if (level <= 50)
monster = 11;
else
monster = 12;
}
else if (random <= 9){
if (level <= 3)
monster = 13;
else if (level <= 10)
monster = 14;
else if (level <= 20)
monster = 15;
else if (level <= 35)
monster = 16;
else if (level <= 50)
monster = 17;
else
monster = 18;
}
else {
shop();
}
cout << "A monster approaches!" << endl;
Sleep(2500);
rand();
random = 1+int(6*rand()/(RAND_MAX + 1.0));
cout << "You encounter a wild Slime! (Lv " << random << ")" << endl;
monster_level = random;
monster_hp = monster_level * 2;
curmonster_hp = monster_hp;
while (monster_hp >= 1){
rand();
Sleep(1000);
random = 1+int(5*rand()/(RAND_MAX + 1.0));
if (random*dex >= 5){
random = (rand()*str/20000);
cout << "You hit Slime for " << random << " damage!" << endl;
monster_hp = curmonster_hp - random;
curmonster_hp = monster_hp;
Sleep(100);
cout << "Slime has " << monster_hp << " health left!" << endl << endl;
} else {
cout << "You missed Slime!" << endl << endl;
}
}
cout << "You defeated Slime!" << endl;
gain_exp = monster_level * 3;
Sleep(3000);
cout << "You earned " << gain_exp << " experience points!" << endl;
exp = old_exp + gain_exp;
next_exp_vis = next_exp - gain_exp;
Sleep(1000);
gold_gain = monster_level * 2.5;
cout << "You gained " << gold_gain << " gold!";
gold = gold_gain + oldgold;
Sleep(2500);
system("cls");
encounters++;
main();
}
int boss(){
main();
}
int main(){
srand ( time(NULL) );
while (true){
rand();
++tick;
oldgold = gold;
++exp;
--next_exp_vis;
old_exp = exp;
exp = old_exp;
oldstr = str;
olddex = dex;
next_exp2 = next_exp;
next_exp_vis = next_exp - exp;
cout << "Level" << setw(4) << level << setw(12) << exp << " Exp" << setw(10) << next_exp_vis
<< " To Next Level"
<< setw(24) << "Distance Travelled: " << setw(5) << dun_distance << "ft" << endl;
cout << str << " " << dex << " " << str_gain << " " << dex_gain;
dun_distance++;
//rand = 0 - 32767
Sleep(500);
system("cls");
random = rand();
if (random >= 31657){
encounter();
}
if (exp >= next_exp){
level_up();
}
if (dun_distance >= goal_distance){
boss();
}
}
}
|
EXE is bugged, please compile from the source yourselves!
.exe (Windows only!)
http://www.easy-share.com/1907944011/DungeonMan.exe