The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'! https://forums.lestoria.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AdventuresInLestoria/Crawler/CharacterRotatingDisplay.h

35 lines
1.4 KiB

#pragma once
#include "MenuComponent.h"
#include "DEFINES.h"
#include "Crawler.h"
INCLUDE_game
class CharacterRotatingDisplay:public MenuComponent{
protected:
Decal*icon;
float timer;
float rotatingFactor=7;
float perspectiveFactor=6;
public:
inline CharacterRotatingDisplay(MenuType parent,geom2d::rect<float>rect,Decal*icon)
:MenuComponent(parent,rect,"",DO_NOTHING),icon(icon){}
protected:
virtual inline void Update(Crawler*game)override{
MenuComponent::Update(game);
timer+=game->GetElapsedTime();
if(timer>=2*PI){
timer-=2*PI;
}
}
virtual inline void Draw(Crawler*game,vf2d parentPos)override{}
virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{
//MenuComponent::DrawDecal(game,parentPos,focused);
game->DrawWarpedDecal(icon,std::array<vf2d,4>{
parentPos+rect.middle()+vf2d{abs(sin(timer)),sin(float(timer+PI))}*vf2d{rotatingFactor,perspectiveFactor},
parentPos+rect.middle()+vf2d{0,rect.size.y}+vf2d{abs(sin(timer)),sin(timer)}*vf2d{rotatingFactor,perspectiveFactor},
parentPos+rect.middle()+rect.size+vf2d{-abs(sin(float(timer+PI))),sin(float(timer+PI))}*vf2d{rotatingFactor,perspectiveFactor},
parentPos+rect.middle()+vf2d{rect.size.x,0}+vf2d{-abs(sin(float(timer+PI))),sin(timer)}*vf2d{rotatingFactor,perspectiveFactor},
});
}
};