Compare commits

..

No commits in common. "72a07395c75600694f5847255d75aa237ab4dfa4" and "b57c137dafb70d35f93c7e493260e8460e6f66f7" have entirely different histories.

5 changed files with 2 additions and 44 deletions

1
.gitignore vendored
View File

@ -6,4 +6,3 @@ banner.txt
print.d
intro.d
sleep.d
game.d

View File

@ -1,26 +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();
}
}

View File

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

View File

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

View File

@ -5,9 +5,7 @@ int main (){
//Title title;
Title::mainTitle();
//Intro intro;
//Intro::mainIntro();
Game game;
game.gameloop();
cin.get();
Intro::mainIntro();
//cin >> ;
return 0;
}