Try new design

This commit is contained in:
jaby 2023-12-01 23:07:16 -05:00
parent 018cd9dac0
commit dc5586aca1
6 changed files with 49 additions and 23 deletions

View File

@ -0,0 +1,6 @@
#pragma once
#include <FontWriter/font_writer.hpp>
void font_writer_setup();
void font_writer_update();
void font_writer_render();

View File

@ -9,16 +9,13 @@ namespace object {
this->tex_page.concat(this->sprite);
}
bool Paco :: update() {
void Paco :: update() {
if(this->timer.is_expired_for(325_ms)) {
static constexpr uint8_t LastIDX = (sizeof(Paco::Colors)/sizeof(Paco::Colors[0])) - 1;
this->color_idx = (this->color_idx == LastIDX) ? 0 : this->color_idx + 1;
this->timer.reset();
return true;
}
return false;
}
void Paco :: render() {

View File

@ -30,7 +30,7 @@ namespace object {
color_idx(0) {}
void setup();
bool update();
void update();
void render();
};
}

View File

@ -0,0 +1,35 @@
#include "../include/font_writer.hpp"
#include <PSX/File/Processor/cd_file_processor.hpp>
#include <PSX/GPU/make_gpu_primitives.hpp>
#include <PSX/Timer/frame_timer.hpp>
#include <FontWriter/default_font.hpp>
using JabyEngine::Make::PositionI8;
static constexpr auto FontWriterTIM = JabyEngine::SimpleTIM(320, 0, 320, JabyEngine::DefaultFont::Info.texture_size.height);
static JabyEngine::FontPrimitive font_buffer[2][256];
static JabyEngine::Wiggle wiggle = {PositionI8(0, 0), PositionI8(1, -2), PositionI8(0, -4), PositionI8(-1, -2), PositionI8(0, 0), PositionI8(1, 2), PositionI8(0, 4), PositionI8(-1, 2)};
static JabyEngine::FontWriter new_font_writer = JabyEngine::FontWriter::empty();
static JabyEngine::SimpleTimer<uint8_t> timer;
static uint8_t wiggle_count = 0;
void font_writer_setup() {
JabyEngine::DefaultFont::load(&__heap_start, FontWriterTIM);
new_font_writer.setup(JabyEngine::FontBufferInfo::from(font_buffer), FontWriterTIM, JabyEngine::DefaultFont::Info);
timer.reset();
}
void font_writer_update() {
auto state = JabyEngine::State::create(JabyEngine::Make::PositionI16(8, 8), wiggle_count);
new_font_writer.write(state, "012345 ABCDEFGHIJKL\nabcedfghijkl", JabyEngine::GPU::Color24::Blue(), &wiggle);
if(timer.is_expired_for(250_ms)) {
timer.reset();
wiggle_count++;
}
}
void font_writer_render() {
new_font_writer.render();
}

View File

@ -1,3 +1,4 @@
#include "../include/font_writer.hpp"
#include "FontWriter/font_writer.hpp"
#include "Objects/paco.hpp"
#include "Overlay/Overlay.hpp"
@ -5,25 +6,15 @@
#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);
font_writer_setup();
Assets::load_for_main();
FontWriter::FontWriter::setup();
@ -36,18 +27,15 @@ static void update() {
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++;
}
font_writer_update();
paco.update();
}
static void render() {
GPU::swap_buffers_vsync(1);
FontWriter::FontWriter::render();
paco.render();
new_font_writer.render();
font_writer_render();
}
void main() {

View File

@ -1,7 +1,7 @@
#pragma once
#include <PSX/File/file_types.hpp>
#include <PSX/GPU/gpu_primitives.hpp>
#include <PSX/GPU/gpu_types.hpp>
#include <PSX/GPU/make_gpu_primitives.hpp>
namespace JabyEngine {
using FontPrimitive = GPU::SPRT::Linked;