jabyengine/examples/PoolBox/application/src/main.cpp

65 lines
2.1 KiB
C++

#include "FontWriter/font_writer.hpp"
#include "Objects/paco.hpp"
#include "Overlay/Overlay.hpp"
#include "assets.hpp"
#include <PSX/GPU/gpu.hpp>
#include <PSX/GPU/make_gpu_primitives.hpp>
#include <PSX/Timer/frame_timer.hpp>
#include <FontWriter/default_font.hpp>
#include <FontWriter/font_writer.hpp>
#include <stdio.h>
using namespace JabyEngine;
using NewFontWriter = ::JabyEngine::FontWriter;
static object::Paco paco;
static FontPrimitive font_buffer[2][256];
static NewFontWriter new_font_writer;
static Wiggle wiggle = {Make::PositionI8(0, 0), Make::PositionI8(1, -2), Make::PositionI8(0, -4), Make::PositionI8(-1, -2), Make::PositionI8(0, 0), Make::PositionI8(1, 2), Make::PositionI8(0, 4), Make::PositionI8(-1, 2)};
static uint8_t wiggle_count = 0;
static void setup() {
static constexpr auto FontTIM = SimpleTIM(320, 0, 320, DefaultFont::Info.texture_size.height);
DefaultFont::load(&__heap_start, FontTIM);
new_font_writer.setup(FontBufferInfo::from(font_buffer), FontTIM, DefaultFont::Info);
Assets::load_for_main();
FontWriter::FontWriter::setup();
paco.setup();
}
static void update() {
FontWriter::FontWriter cursor;
const auto end_pos = cursor.write(FontWriter::Position::create(0, 32), "Cody is cute\n&\na \x1b[8;0;0mBAAAAABY!!!");
cursor.write(end_pos, "\x1b[0;7;7mJaby was\nhere c:");
auto state = State::create(Make::PositionI16(8, 8), wiggle_count);
new_font_writer.write(state, "012345 ABCDEFGHIJKL\nabcedfghijkl", GPU::Color24::Blue(), &wiggle);
if(paco.update()) {
wiggle_count++;
}
}
static void render() {
GPU::swap_buffers_vsync(1);
FontWriter::FontWriter::render();
paco.render();
new_font_writer.render();
}
void main() {
setup();
Overlay::TimerTest::mesaure_busy_loop();
JabyEngine::HighResTime::enable();
while(true) {
const auto start = Overlay::TimerTest::start_measuring();
update();
render();
Overlay::TimerTest::end_measuring(start, GPU::Display::frames_per_sec);
}
}