This repository has been archived on 2022-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
glyphs-juke/src/main.cc

50 lines
1.0 KiB
C++
Raw Normal View History

2021-08-21 08:29:58 +00:00
#include <iostream>
#include <string>
2021-08-23 05:22:56 +00:00
#define NOMINMAX
2021-08-21 08:29:58 +00:00
#include <windows.h>
2021-08-23 05:22:56 +00:00
#undef NOMINMAX
2021-08-21 08:29:58 +00:00
#include "common.h"
#include "Font.h"
2021-08-23 05:22:56 +00:00
#include "Game.h"
2021-08-21 08:29:58 +00:00
#include "LinearAllocator.h"
2021-08-25 03:27:39 +00:00
#include "SystemClock.h"
2021-08-21 08:29:58 +00:00
#include "Win32Console.h"
constexpr size_t kHeapSize = 1024*1024*64;
constexpr uint32_t kWidth = 96;
constexpr uint32_t kHeight = 28;
int main() {
auto memory = std::make_unique<uint8_t[]>(kHeapSize);
gj::LinearAllocator alloc(memory.get(), kHeapSize);
gj::Win32Console console(&alloc, kWidth, kHeight);
console.Show();
2021-08-25 03:27:39 +00:00
gj::Game::Param param;
param.alloc = &alloc;
param.clock = &gj::SystemClock::instance();
param.w = kWidth;
param.h = kHeight;
gj::Game game(std::move(param));
2021-08-21 08:29:58 +00:00
while (true) {
2021-08-26 05:51:50 +00:00
game.Update(console.TakeInput());
2021-08-21 08:29:58 +00:00
{
2021-08-23 05:22:56 +00:00
auto& fb = console.TakeColorbuffer();
fb.Clear();
game.Draw(fb);
console.SwapColorbuffer();
2021-08-21 08:29:58 +00:00
}
{
2021-08-23 05:22:56 +00:00
auto& fb = console.TakeTextbuffer();
fb.Clear();
game.Write(fb);
console.SwapTextbuffer();
2021-08-21 08:29:58 +00:00
}
Sleep(10);
2021-08-21 08:29:58 +00:00
}
}