Testing out new Title Image.

This commit is contained in:
2025-02-05 00:04:04 -05:00
parent be1e04eac9
commit a6cf319c1c
9 changed files with 29 additions and 18 deletions

View File

@@ -48,7 +48,7 @@ CPMAddPackage(
CPMAddPackage(
NAME JGL
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-47.zip
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-48.zip
)
CPMAddPackage(

View File

@@ -43,6 +43,7 @@ namespace CaveGame::Client
JGL::Texture* player_sprite;
JGL::Texture* explosion_sprite;
JGL::Texture* title_img;
AssetService();

View File

@@ -43,10 +43,12 @@ namespace CaveGame::Client
void PassMouseMovement(const J3ML::LinearAlgebra::Vector2 &pos) override;
protected:
JUI::Scene* scene;
JUI::TextRect* title;
JUI::Rect* title;
JUI::Rect* button_group;
JUI::Rect* changelog;
JGL::Texture* bg; // TODO: RAII on this
// TODO: Texture instances created in the lifetime of this class, somehow cause JGL::Draw to segfault!! Please investigate.
Vector2 mpos {0,0};
Vector2 goal {0,0};
private:

View File

@@ -11,8 +11,9 @@ CaveGame::Client::AssetService::AssetService() {
}
void CaveGame::Client::AssetService::TempLoadSimple() {
player_sprite = new JGL::Texture("assets/textures/player.png", JGL::TextureFilteringMode::NEAREST);
explosion_sprite = new JGL::Texture("assets/textures/explosion.png", JGL::TextureFilteringMode::NEAREST);
player_sprite = new JGL::Texture("assets/textures/player.png", JGL::FilteringMode::NEAREST);
explosion_sprite = new JGL::Texture("assets/textures/explosion.png", JGL::FilteringMode::NEAREST);
title_img = new JGL::Texture("assets/textures/title_1.png");
}
void CaveGame::Client::AssetService::EnqueueDefaultAssetsFolder() {

View File

@@ -54,7 +54,7 @@ void CaveGame::Client::TileHotbar::Load(CaveGame::Client::LocalWorld *world) {
int icon_size = 16;
auto* canvas_texture = new Texture(Vector2((float) icon_size, (float) icon_size));
auto* canvas_texture = new Texture(Vector2i( icon_size, icon_size));
auto* tile_icon_canvas = new RenderTarget(canvas_texture, {0, 0, 0, 0});
JGL::J2D::Begin(tile_icon_canvas, true);

View File

@@ -2,6 +2,8 @@
#include <JUI/Widgets/TextRect.hpp>
#include "JUI/Widgets/ListLayout.hpp"
#include "JUI/Widgets/Button.hpp"
#include "JUI/Widgets/Image.hpp"
#include "Client/AssetService.hpp"
CaveGame::Client::MainMenu::MainMenu() : Scene()
{
@@ -36,6 +38,7 @@ void CaveGame::Client::MainMenu::Load() {
bg = new JGL::Texture("assets/textures/bg.png");
Scene::Load();
}
@@ -71,20 +74,24 @@ void CaveGame::Client::MainMenu::BuildWidgets() {
using namespace JUI;
title = new TextRect(scene);
title->SetFont(JGL::Fonts::Jupiteroid);
title->SetContent("CaveGame");
title->SetTextColor(Colors::White);
title->SetTextSize(64);
//title->SetFont(JGL::Fonts::Jupiteroid);
//title->SetContent("CaveGame");
//title->SetTextColor(Colors::White);
//title->SetTextSize(64);
title->Position({0, 0, 0.5f, 0.2f});
title->Size({0, 0, 0.3f, 0.15f});
title->Size({0, 0, 0.5f, 0.25f});
title->AnchorPoint({0.5f, 0.5f});
title->Center();
//title->Center();
title->BGColor({0,0,0,0});
title->SetBorderStyling(Colors::Cyans::Cyan, 1);
auto* content = new JUI::Image(title);
content->Content(Client::AssetService::Get()->title_img);
content->FitImageToParent(true);
button_group = new Rect(scene);
button_group->Size({250, 400, 0, 0});
button_group->Position({0, 0, 0.5f, 0.3f});
button_group->Position({0, 0, 0.5f, 0.4f});
button_group->AnchorPoint({0.5f, 0.f});
button_group->BGColor({0,0,0,0});
button_group->SetBorderStyling(Colors::Cyans::Cyan, 1);

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -79,13 +79,13 @@ namespace CaveGame::ClientApp
this->SetResizable(true);
this->SetVsyncEnabled(false);
// TODO: Implement Resource/Asset manager rather than passing asset references around like this.
this->menu_ctx->BuildWidgets();
this->assets.TempLoadSimple();
this->assets.EnqueueDefaultAssetsFolder();
this->ChangeScene(this->splash_ctx);
// TODO: Implement Resource/Asset manager rather than passing asset references around like this.
this->menu_ctx->BuildWidgets();
Gameloop();
processOnClose();

View File

@@ -12,7 +12,7 @@ namespace CaveGame::Core
//AABB2D quad;
};
class KeyframeAnimation
/* class KeyframeAnimation
{
Event<> Began;
Event<> Complete;
@@ -22,7 +22,7 @@ namespace CaveGame::Core
std::vector<Frame> keyframes;
float timer;
int keyframe_index;
};
};*/
class AnimatedSprite {
public:
@@ -32,7 +32,7 @@ namespace CaveGame::Core
void DrawFrame();
void DrawCurrentFrame();
void PlayAnimation(const KeyframeAnimation& anim);
//void PlayAnimation(const KeyframeAnimation& anim);
protected:
private:
};