Implement Wiggle Title Text
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include "../include/asset_mgr.hpp"
|
||||
#include "include/font_writer.hpp"
|
||||
#include "include/paco.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace JabyEngine;
|
||||
@@ -10,14 +13,22 @@ static object::Paco paco;
|
||||
|
||||
static void setup() {
|
||||
Assets::Main::load();
|
||||
FontWriter::setup();
|
||||
paco.setup();
|
||||
}
|
||||
|
||||
static void update() {
|
||||
static const char Title[] = "Pool Box";
|
||||
static constexpr auto TitleLength = (sizeof(Title) - 1)*DefaultFont::Info.font_size.width;
|
||||
|
||||
auto cursor = FontWriter::update(JabyEngine::Make::PositionI16((GPU::Display::Width-TitleLength)/2, 16));
|
||||
paco.update();
|
||||
|
||||
FontWriter::new_font_writer.write(cursor, Title, GPU::Color24::Yellow(), &FontWriter::wiggle);
|
||||
}
|
||||
|
||||
static void render() {
|
||||
FontWriter::new_font_writer.render();
|
||||
paco.render();
|
||||
}
|
||||
|
||||
|
35
examples/PoolBox/application/src/font_writer.cpp
Normal file
35
examples/PoolBox/application/src/font_writer.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "include/font_writer.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp> //< only for __heap_start D:
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace FontWriter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static constexpr auto LibraryFontTIM = SimpleTIM(320, 0, 320, DefaultFont::Info.texture_size.height);
|
||||
|
||||
static FontPrimitive font_buffer[2*256];
|
||||
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)};
|
||||
JabyEngine::FontWriter new_font_writer = JabyEngine::FontWriter::empty();
|
||||
JabyEngine::FontWriter bios_font_writer = JabyEngine::FontWriter::empty();
|
||||
static SimpleTimer<uint8_t> timer;
|
||||
uint8_t wiggle_count = 0;
|
||||
|
||||
void setup() {
|
||||
JabyEngine::DefaultFont::load(&__heap_start, LibraryFontTIM);
|
||||
JabyEngine::GlobalFontPrimitivePool::setup(font_buffer);
|
||||
|
||||
new_font_writer.setup(LibraryFontTIM, JabyEngine::DefaultFont::Info);
|
||||
bios_font_writer.setup(JabyEngine::BIOSFont::TIM, JabyEngine::BIOSFont::Info);
|
||||
timer.reset();
|
||||
}
|
||||
|
||||
State update(const GPU::PositionI16& start) {
|
||||
if(timer.is_expired_for(50_ms)) {
|
||||
timer.reset();
|
||||
wiggle_count++;
|
||||
}
|
||||
|
||||
return State::create(start, wiggle_count);
|
||||
}
|
||||
}
|
14
examples/PoolBox/application/src/include/font_writer.hpp
Normal file
14
examples/PoolBox/application/src/include/font_writer.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include <FontWriter/Type/types.hpp>
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
|
||||
namespace FontWriter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
extern Wiggle wiggle;
|
||||
extern JabyEngine::FontWriter new_font_writer;
|
||||
extern JabyEngine::FontWriter bios_font_writer;
|
||||
|
||||
void setup();
|
||||
State update(const GPU::PositionI16& start);
|
||||
}
|
@@ -8,6 +8,7 @@ namespace object {
|
||||
|
||||
class Paco {
|
||||
private:
|
||||
static constexpr auto Size = Make::SizeI16(120, 128);
|
||||
static const GPU::Color24 Colors[];
|
||||
|
||||
GPU::TexPage::Linked tex_page;
|
||||
@@ -21,7 +22,7 @@ namespace object {
|
||||
Assets::Main::PacoTIM.get_texture_x(), Assets::Main::PacoTIM.get_texture_y()),
|
||||
GPU::TexturePageColor::$4bit).linked()),
|
||||
sprite(Make::SPRT(
|
||||
Make::AreaI16(Make::PositionI16(0, 100), Make::SizeI16(120, 128)),
|
||||
Make::AreaI16(Make::PositionI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height), Size),
|
||||
Make::OffsetPageWithClut(Make::PageOffset(0, 0), Make::PageClut(Assets::Main::PacoTIM.get_clut_x(), Assets::Main::PacoTIM.get_clut_y())),
|
||||
GPU::Color24::Blue()).linked()),
|
||||
timer(),
|
||||
|
@@ -4,15 +4,6 @@ namespace object {
|
||||
const GPU::Color24 Paco :: Colors[] = {GPU::Color24::Red(), GPU::Color24::Green(), GPU::Color24::Blue(), GPU::Color24::Yellow()};
|
||||
|
||||
void Paco :: setup() {
|
||||
/*this->tex_page = Make::TexPage(Make::PositionU16(
|
||||
Assets::Main::PacoTIM.get_texture_x(), Assets::Main::PacoTIM.get_texture_y()),
|
||||
GPU::TexturePageColor::$4bit).linked();
|
||||
|
||||
this->sprite = Make::SPRT(
|
||||
Make::AreaI16(Make::PositionI16(0, 100), Make::SizeI16(120, 128)),
|
||||
Make::OffsetPageWithClut(Make::PageOffset(0, 0), Make::PageClut(Assets::Main::PacoTIM.get_clut_x(), Assets::Main::PacoTIM.get_clut_y())),
|
||||
GPU::Color24::Blue()).linked();*/
|
||||
|
||||
this->timer.reset();
|
||||
this->tex_page.concat(this->sprite);
|
||||
}
|
||||
|
Reference in New Issue
Block a user