-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dad92db
commit 0007b5f
Showing
5 changed files
with
285 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,56 @@ | ||
Fields of Food MMMMMMM | ||
* wall | ||
M mushroom | ||
& apple | ||
Angry Mob Version M | ||
*********************************** | ||
* X * | ||
* M * | ||
* * | ||
* M % % * | ||
* M * * | ||
* * * * | ||
* M * | ||
* * | ||
* * * | ||
* * * | ||
* M * M **** * | ||
* * * | ||
* * | ||
* * | ||
* MMM * | ||
* * | ||
* % * | ||
* * | ||
* U * | ||
* * | ||
* * * * | ||
* * * | ||
*********************************** | ||
|
||
* - wall | ||
M - mob | ||
|
||
struct mob{ | ||
int dir; | ||
int x,y; | ||
int pause; | ||
}; | ||
|
||
|
||
# THIS IS ALL JUST IDEAS FOR ELABORATION ON A THE CONCEPTS WE WILL DEVELOP AND HAVE. | ||
Player will forage in dungeon style levels. These levels will be randomly generated from a pool of: | ||
- Mob types/agression | ||
- Coins | ||
- Assorted loot | ||
- Dopamine producing loot boxes with a wheel loot allocation feature. | ||
- Style and structures of the biomes, landscapes and perhaps related debuffs/buffs - Could be item specific/mob specific. | ||
- With this in mind, we can effectively reskin enemies easily by just relation to the areas in which they are found. | ||
- Colourful, friendly and basic graphics utilizing a majority of bold and engaging colour pallets. | ||
# To travel from area to area there should be requirements. | ||
- In some areas as mentioned there will be different mobs, effects, loot and so forth. | ||
- Some areas will be allocated safe zones. | ||
- Campfire from darksouls esq idea for travel? | ||
- Some areas will be allocated exploration zones. | ||
- Perhaps some areas will be arenas where you will be battling another player/npc that has a similar power score as yourself. | ||
- Some areas will have waves of enemies that you must beat to proceed, providing loot. | ||
- There will be boss battles that will drop good loot. | ||
|
||
|
||
|
||
1 1 | ||
0 0 0 | ||
1 0 1 | ||
2 1 0 | ||
3 1 1 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
project(mob) | ||
|
||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -std:c++17") | ||
|
||
ADD_EXECUTABLE(mob mob.cpp) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
#include <iostream> | ||
#include <windows.h> | ||
#include <conio.h> | ||
#include <fstream> | ||
#include <string> | ||
#include <vector> | ||
|
||
|
||
int mainDelay=80; | ||
int counter=0; | ||
int key = 0; | ||
int monsterCount = 0; | ||
|
||
|
||
int keyboardKey() { | ||
if (_kbhit()) { | ||
return getch(); | ||
} | ||
return -1; | ||
} | ||
|
||
enum blockTypes { | ||
WALL=1, | ||
MONSTER=2 | ||
}; | ||
|
||
char tileChar[] = {' ', '#', 'M'}; | ||
|
||
enum keyCodes { | ||
KEY_ESC=27 | ||
}; | ||
|
||
std::string title; | ||
|
||
|
||
|
||
struct monstermap { | ||
int rows, cols; | ||
std::vector<int> data; | ||
|
||
monstermap(int rows0, int cols0) { | ||
rows = rows0; | ||
cols = cols0; | ||
int size = rows * cols; | ||
data.resize(size); | ||
} | ||
|
||
void set(int x, int y, int m) { | ||
data[x + y * cols] = m; | ||
} | ||
|
||
int get(int x, int y) { | ||
return data[x + y * cols]; | ||
} | ||
|
||
std::string getRow(int row) { | ||
std::vector<char> chars; | ||
for (int col = 0; col < cols; col++) { | ||
int tile = data[col + row * cols]; | ||
chars.push_back(tileChar[tile]); | ||
} | ||
return std::string(chars.data(),cols); | ||
} | ||
|
||
|
||
}; | ||
|
||
monstermap* map0; | ||
|
||
struct monster { | ||
int dir; | ||
int x, y; | ||
int delay; | ||
|
||
monster(int x0, int y0) { | ||
x = x0; | ||
y = y0; | ||
int count = monsterCount++; | ||
dir = count & 3; | ||
delay = 10; | ||
} | ||
|
||
void move() { | ||
if (delay) { | ||
delay--; | ||
return; | ||
} | ||
int x0 = x; int y0 = y; | ||
|
||
switch (dir&3) { | ||
case 0:y0--; break; | ||
case 1:x0++; break; | ||
case 2:y0++; break; | ||
case 3:x0--; break; | ||
} | ||
|
||
int tile=map0->get(x0, y0); | ||
if (tile == 0) { | ||
map0->set(x, y, 0); | ||
x = x0; | ||
y = y0; | ||
map0->set(x, y, 2); | ||
} | ||
else { | ||
delay = 10; | ||
dir--; | ||
} | ||
} | ||
}; | ||
|
||
|
||
std::vector<monster*> monsters; | ||
|
||
void addMonster(int x, int y) { | ||
monsters.push_back(new monster(x, y)); | ||
} | ||
|
||
int maprows = 0; | ||
int mapcols = 0; | ||
|
||
void moveMonsters() { | ||
for (auto m : monsters) { | ||
m->move(); | ||
} | ||
} | ||
|
||
|
||
|
||
int main() { | ||
|
||
SetConsoleOutputCP(CP_UTF8); | ||
|
||
// READ LEVEL FROM FILE | ||
|
||
std::ifstream file("gamelevel.txt"); | ||
std::string str; | ||
std::vector<std::string> strings; | ||
int linenumber = 0; | ||
while (std::getline(file, str)) | ||
{ | ||
linenumber++; | ||
if (str == "") break; | ||
if (linenumber == 1) { | ||
title = str; | ||
continue; | ||
} | ||
int n = str.size(); | ||
if (n > mapcols) mapcols = n; | ||
strings.push_back(str); | ||
} | ||
maprows = strings.size(); | ||
|
||
map0=new monstermap(maprows, mapcols); | ||
|
||
for (int i = 0; i < maprows; i++) { | ||
std::string s=strings[i]; | ||
for (int j = 0; j < s.size(); j++) { | ||
char c = s[j]; | ||
|
||
if (c == 32) continue; | ||
|
||
if (c == '*') { | ||
map0->set(j, i, WALL); | ||
} | ||
|
||
if (c == 'M') { | ||
map0->set(j, i, MONSTER); | ||
addMonster(j, i); | ||
} | ||
} | ||
|
||
} | ||
|
||
// MAIN LOOP | ||
|
||
while (true) { | ||
// home the cursor | ||
std::cout << "\033[0;0f" << std::flush; | ||
|
||
std::cout << title << std::endl << std::endl; | ||
|
||
for (int i = 0; i < maprows; i++) { | ||
std::string s = map0->getRow(i); | ||
std::cout << s << std::endl; | ||
} | ||
|
||
moveMonsters(); | ||
|
||
std::cout << counter << std::endl; | ||
|
||
std::cout << "key:" << key << " " << std::endl; | ||
|
||
Sleep(mainDelay); | ||
|
||
counter++; | ||
|
||
int keycode = keyboardKey(); | ||
|
||
if (key == KEY_ESC) break; | ||
|
||
if (keycode > -1) key = keycode; | ||
|
||
} | ||
|
||
std::cout << "mob game" << std::endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters