Skip to content

Removed Unicode dependency and added user32.lib reference, now can be compiled using "cl CommandLineFPS.cpp" on command line #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions CommandLineFPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ using namespace std;

#include <stdio.h>
#include <Windows.h>
#pragma comment(lib, "user32.lib")

int nScreenWidth = 120; // Console Screen Size X (columns)
int nScreenHeight = 40; // Console Screen Size Y (rows)
Expand All @@ -90,29 +91,29 @@ float fSpeed = 5.0f; // Walking Speed
int main()
{
// Create Screen Buffer
wchar_t *screen = new wchar_t[nScreenWidth*nScreenHeight];
char *screen = new char[nScreenWidth*nScreenHeight];
HANDLE hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
SetConsoleActiveScreenBuffer(hConsole);
DWORD dwBytesWritten = 0;

// Create Map of world space # = wall block, . = space
wstring map;
map += L"#########.......";
map += L"#...............";
map += L"#.......########";
map += L"#..............#";
map += L"#......##......#";
map += L"#......##......#";
map += L"#..............#";
map += L"###............#";
map += L"##.............#";
map += L"#......####..###";
map += L"#......#.......#";
map += L"#......#.......#";
map += L"#..............#";
map += L"#......#########";
map += L"#..............#";
map += L"################";
string map;
map += "#########.......";
map += "#...............";
map += "#.......########";
map += "#..............#";
map += "#......##......#";
map += "#......##......#";
map += "#..............#";
map += "###............#";
map += "##.............#";
map += "#......####..###";
map += "#......#.......#";
map += "#......#.......#";
map += "#..............#";
map += "#......#########";
map += "#..............#";
map += "################";

auto tp1 = chrono::system_clock::now();
auto tp2 = chrono::system_clock::now();
Expand Down Expand Up @@ -264,7 +265,7 @@ int main()
}

// Display Stats
swprintf_s(screen, 40, L"X=%3.2f, Y=%3.2f, A=%3.2f FPS=%3.2f ", fPlayerX, fPlayerY, fPlayerA, 1.0f/fElapsedTime);
sprintf_s(screen, 40, "X=%3.2f, Y=%3.2f, A=%3.2f FPS=%3.2f ", fPlayerX, fPlayerY, fPlayerA, 1.0f/fElapsedTime);

// Display Map
for (int nx = 0; nx < nMapWidth; nx++)
Expand Down