weird bug happened where lots stuf corrupted, better i commit asap
This commit is contained in:
parent
b07bb475a7
commit
aa92184cf5
243 changed files with 488 additions and 92 deletions
|
|
@ -35,21 +35,23 @@ namespace enginend::nodes::twod {
|
|||
int framecounter;
|
||||
unsigned int nextframeoffset;
|
||||
int prevframe;
|
||||
|
||||
const char*path;
|
||||
animated() : frames(0), currentframe(0), framedelay(6), framecounter(0), nextframeoffset(0) {
|
||||
animimage.data = nullptr;
|
||||
}
|
||||
|
||||
animated(const char* gifpath, Vector2 position, Vector2 size, int delay = 6)
|
||||
: textured(nullptr, position.x, position.y, size.x, size.y),
|
||||
framedelay(delay), currentframe(0), framecounter(0), frames(0), nextframeoffset(0)
|
||||
framedelay(delay), currentframe(0), framecounter(0), frames(0), nextframeoffset(0),path(gifpath)
|
||||
{
|
||||
animimage = LoadImageAnim(gifpath, &frames);
|
||||
animimage = LoadImageAnim(path, &frames);
|
||||
if (frames > 0) {
|
||||
texture = new Texture2D(LoadTextureFromImage(animimage));
|
||||
}
|
||||
}
|
||||
|
||||
void boot() override {
|
||||
|
||||
}
|
||||
void tick() override {
|
||||
textured::tick();
|
||||
if (frames <= 1) return;
|
||||
|
|
@ -162,11 +164,25 @@ namespace enginend::nodes::twod {
|
|||
}
|
||||
void boot()override{this->tinted::boot();}
|
||||
void tick()override{
|
||||
this->tinted::tick();
|
||||
}
|
||||
void draw()override {
|
||||
|
||||
this->tinted::tick();
|
||||
|
||||
Vector2 mouse=GetMousePosition();
|
||||
float wstretch=(float)GetScreenWidth()/(float)GetRenderWidth();
|
||||
float hstretch=(float)GetScreenHeight()/(float)GetRenderHeight();
|
||||
mouse.x/=wstretch;mouse.y/=hstretch;
|
||||
tiny::echo(
|
||||
"render:\nwidth:%i height:%i\n\nscreen:\nwidth:%i height:%i\n\n\n",
|
||||
GetRenderWidth(),GetRenderHeight(),
|
||||
GetScreenWidth(),GetScreenHeight()
|
||||
);
|
||||
|
||||
tiny::echo(
|
||||
"stretch:\nwidth:%f height:%f\n\nmouse:\nwidth:%f height:%f",
|
||||
wstretch,hstretch,
|
||||
mouse.x,mouse.y
|
||||
);
|
||||
if(CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y})){hover=true;
|
||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
||||
pressed=true;
|
||||
|
|
@ -200,7 +216,6 @@ namespace enginend::nodes::twod {
|
|||
};
|
||||
struct labeledbutton :virtual public button {
|
||||
std::string label;
|
||||
Font font;
|
||||
int fs;
|
||||
Color txc;
|
||||
labeledbutton(std::string name,Texture2D* texture,enginend::theme* theme,
|
||||
|
|
@ -229,12 +244,12 @@ namespace enginend::nodes::twod {
|
|||
this->theme->booleantext[3]:this->theme->booleantext[0]:
|
||||
this->theme->buttontext[0];
|
||||
}
|
||||
Vector2 tsize=MeasureTextEx(font,label.c_str(),fs,1);
|
||||
Vector2 tsize=MeasureTextEx(theme->font,label.c_str(),fs,1);
|
||||
Vector2 tpos={
|
||||
pos.x+(size.x-tsize.x)/2,
|
||||
pos.y+(size.y-tsize.y)/2
|
||||
};
|
||||
DrawTextEx(font,label.c_str(),tpos,fs,1,txc);
|
||||
DrawTextEx(theme->font,label.c_str(),tpos,fs,1,txc);
|
||||
}
|
||||
void exit()override{this->button::exit();}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ namespace enginend::nodes::twod::relative {
|
|||
void tick() override{}
|
||||
void draw()override{
|
||||
if(texture==nullptr)return;
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
float ax=x*sw;
|
||||
float ay=y*sh;
|
||||
float aw=w*sw;
|
||||
|
|
@ -95,8 +95,8 @@ namespace enginend::nodes::twod::relative {
|
|||
void boot()override{}
|
||||
void tick()override{}
|
||||
void draw()override{
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
float ax=x*sw;
|
||||
float ay=y*sh;
|
||||
float aw=w*sw;
|
||||
|
|
@ -120,8 +120,8 @@ namespace enginend::nodes::twod::relative {
|
|||
colored::draw();
|
||||
return;
|
||||
}
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
float ax=x*sw;
|
||||
float ay=y*sh;
|
||||
float aw=w*sw;
|
||||
|
|
@ -164,8 +164,8 @@ namespace enginend::nodes::twod::relative {
|
|||
}
|
||||
}
|
||||
void draw()override {
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
float ax=x*sw;
|
||||
float ay=y*sh;
|
||||
|
||||
|
|
@ -206,8 +206,11 @@ namespace enginend::nodes::twod::relative {
|
|||
void draw()override {
|
||||
|
||||
Vector2 mouse=GetMousePosition();
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float wstretch=(float)GetScreenWidth()/(float)GetRenderWidth();
|
||||
float hstretch=(float)GetScreenHeight()/(float)GetRenderHeight();
|
||||
mouse.x/=wstretch;mouse.y/=hstretch;
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
Rectangle r={float(x*sw),float(y*sh),float(w*sw),float(h*sh)};
|
||||
if(CheckCollisionPointRec(mouse,r)){hover=true;
|
||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
||||
|
|
@ -259,8 +262,8 @@ namespace enginend::nodes::twod::relative {
|
|||
}
|
||||
void draw()override{
|
||||
button::draw();
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
float ax=x*sw;
|
||||
float ay=y*sh;
|
||||
float aw=w*sw;
|
||||
|
|
@ -307,8 +310,8 @@ namespace enginend::nodes::twod::relative {
|
|||
void boot()override{}
|
||||
void tick()override{
|
||||
Vector2 mouse=GetMousePosition();
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
Rectangle r={float(x*sw),float(y*sh),float(w*sw),float(h*sh)};
|
||||
if(CheckCollisionPointRec(mouse,r)&&IsMouseButtonDown(MOUSE_LEFT_BUTTON)){
|
||||
float t=(mouse.x-(x*sw))/(w*sw);
|
||||
|
|
@ -318,8 +321,8 @@ namespace enginend::nodes::twod::relative {
|
|||
}
|
||||
}
|
||||
void draw()override{
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
float ax=x*sw;
|
||||
float ay=y*sh;
|
||||
float aw=w*sw;
|
||||
|
|
@ -341,8 +344,8 @@ namespace enginend::nodes::twod::relative {
|
|||
text::tick();
|
||||
}
|
||||
void draw()override{
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
float ax=x*sw;
|
||||
float ay=y*sh;
|
||||
float aw=w*sw;
|
||||
|
|
@ -369,8 +372,8 @@ namespace enginend::nodes::twod::relative {
|
|||
void tick()override{
|
||||
text::tick();
|
||||
Vector2 mouse=GetMousePosition();
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
Rectangle r={float(x*sw),float(y*sh),float(w*sw),float(h*sh)};
|
||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
||||
active=CheckCollisionPointRec(mouse,r);
|
||||
|
|
@ -393,8 +396,8 @@ namespace enginend::nodes::twod::relative {
|
|||
void draw()override{
|
||||
text::draw();
|
||||
if(active){
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
float ax=x*sw;
|
||||
float ay=y*sh;
|
||||
DrawRectangle(ax+MeasureTextEx(this->theme->font,content.c_str(),fs,1).x,ay,2,fs,{0,0,0,127});
|
||||
|
|
@ -414,8 +417,8 @@ namespace enginend::nodes::twod::relative {
|
|||
void tick()override{
|
||||
textfield::tick();
|
||||
Vector2 mouse=GetMousePosition();
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
Rectangle r={float(x*sw),float(y*sh),float(w*sw),float(h*sh)};
|
||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
||||
active=CheckCollisionPointRec(mouse,r);
|
||||
|
|
@ -442,8 +445,8 @@ namespace enginend::nodes::twod::relative {
|
|||
void draw()override{
|
||||
textfield::draw();
|
||||
if(active){
|
||||
float sw=GetScreenWidth();
|
||||
float sh=GetScreenHeight();
|
||||
float sw=GetRenderWidth();
|
||||
float sh=GetRenderHeight();
|
||||
float ax=x*sw;
|
||||
float ay=y*sh;
|
||||
float lh=fs+2;
|
||||
|
|
|
|||
|
|
@ -45,10 +45,21 @@ namespace enginend::nodes::trid {
|
|||
};
|
||||
struct object3d:public physicsagent {
|
||||
Model* model;
|
||||
const char *path;
|
||||
object3d(const char* path):path(path) {
|
||||
}
|
||||
void boot() override {
|
||||
(*model)=LoadModel(path);
|
||||
}
|
||||
void tick() override {
|
||||
|
||||
}
|
||||
void draw() override {
|
||||
DrawModel(*model,pos,1.,tint);
|
||||
}
|
||||
void exit() override {
|
||||
UnloadModel(*model);
|
||||
delete model;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue