Skip to content

Commit

Permalink
angrymob
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrologic committed Aug 21, 2023
1 parent dad92db commit 0007b5f
Show file tree
Hide file tree
Showing 5 changed files with 285 additions and 19 deletions.
65 changes: 51 additions & 14 deletions gamelevel.txt
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
8 changes: 8 additions & 0 deletions mobstermadness/CmakeLists.txt
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)


206 changes: 206 additions & 0 deletions mobstermadness/mob.cpp
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;
}
11 changes: 11 additions & 0 deletions skidtool/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ extern std::vector<logline> machineLog;

void systemLog(const char* tag, std::string s);


class acidlog : public std::stringstream {

public:
void clr() {
str(std::string());
*this << std::hex;
}
};


Chunk loadChunk(std::string path, int physical);


Expand Down
14 changes: 9 additions & 5 deletions skidtool/skidtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void dayminticks(int *dmt) {
SystemTimeToVariantTime(&time,&v1);
dmt[0] = (v1-v0);
dmt[1] = time.wHour * 60 + time.wMinute;
dmt[2] = time.wSecond * 50 + (time.wMilliSeconds/20);
dmt[2] = time.wSecond * 50 + (time.wMilliseconds/20);
}

int getch2() {
Expand Down Expand Up @@ -812,19 +812,20 @@ class aciddos : public IDos {
int fileCount = 0;
FileMap fileMap;
FileLocks fileLocks;
std::stringstream doslog;
acidlog doslog;

void emit() {
std::string s = doslog.str();
systemLog("dos", s);
doslog.str(std::string());
doslog.clr();
}

public:

acid68000* cpu0;
aciddos(acid68000* cpu) {
cpu0 = cpu;
doslog.clr();

fileMap["stdin"] = NativeFile(INPUT_STREAM, "stdin");
fileMap["stdout"] = NativeFile(OUTPUT_STREAM, "stdout");
Expand Down Expand Up @@ -1165,20 +1166,23 @@ BUGS
*/


class acidexec : public IExec {
public:
acid68000* cpu0;
std::stringstream execlog;
acidlog execlog;

void emit() {
std::string s = execlog.str();
systemLog("exec", s);
execlog.str(std::string());
execlog.clr();
}

acidexec(acid68000* cpu) {
cpu0 = cpu;
execlog.clr();
}

void forbid(){}
void permit() {}
void waitMsg() {}
Expand Down

0 comments on commit 0007b5f

Please sign in to comment.