Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
|
bb8bc40c13 | |
|
0737ed92a8 | |
|
4f60b29fc4 | |
|
657b97c4a8 |
|
@ -6,11 +6,3 @@ 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
|
|
||||||
|
|
27
src/game.cpp
27
src/game.cpp
|
@ -1,27 +0,0 @@
|
||||||
#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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
#include <chrono>
|
|
||||||
#include <thread>
|
|
||||||
#include <cstdlib>
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
class Game{
|
|
||||||
public:
|
|
||||||
void gameloop();
|
|
||||||
|
|
||||||
};
|
|
|
@ -6,6 +6,9 @@ using namespace std;
|
||||||
|
|
||||||
class Intro {
|
class Intro {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void mainIntro();
|
static void mainIntro();
|
||||||
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Inventory{
|
|
||||||
public:
|
|
||||||
|
|
||||||
Inventory(){
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,6 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
class Item{
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
|
@ -2,5 +2,4 @@
|
||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
#include "title.h"
|
#include "title.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include "game.h"
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
#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;
|
|
||||||
};
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
|
||||||
#include <cstring>
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class Print{
|
class Print{
|
||||||
|
@ -12,9 +10,7 @@ class Print{
|
||||||
~Print(){
|
~Print(){
|
||||||
|
|
||||||
};
|
};
|
||||||
static void printl(string text);
|
void printl(string text);
|
||||||
static void println(string text);
|
void println(string text);
|
||||||
static void type(string text);
|
|
||||||
static void blank_line();
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstring>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class Sleep{
|
class Sleep{
|
||||||
public:
|
public:
|
||||||
static void delay(int milliseconds);
|
static void delay(int milliseconds);
|
||||||
|
static void type(string text);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include "include/print.h"
|
||||||
|
#include "include/sleep.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class Title{
|
class Title{
|
||||||
|
private:
|
||||||
|
protected:
|
||||||
public:
|
public:
|
||||||
static void mainTitle();
|
static void mainTitle();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
#include "include/intro.h"
|
#include "include/intro.h"
|
||||||
|
|
||||||
void Intro::mainIntro(){
|
void Intro::mainIntro(){
|
||||||
Print::blank_line();
|
int time = 1000;
|
||||||
Print::type("The world didn't end with a bang. It ended with a groan.. and the scratching of death fingers against ");
|
cout << endl;
|
||||||
Print::type("steel shutters.");
|
cout << endl;
|
||||||
Print::type("Pete used to sell shotguns, slugs, and survival tips to deer hunters and doomsday preppers out of his");
|
Sleep::type("");
|
||||||
Print::type("rundown gun store on the edge of town. Folks called him Shotgun Pete. They laughed at his bunker in the");
|
Sleep::delay(time);
|
||||||
Print::type("basement and his endless stockpile of beans and buckshot.");
|
Sleep::type("The world didn't end with a bang. It ended with a groan.. and the scratching of death fingers against steel shutters.");
|
||||||
Print::type("They’re not laughing now.");
|
Sleep::delay(time);
|
||||||
Print::type("It’s been 47 days since the dead started walking. The city’s overrun. The power’s gone. The roads are broken");
|
Sleep::type("Pete used to sell shotgun, slug, and survival tips to deer hunters and doomsday preppers out of his rundown gun store ");
|
||||||
Print::type("and the rules are worse.");
|
|
||||||
Print::type("But Pete? Pete’s still here. Armed to the teeth. Ready to take back what’s his, one shell at a time.");
|
|
||||||
Print::type("Welcome to Shotgun Pete. Lock and load.");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,5 @@ int main (){
|
||||||
system("clear");
|
system("clear");
|
||||||
Title::mainTitle();
|
Title::mainTitle();
|
||||||
Intro::mainIntro();
|
Intro::mainIntro();
|
||||||
Game game;
|
|
||||||
game.gameloop();
|
|
||||||
cin.get();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
#include "include/player.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,9 @@
|
||||||
#include "include/print.h"
|
#include "include/print.h"
|
||||||
|
|
||||||
void Print::printl(string text){
|
void Print::printl(string text){
|
||||||
cout << text << flush;
|
cout << text;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,3 +8,18 @@ void Sleep::delay(int milliseconds){
|
||||||
// Do nothing, just wait
|
// Do nothing, just wait
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void Sleep::type(string text){
|
||||||
|
int a = text.size();
|
||||||
|
char* charArray = new char[a+1];
|
||||||
|
strcpy(charArray, text.c_str());
|
||||||
|
int i = 0;
|
||||||
|
int time = 300;
|
||||||
|
|
||||||
|
while(i < a+1){
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(time));
|
||||||
|
cout << charArray[i] << flush;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
delete[] charArray;
|
||||||
|
}
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
#include "include/title.h"
|
#include "include/title.h"
|
||||||
#include "include/print.h"
|
|
||||||
#include "include/sleep.h"
|
|
||||||
|
|
||||||
void Title::mainTitle(){
|
void Title::mainTitle(){
|
||||||
int s = 900;
|
int time = 700;
|
||||||
Print::println("");
|
cout << "███████╗██╗ ██╗ ██████╗ ████████╗ ██████╗ ██╗ ██╗███╗ ██╗ ██████╗ ███████╗████████╗███████╗" << endl;
|
||||||
Print::println("\033[31m███████╗██╗ ██╗ ██████╗ ████████╗ ██████╗ ██╗ ██╗███╗ ██╗ ██████╗ ███████╗████████╗███████╗");
|
Sleep::delay(time);
|
||||||
Sleep::delay(s);
|
cout << "██╔════╝██║ ██║██╔═══██╗╚══██╔══╝██╔════╝ ██║ ██║████╗ ██║ ██╔══██╗██╔════╝╚══██╔══╝██╔════╝" << endl;
|
||||||
Print::println("██╔════╝██║ ██║██╔═══██╗╚══██╔══╝██╔════╝ ██║ ██║████╗ ██║ ██╔══██╗██╔════╝╚══██╔══╝██╔════╝");
|
Sleep::delay(time);
|
||||||
Sleep::delay(s);
|
cout << "███████╗███████║██║ ██║ ██║ ██║ ███╗██║ ██║██╔██╗ ██║ ██████╔╝█████╗ ██║ █████╗ " << endl;
|
||||||
Print::println("███████╗███████║██║ ██║ ██║ ██║ ███╗██║ ██║██╔██╗ ██║ ██████╔╝█████╗ ██║ █████╗ ");
|
Sleep::delay(time);
|
||||||
Sleep::delay(s);
|
cout << "╚════██║██╔══██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██╔═══╝ ██╔══╝ ██║ ██╔══╝ " << endl;
|
||||||
Print::println("╚════██║██╔══██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██╔═══╝ ██╔══╝ ██║ ██╔══╝ ");
|
Sleep::delay(time);
|
||||||
Sleep::delay(s);
|
cout << "███████║██║ ██║╚██████╔╝ ██║ ╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ███████╗ ██║ ███████╗" << endl;
|
||||||
Print::println("███████║██║ ██║╚██████╔╝ ██║ ╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ███████╗ ██║ ███████╗");
|
Sleep::delay(time);
|
||||||
Sleep::delay(s);
|
cout << "╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝" << endl;
|
||||||
Print::println("╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue