Compare commits

...

19 Commits
dev ... master

Author SHA1 Message Date
Justin 6a69ea5685 added a exit 2025-05-15 20:35:13 -05:00
Justin 3aee2fa468 fixed typo issues and added some headers 2025-05-15 19:42:55 -05:00
Justin 0bfecbfb66 working on the player 2025-05-13 23:17:24 -05:00
Justin 7beb263dfc Starting the player 2025-05-11 21:48:04 -05:00
Justin 420998231b init 2025-05-11 21:06:17 -05:00
Justin fc4a95db3d Fixed the time of the typing. 2025-05-11 20:47:56 -05:00
Justin 331a0812bc Added more to the ignored file 2025-05-11 18:21:45 -05:00
Justin 888c0744d9 init 2025-05-11 18:16:46 -05:00
Justin 72a07395c7 Added the game loop the game. 2025-05-11 18:06:28 -05:00
Justin ee934b2d26 Added game.d to the list that was not needed. 2025-05-11 18:05:29 -05:00
Justin b57c137daf init the game loop 2025-05-11 16:06:26 -05:00
Justin 5e8a530dba Changed the color 2025-05-11 14:59:55 -05:00
Justin 53d83a16fb Added all of the intro 2025-05-11 14:59:08 -05:00
Justin d0fad7966a Change the type time to 250 2025-05-11 12:55:52 -05:00
Justin 8659174a14 Moved to static that should have been done at first 2025-05-11 12:51:09 -05:00
Justin f0daf29917 Changed the print to static 2025-05-11 10:43:37 -05:00
Justin 5855b37c6e Added the type in to the print 2025-05-11 10:39:58 -05:00
Justin b7ad0fbb6c Added clear screen to the main before its starts. 2025-05-11 10:27:25 -05:00
Justin 1673e995a6 Working on the delay and fixing issues 2025-05-11 10:24:48 -05:00
26 changed files with 147 additions and 32 deletions

8
.gitignore vendored
View File

@ -6,3 +6,11 @@ banner.txt
print.d print.d
intro.d intro.d
sleep.d sleep.d
game.d
chest.d
door.d
inventory.d
player.d
room.d
wall.d
item.d

0
src/chest.cpp Normal file
View File

0
src/door.cpp Normal file
View File

27
src/game.cpp Normal file
View File

@ -0,0 +1,27 @@
#include "include/game.h"
void Game::gameloop(){
//This is the main game loop.
const int target_fps = 15;
const std::chrono::duration<double> target_frame_duration = chrono::duration<double>(1.0 / target_fps);
auto previous_time = std::chrono::steady_clock::now();
while(true){
auto current_time = std::chrono::steady_clock::now();
chrono::duration<double> elapsed_time = current_time - previous_time;
// Game logic and rendering here
system("clear");
cout << "Frame time: " << elapsed_time.count() << " seconds" << endl;
if (elapsed_time < target_frame_duration) {
chrono::duration<double> sleep_time = target_frame_duration - elapsed_time;
this_thread::sleep_for(sleep_time);
}
previous_time = chrono::steady_clock::now();
exit(1);
}
}

0
src/include/chest.h Normal file
View File

0
src/include/door.h Normal file
View File

12
src/include/game.h Normal file
View File

@ -0,0 +1,12 @@
#include <iostream>
#include <chrono>
#include <thread>
#include <cstdlib>
using namespace std;
class Game{
public:
void gameloop();
};

View File

@ -6,9 +6,6 @@ using namespace std;
class Intro { class Intro {
public: public:
static void mainIntro();
void mainIntro();
private:
}; };

11
src/include/inventory.h Normal file
View File

@ -0,0 +1,11 @@
class Inventory{
public:
Inventory(){
};
};

6
src/include/item.h Normal file
View File

@ -0,0 +1,6 @@
class Item{
};

View File

@ -1,4 +1,6 @@
#include <iostream> #include <iostream>
#include "intro.h" #include "intro.h"
#include "title.h" #include "title.h"
#include <cstdlib>
#include "game.h"
using namespace std; using namespace std;

14
src/include/player.h Normal file
View File

@ -0,0 +1,14 @@
#include "inventory.h"
#include "item.h"
class Player{
public:
void move();
void add_inventory(Item);
bool check_inventory(Item);
bool remove_inventory(Item);
private:
Inventory inventory;
};

View File

@ -1,5 +1,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <thread>
#include <cstring>
using namespace std; using namespace std;
class Print{ class Print{
@ -10,7 +12,9 @@ class Print{
~Print(){ ~Print(){
}; };
void printl(string text); static void printl(string text);
void println(string text); static void println(string text);
static void type(string text);
static void blank_line();
}; };

0
src/include/room.h Normal file
View File

View File

@ -3,6 +3,6 @@ using namespace std;
class Sleep{ class Sleep{
public: public:
void delay(int milliseconds); static void delay(int milliseconds);
}; };

View File

@ -3,8 +3,6 @@
using namespace std; using namespace std;
class Title{ class Title{
private:
protected:
public: public:
void mainTitle(); static void mainTitle();
}; };

0
src/include/wall.h Normal file
View File

View File

@ -1,6 +1,15 @@
#include "include/intro.h" #include "include/intro.h"
void Intro::mainIntro(){ void Intro::mainIntro(){
cout << "The world didn't end with a bang. It ended with a groan.. and the scratching of death fingers against steel shutters." << endl; Print::blank_line();
std::this_thread::sleep_for(std::chrono::milliseconds(3000)); Print::type("The world didn't end with a bang. It ended with a groan.. and the scratching of death fingers against ");
Print::type("steel shutters.");
Print::type("Pete used to sell shotguns, slugs, and survival tips to deer hunters and doomsday preppers out of his");
Print::type("rundown gun store on the edge of town. Folks called him Shotgun Pete. They laughed at his bunker in the");
Print::type("basement and his endless stockpile of beans and buckshot.");
Print::type("Theyre not laughing now.");
Print::type("Its been 47 days since the dead started walking. The citys overrun. The powers gone. The roads are broken");
Print::type("and the rules are worse.");
Print::type("But Pete? Petes still here. Armed to the teeth. Ready to take back whats his, one shell at a time.");
Print::type("Welcome to Shotgun Pete. Lock and load.");
} }

0
src/inventory.cpp Normal file
View File

0
src/item.cpp Normal file
View File

View File

@ -1,9 +1,11 @@
#include "include/main.h" #include "include/main.h"
int main (){ int main (){
Title title; system("clear");
title.mainTitle(); Title::mainTitle();
Intro intro; Intro::mainIntro();
intro.mainIntro(); Game game;
game.gameloop();
cin.get();
return 0; return 0;
} }

4
src/player.cpp Normal file
View File

@ -0,0 +1,4 @@
#include "include/player.h"

View File

@ -1,9 +1,30 @@
#include "include/print.h" #include "include/print.h"
void Print::printl(string text){ void Print::printl(string text){
cout << text; cout << text << flush;
} }
void Print::println(string text){ void Print::println(string text){
cout << text << endl; cout << text << endl;
} }
void Print::type(string text){
int a = text.size();
char* charArray = new char[a+1];
strcpy(charArray, text.c_str());
int i = 0;
int time = 150;
while(i < a+1){
std::this_thread::sleep_for(std::chrono::milliseconds(time));
cout << charArray[i] << flush;
i++;
}
cout << endl;
delete[] charArray;
}
void Print::blank_line(){
cout << endl;
}

0
src/room.cpp Normal file
View File

View File

@ -1,21 +1,21 @@
#include "include/title.h" #include "include/title.h"
#include "include/print.h" #include "include/print.h"
#include "include/sleep.h"
void Title::mainTitle(){ void Title::mainTitle(){
int s = 2000; int s = 900;
Print print; Print::println("");
print.println("███████╗██╗ ██╗ ██████╗ ████████╗ ██████╗ ██╗ ██╗███╗ ██╗ ██████╗ ███████╗████████╗███████╗"); Print::println("\033[31m███████╗██╗ ██╗ ██████╗ ████████╗ ██████╗ ██╗ ██╗███╗ ██╗ ██████╗ ███████╗████████╗███████╗");
usleep(s); Sleep::delay(s);
print.println("██╔════╝██║ ██║██╔═══██╗╚══██╔══╝██╔════╝ ██║ ██║████╗ ██║ ██╔══██╗██╔════╝╚══██╔══╝██╔════╝"); Print::println("██╔════╝██║ ██║██╔═══██╗╚══██╔══╝██╔════╝ ██║ ██║████╗ ██║ ██╔══██╗██╔════╝╚══██╔══╝██╔════╝");
usleep(s); Sleep::delay(s);
print.println("███████╗███████║██║ ██║ ██║ ██║ ███╗██║ ██║██╔██╗ ██║ ██████╔╝█████╗ ██║ █████╗ "); Print::println("███████╗███████║██║ ██║ ██║ ██║ ███╗██║ ██║██╔██╗ ██║ ██████╔╝█████╗ ██║ █████╗ ");
usleep(s); Sleep::delay(s);
print.println("╚════██║██╔══██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██╔═══╝ ██╔══╝ ██║ ██╔══╝ "); Print::println("╚════██║██╔══██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██╔═══╝ ██╔══╝ ██║ ██╔══╝ ");
usleep(s); Sleep::delay(s);
print.println("███████║██║ ██║╚██████╔╝ ██║ ╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ███████╗ ██║ ███████╗"); Print::println("███████║██║ ██║╚██████╔╝ ██║ ╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ███████╗ ██║ ███████╗");
usleep(s); Sleep::delay(s);
print.println("╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝"); Print::println("╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝");
} }

0
src/wall.cpp Normal file
View File