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
40
games/animatronical/q1/a1/src/cycletext.h
Normal file
40
games/animatronical/q1/a1/src/cycletext.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#pragma once
|
||||
#include <sstream>
|
||||
extern Color*LOADINGCOLOR[3];
|
||||
struct logi: public virtual enginend::nodes::twod::textfield {
|
||||
logi(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fs,std::string txt) {
|
||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->content=txt;this->theme=theme;
|
||||
this->texture=texture;
|
||||
this->fs=fs;
|
||||
}
|
||||
int delay=0;
|
||||
int wait=0,amount=10;
|
||||
void draw() override {
|
||||
float spacing=fs/2.0f;
|
||||
if(++delay>=10){
|
||||
Color*tmp=LOADINGCOLOR[2];
|
||||
LOADINGCOLOR[2]=LOADINGCOLOR[1];
|
||||
LOADINGCOLOR[1]=LOADINGCOLOR[0];
|
||||
LOADINGCOLOR[0]=tmp;
|
||||
delay=0;
|
||||
}
|
||||
if(++wait>20){
|
||||
wait=0;
|
||||
int max=(content.size()/2)*2;
|
||||
if(++amount>=max)amount=0;
|
||||
}
|
||||
int vispos=amount>>1;
|
||||
int len=content.size();
|
||||
Vector2 charPos=pos;
|
||||
for(int i=0;i<len;i++){
|
||||
int part=i/2;
|
||||
if(part<vispos||(part==vispos&&(amount%2==0||i<vispos*2))){
|
||||
char c=content[i];
|
||||
char str[2]={c,'\0'};
|
||||
Color fc=*LOADINGCOLOR[part%3];
|
||||
DrawTextEx(this->theme->font,str,charPos,(float)fs,spacing,fc);
|
||||
charPos.x+=MeasureTextEx(this->theme->font,str,(float)fs,spacing).x;
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,32 +1,105 @@
|
|||
#include "scenes/game.h"
|
||||
#include "scenes/mainmenu.h"
|
||||
#include "cycletext.h"
|
||||
tiny::ErrorLevel tiny::level{9};
|
||||
PLATFORM platform=LINUX;
|
||||
std::string androidpackage="kn.kinfuyuki.animatronical-q1a1";
|
||||
Font gamefont;
|
||||
Font loadingfont;
|
||||
char changeto=0;
|
||||
Color*LOADINGCOLOR[3] {
|
||||
new Color{255,255,0,255},
|
||||
new Color{255,0,255,255},
|
||||
new Color{0,255,255,255}
|
||||
};
|
||||
class anim: public enginend::program {
|
||||
public:
|
||||
int loadscreensecs=0;
|
||||
int loadingscreen=0;
|
||||
RenderTexture2D buffer;
|
||||
enginend::nodes::twod::animated* caramel;
|
||||
logi* loadingtext;
|
||||
const char *CONF() override{return "SAVEFILE.TDF";}
|
||||
|
||||
bool changing=false;
|
||||
Image aniicon;
|
||||
void boot() override {
|
||||
aniicon=LoadImage("res/icon.png");
|
||||
this->currentscene=new mainmenu;
|
||||
|
||||
SetConfigFlags(FLAG_VSYNC_HINT|FLAG_WINDOW_RESIZABLE);
|
||||
InitWindow(380,240,"ani1");
|
||||
|
||||
SetWindowIcon(aniicon);
|
||||
InitAudioDevice();
|
||||
gamefont=LoadFont(AT("res/font/mga.ttf"));
|
||||
caramel=new enginend::nodes::twod::animated(
|
||||
AT("res/loading/out2.gif"),{0,0},{320,240},6
|
||||
);
|
||||
loadingtext=new logi(
|
||||
nullptr,enginend::DEFAULT,0,220,200,16,16,"LOADING..."
|
||||
);
|
||||
buffer=LoadRenderTexture(320,240);
|
||||
enginend::DEFAULT->font=gamefont;
|
||||
currentscene->boot();
|
||||
}
|
||||
void tick() override {
|
||||
if (IsKeyDown(KEY_LEFT_ALT)&&IsKeyDown(KEY_F4))shouldclose=true;
|
||||
currentscene->tick();
|
||||
if(changing) {
|
||||
loadingscreen++;
|
||||
caramel->tick();
|
||||
loadingtext->tick();
|
||||
if (loadingscreen>loadscreensecs) {
|
||||
changing=false;
|
||||
loadingscreen=0;
|
||||
currentscene->exit();
|
||||
delete currentscene;
|
||||
currentscene= new game;
|
||||
currentscene->boot();
|
||||
currentscene->tick();
|
||||
}
|
||||
}
|
||||
else currentscene->tick();
|
||||
}
|
||||
void draw() override {
|
||||
currentscene->draw();
|
||||
BeginTextureMode(buffer);
|
||||
ClearBackground(rl::BLACK);
|
||||
int currscene=changeto;
|
||||
if (!changing)currentscene->draw();
|
||||
else {
|
||||
caramel->draw();
|
||||
loadingtext->draw();
|
||||
}
|
||||
EndTextureMode();
|
||||
|
||||
if (currscene!=changeto) {
|
||||
tiny::success("yay");
|
||||
switch (changeto) {
|
||||
case 0:
|
||||
currentscene->exit();
|
||||
delete currentscene;
|
||||
currentscene= new mainmenu;
|
||||
currentscene->boot();
|
||||
break;
|
||||
case 1:
|
||||
changing=true;
|
||||
loadscreensecs=GetRandomValue(2*60,10*60);
|
||||
break;
|
||||
default:
|
||||
tiny::fatal("wtf");
|
||||
}
|
||||
}
|
||||
|
||||
BeginDrawing();
|
||||
ClearBackground(rl::BLACK);
|
||||
DrawTexturePro(buffer.texture,{0,0,320,-240},{0,0,(float)GetScreenWidth(),(float)GetScreenHeight()},{0,0},0,rl::WHITE);
|
||||
EndDrawing();
|
||||
}
|
||||
void exit() override {
|
||||
currentscene->exit();
|
||||
}
|
||||
};
|
||||
|
||||
char changeto=-1;
|
||||
int main() {
|
||||
anim dagame;
|
||||
dagame.boot();
|
||||
|
|
|
|||
|
|
@ -38,19 +38,40 @@ struct game:public enginend::scene {
|
|||
entity skaile{10,3};
|
||||
entity player{0,1};
|
||||
Texture2D current;
|
||||
Texture2D skailemenu[3];
|
||||
bool iskailepressed=false;
|
||||
bool iskailemenu=false;
|
||||
|
||||
bool canseeuycatroz=false;
|
||||
bool canseeskaile=false;
|
||||
float crystallyprogress=1.;
|
||||
void exit() override {
|
||||
UnloadTexture(current);
|
||||
for (Texture2D i: skailemenu) {
|
||||
|
||||
UnloadTexture(i);
|
||||
}
|
||||
scene::exit();
|
||||
}
|
||||
void boot() final {
|
||||
mappath=AT("res/map");
|
||||
this->nodes={
|
||||
new enginend::nodes::twod::relative::textured()
|
||||
};
|
||||
std::string newpath=AT((mappath+"/"+lightlevel[lightmode]+"/"+sides[player.dir]+"/"+std::to_string(player.pos)+".jpg"));
|
||||
|
||||
skailemenu[0]=LoadTexture(AT("res/gui/buttonf.png"));
|
||||
skailemenu[1]=LoadTexture(AT("res/gui/buttonn.png"));
|
||||
skailemenu[2]=LoadTexture(AT("res/gui/skailevisor.png"));
|
||||
current=LOADMAP
|
||||
}
|
||||
void tick() final {
|
||||
if (iskailemenu) {
|
||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
|
||||
iskailepressed=true;
|
||||
}else {
|
||||
iskailepressed=false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void draw() final {
|
||||
bool changed=false;
|
||||
bool updateview=false;
|
||||
if (stamina>=1.){
|
||||
|
|
@ -58,6 +79,14 @@ struct game:public enginend::scene {
|
|||
if (ifbackward()){player.pos=moveentity(player.pos,player.dir,true);changed=true;}
|
||||
if (ifleft()){player.dir=rotateentity(player.pos,player.dir,false);changed=true;}
|
||||
if (ifright()){player.dir=rotateentity(player.pos,player.dir,true);changed=true;}
|
||||
if (ifflashlight()){lightmode=!lightmode;changed=true;}
|
||||
if (ifinteract()) {
|
||||
changed=true;
|
||||
if (player.dir==0&&player.pos==0)changeto=0;
|
||||
else if (moveentity(player.pos,player.dir,false)==skaile.pos) {
|
||||
iskailemenu=!iskailemenu;
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
UnloadTexture(current);
|
||||
std::string newpath=AT((mappath+"/"+lightlevel[lightmode]+"/"+sides[player.dir]+"/"+std::to_string(player.pos)+".jpg"));
|
||||
|
|
@ -74,25 +103,28 @@ struct game:public enginend::scene {
|
|||
|
||||
}
|
||||
}else stamina+=.01;
|
||||
float screenw=320;float screenh=240;
|
||||
|
||||
if(!iskailemenu) {
|
||||
DrawTexturePro(current,{0,0,480,280},{0,0,screenw,screenh},{0,0},0,rl::WHITE);
|
||||
if (canseeuycatroz)DrawRectangle(
|
||||
screenw/10.,screenh/10.,screenw/12,screenh/1.5,rl::BLUE);
|
||||
if (canseeskaile)DrawRectangle(
|
||||
screenw/2.,screenh/10.,screenw/12,screenh/1.5,rl::RED);
|
||||
}else {
|
||||
if (iskailemenu) {
|
||||
DrawTexture(skailemenu[2],0,0,rl::WHITE);
|
||||
tiny::success("%i",iskailepressed);
|
||||
DrawTexture(skailemenu[iskailepressed],261,120,rl::WHITE);
|
||||
|
||||
}
|
||||
}
|
||||
DrawText(("pos: "+std::to_string(player.pos)+" dir:"+std::to_string(player.dir)).c_str(),0,0,16,rl::WHITE);
|
||||
DrawText(("uypos: "+std::to_string(uycatroz.pos)+" uydir:"+std::to_string(uycatroz.dir)).c_str(),0,32,16,rl::SKYBLUE);
|
||||
DrawText(("skpos: "+std::to_string(skaile.pos)+" skdir:"+std::to_string(skaile.dir)).c_str(),0,48,16,rl::RED);
|
||||
DrawText(("crystally: "+std::to_string(crystallyprogress)).c_str(),0,64,16,rl::LIME);
|
||||
|
||||
|
||||
}
|
||||
void draw() final {
|
||||
float screenw=(float)GetScreenWidth();float screenh=(float)GetScreenHeight();
|
||||
BeginDrawing();
|
||||
ClearBackground(rl::WHITE);
|
||||
DrawTexturePro(current,{0,0,480,280},{0,0,screenw,screenh},{0,0},0,rl::WHITE);
|
||||
if (canseeuycatroz)DrawRectangle(
|
||||
screenw/10.,screenh/10.,screenw/12,screenh/1.5,rl::BLUE);
|
||||
if (canseeskaile)DrawRectangle(
|
||||
screenw/2.,screenh/10.,screenw/12,screenh/1.5,rl::RED);
|
||||
DrawText(("pos: "+std::to_string(player.pos)+" dir:"+std::to_string(player.dir)).c_str(),0,0,64,rl::WHITE);
|
||||
DrawText(("uypos: "+std::to_string(uycatroz.pos)+" uydir:"+std::to_string(uycatroz.dir)).c_str(),0,64,64,rl::SKYBLUE);
|
||||
DrawText(("skpos: "+std::to_string(skaile.pos)+" skdir:"+std::to_string(skaile.dir)).c_str(),0,128,64,rl::RED);
|
||||
DrawText(("crystally: "+std::to_string(crystallyprogress)).c_str(),0,196,64,rl::LIME);
|
||||
|
||||
|
||||
EndDrawing();
|
||||
|
||||
}
|
||||
};
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include <cmath>
|
||||
#include <enginend/engine.h>
|
||||
#include "shared.h"
|
||||
|
||||
|
|
@ -13,6 +14,8 @@ public:
|
|||
mainmenu() {
|
||||
|
||||
}
|
||||
enginend::nodes::twod::labeledbutton* play;
|
||||
enginend::nodes::twod::labeledbutton* version;
|
||||
void boot() override {
|
||||
std::string modifier=".png";
|
||||
bg=LoadTexture(AT("res/menu/"+
|
||||
|
|
@ -38,25 +41,59 @@ public:
|
|||
"if(idx<0.7||idx>0.9){idx*=randf;}"
|
||||
"gl_FragColor=vec4(texel.rgb,texel.a*idx);}"
|
||||
);
|
||||
enginend::DEFAULT->tint={255,255,255,0};
|
||||
play=new enginend::nodes::twod::labeledbutton("PLAY",
|
||||
nullptr,enginend::DEFAULT,0.65,0.75,0.5,0.05,std::function<void()>([]() {
|
||||
changeto=1;
|
||||
}),1
|
||||
);
|
||||
version=new enginend::nodes::twod::labeledbutton("0.1c",
|
||||
nullptr,enginend::DEFAULT,0.65,0.75,0.5,0.05,std::function<void()>([]() {
|
||||
changeto=2;
|
||||
}),1
|
||||
);
|
||||
}
|
||||
void tick() override {
|
||||
|
||||
play->tick();
|
||||
version->tick();
|
||||
}
|
||||
void draw() override {
|
||||
float screenw=(float)GetScreenWidth();float screenh=(float)GetScreenHeight();
|
||||
float screenw=320;float screenh=240;
|
||||
UpdateMusicStream(bgm);
|
||||
BeginDrawing();
|
||||
ClearBackground(rl::BLACK);
|
||||
DrawTexturePro(bg,{0,0,320,240},{0,0,screenw,screenh},{0,0},0,rl::WHITE);
|
||||
float t=GetTime()/200000;
|
||||
SetShaderValue(bzzzz,GetShaderLocation(bzzzz,"t"),&t,SHADER_UNIFORM_FLOAT);
|
||||
BeginShaderMode(bzzzz);
|
||||
DrawTexturePro(title,{0,0,1065,194},{0,0,screenw,(screenh/4)},{0,0},0,rl::WHITE);
|
||||
EndShaderMode();
|
||||
EndDrawing();
|
||||
play->fs=std::sqrt(screenh+screenw);
|
||||
play->pos={0.65f*screenw,0.75f*screenh};
|
||||
play->size={0.3f*screenw,0.2f*screenh};
|
||||
unsigned char hovering=play->hover?play->pressed?128:64:0;
|
||||
enginend::DEFAULT->tint={255,255,255,hovering};
|
||||
enginend::DEFAULT->buttontext[0]=enginend::DEFAULT->buttontext[1]=enginend::DEFAULT->buttontext[2]=
|
||||
{255,0,255,255};
|
||||
play->draw();
|
||||
hovering=version->hover?version->pressed?128:64:0;
|
||||
enginend::DEFAULT->tint={255,255,255,hovering};
|
||||
|
||||
version->fs=std::sqrt(screenh+screenw);
|
||||
version->pos={0.05f*screenw,0.75f*screenh};
|
||||
version->size={0.3f*screenw,0.2f*screenh};
|
||||
|
||||
enginend::DEFAULT->buttontext[0]=enginend::DEFAULT->buttontext[1]=enginend::DEFAULT->buttontext[2]=
|
||||
{0,255,255,255};
|
||||
|
||||
version->draw();
|
||||
|
||||
}
|
||||
void exit() override {
|
||||
|
||||
play->exit();
|
||||
version->exit();
|
||||
StopMusicStream(bgm);
|
||||
UnloadTexture(bg);
|
||||
UnloadTexture(title);
|
||||
UnloadMusicStream(bgm);
|
||||
UnloadShader(bzzzz);
|
||||
}
|
||||
};
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
// N S L R
|
||||
std::vector<char>opposites{1,0,3,2};
|
||||
std::vector<char> sides{
|
||||
'n','s','l','r'
|
||||
'n','s','r','l'
|
||||
};
|
||||
std::vector<std::string> lightlevel{
|
||||
"off","on","urcooked"
|
||||
|
|
@ -106,12 +106,13 @@ bool ifright(){
|
|||
bool ifinteract() {
|
||||
if (IsKeyPressed(KEY_RIGHT_CONTROL))return true;
|
||||
if (IsKeyPressed(KEY_KP_7))return true;
|
||||
if (IsKeyPressed(KEY_E))return true;
|
||||
if (IsKeyPressed(KEY_SPACE))return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ifflashlight() {
|
||||
if (IsKeyPressed(KEY_E))return true;
|
||||
if (IsKeyPressed(KEY_F))return true;
|
||||
if (IsKeyPressed(KEY_KP_9))return true;
|
||||
if (IsKeyPressed(KEY_RIGHT_SHIFT))return true;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
#pragma once
|
||||
extern char changeto;
|
||||
#include <enginend/engine.h>
|
||||
extern char changeto;
|
||||
extern Font gamefont;
|
||||
Loading…
Add table
Add a link
Reference in a new issue