Ready
Some checks failed
Emscripten Build / Build_and_Deploy_Web_Build (push) Failing after 32s

This commit is contained in:
sigonasr2 2026-01-10 09:03:04 -06:00
parent 2208f8671b
commit 34a753737e
9 changed files with 190 additions and 9 deletions

View File

@ -119,7 +119,7 @@ void Renderer3D::OnUserUpdate(PixelGameEngine&pge){
auto DrawFittedString=[&](vf2d pos,float width,const std::string&str,Pixel col,float scale){
pge.DrawStringPropDecal(pos+vf2d{1,1},str,BLACK,{std::min(width/(pge.GetTextSizeProp(str).x*scale),scale),scale});
pge.DrawStringPropDecal(pos,str,WHITE,{std::min(width/(pge.GetTextSizeProp(str).x*scale),scale),scale});
pge.DrawStringPropDecal(pos,str,col,{std::min(width/(pge.GetTextSizeProp(str).x*scale),scale),scale});
};
auto DisplayDiff=[&](vf2d pos,std::pair<Diff,Song>songInfo){
@ -161,7 +161,7 @@ void Renderer3D::OnUserUpdate(PixelGameEngine&pge){
DrawFittedString({12,24},pge.ScreenWidth()/2-24,spheres[0].revealed?spheres[0].songInfo.second.displayName:"?????",WHITE,2);
DrawFittedString({float(pge.ScreenWidth()/2)+12,24},pge.ScreenWidth()/2-24,spheres[1].revealed?spheres[1].songInfo.second.displayName:"?????",WHITE,2);
DrawFittedString({64,200},pge.ScreenWidth()/2-24,spheres[2].revealed?spheres[2].songInfo.second.displayName:"?????",WHITE,2);
DrawFittedString({64,200},pge.ScreenWidth()/2-24,spheres[2].revealed?spheres[2].songInfo.second.displayName:"?????",YELLOW,2);
DisplayDiff({12,120},spheres[0].songInfo);
DisplayDiff({float(pge.ScreenWidth()/2)+12,120},spheres[1].songInfo);

View File

@ -18,9 +18,12 @@ std::vector<std::pair<Diff,Song>>DDREngine::chaosCharts;
std::vector<std::pair<Diff,Song>>DDREngine::enduranceCharts;
std::vector<std::pair<Diff,Song>>DDREngine::bossCharts;
PixelGameEngine*DDREngine::pge;
std::pair<int,int>DDREngine::diffRange;
int DDREngine::bossLevel;
void DDREngine::Init(PixelGameEngine&pge){
DDREngine::pge=&pge;
std::ifstream f("songdata.json");
json data = json::parse(f);

View File

@ -20,6 +20,8 @@ public:
static std::vector<std::pair<Diff,Song>>chaosCharts;
static std::vector<std::pair<Diff,Song>>enduranceCharts;
static std::vector<std::pair<Diff,Song>>bossCharts;
static std::pair<int,int>diffRange;
static int bossLevel;
private:
static json arr;
static std::unordered_map<std::string,int>songids;

View File

@ -2,7 +2,7 @@
#include<string>
#include<optional>
#include"olcPixelGameEngine.h"
class Renderable;
class olc::Renderable;
using Rating=float;
class Difficulty{
public:
@ -20,4 +20,5 @@ public:
const std::string name;
const std::string displayName;
const Difficulty diffs;
bool selected{false};
};

View File

@ -7,12 +7,28 @@
#include<ranges>
#include"Scrambler.h"
#include"3DRender.h"
#include"GrooveRadar.h"
#include<random>
enum State{
RADAR,
RHYTHM,
TECHNICAL,
SPEED,
CHAOS,
ENDURANCE,
BOSS,
ITG
};
// Override base class with your custom functionality
class JTS : public olc::PixelGameEngine
{
Renderer3D render;
Renderer3D rhythmGalaxy,technicalGalaxy,speedGalaxy,chaosGalaxy,enduranceGalaxy,bossGalaxy;
std::unique_ptr<GrooveRadar>radar;
State state{RADAR};
public:
JTS()
@ -27,16 +43,167 @@ public:
bool OnUserCreate() override
{
SetPixelMode(Pixel::MASK);
std::ifstream playerFile("players.json");
json playerFileData = json::parse(playerFile);
if(playerFileData["Game"]=="ITG")state=ITG;
DDREngine::diffRange={playerFileData["Difficulties"][0],playerFileData["Difficulties"][1]};
DDREngine::bossLevel=playerFileData["Boss"];
DDREngine::Init(*this);
render.OnUserCreate(*this);
rhythmGalaxy.OnUserCreate(*this);
technicalGalaxy.OnUserCreate(*this);
speedGalaxy.OnUserCreate(*this);
chaosGalaxy.OnUserCreate(*this);
enduranceGalaxy.OnUserCreate(*this);
bossGalaxy.OnUserCreate(*this);
std::random_device rd;
std::mt19937 rng(rd());
auto random=[&rng](float range){
static std::uniform_real_distribution<float>distrib(0,1);
return distrib(rng)*range;
};
std::vector<std::reference_wrapper<Renderer3D>>galaxies{
rhythmGalaxy,
technicalGalaxy,
speedGalaxy,
chaosGalaxy,
enduranceGalaxy
};
std::vector<std::reference_wrapper<std::vector<std::pair<Diff,Song>>>>chartLists{
DDREngine::rhythmCharts,
DDREngine::technicalCharts,
DDREngine::speedCharts,
DDREngine::chaosCharts,
DDREngine::enduranceCharts,
DDREngine::bossCharts
};
auto GetRandomChart=[&random,&chartLists](std::reference_wrapper<Renderer3D>galaxy,size_t ind,int levelBoost=0,int bossLevel=0){
while(true){
size_t randInd{size_t(random(chartLists[ind].get().size()))};
auto&[diff,song]{chartLists[ind].get()[randInd]};
if(song.selected)continue;
float chartLevel{};
if(diff=="bSP")chartLevel=*song.diffs.bSP;
if(diff=="BSP")chartLevel=*song.diffs.BSP;
if(diff=="DSP")chartLevel=*song.diffs.DSP;
if(diff=="ESP")chartLevel=*song.diffs.ESP;
if(diff=="CSP")chartLevel=*song.diffs.CSP;
if(bossLevel>0){
if(std::min(chartLevel+levelBoost,19.f)<=bossLevel+1.f&&std::min(chartLevel+levelBoost,19.f)>=bossLevel-0.5f){
galaxy.get().AddPlanet({diff,song});
song.selected=true;
return;
}
}else
if((std::min(chartLevel+levelBoost,18.f)<=DDREngine::diffRange.second+0.5f&&std::min(chartLevel+levelBoost,18.f)>=DDREngine::diffRange.first-0.5f)){
galaxy.get().AddPlanet({diff,song});
song.selected=true;
return;
}
}
};
for(size_t ind{0};auto&galaxy:galaxies){
galaxy.get().ClearPlanets();
for(int songsRequiredCounter:std::ranges::iota_view(0,2)){ //2 songs minimum
GetRandomChart(galaxy,ind);
}
ind++;
}
switch(int(random(5))){
case 0:{
std::println(std::cout,"Rhythm Galaxy gets bonus chart");
GetRandomChart(galaxies[0],0,1);
}break;
case 1:{
std::println(std::cout,"Technical Galaxy gets bonus chart");
GetRandomChart(galaxies[1],1,1);
}break;
case 2:{
std::println(std::cout,"Speed Galaxy gets bonus chart");
GetRandomChart(galaxies[2],2,1);
}break;
case 3:{
std::println(std::cout,"Chaos Galaxy gets bonus chart");
GetRandomChart(galaxies[3],3,1);
}break;
case 4:{
std::println(std::cout,"Endurance Galaxy gets bonus chart");
GetRandomChart(galaxies[4],4,1);
}break;
}
bossGalaxy.ClearPlanets();
for(int songsRequiredCounter:std::ranges::iota_view(0,6)){ //6 songs
GetRandomChart(bossGalaxy,5,0,DDREngine::bossLevel);
}
radar=std::make_unique<GrooveRadar>(*this,GetScreenSize()/2,40,4);
return true;
}
bool OnUserUpdate(float fElapsedTime) override
{
render.OnUserUpdate(*this);
if(GetKey(Key::SPACE).bPressed)render.AddPlanet(DDREngine::technicalCharts[0]);
if(state==ITG){
}else{
switch(state){
case RADAR:{
radar->Update(fElapsedTime);
int increment{1};
if(GetKey(Key::NP_SUB).bHeld)increment=-1;
if(GetKey(Key::NP5).bPressed)radar->vals[0]+=increment;
if(GetKey(Key::NP6).bPressed)radar->vals[1]+=increment;
if(GetKey(Key::NP3).bPressed)radar->vals[2]+=increment;
if(GetKey(Key::NP1).bPressed)radar->vals[3]+=increment;
if(GetKey(Key::NP4).bPressed)radar->vals[4]+=increment;
if(GetKey(Key::K1).bPressed){
Clear(BLANK);
state=RHYTHM;
}
if(GetKey(Key::K2).bPressed){
Clear(BLANK);
state=TECHNICAL;
}
if(GetKey(Key::K3).bPressed){
Clear(BLANK);
state=SPEED;
}
if(GetKey(Key::K4).bPressed){
Clear(BLANK);
state=CHAOS;
}
if(GetKey(Key::K5).bPressed){
Clear(BLANK);
state=ENDURANCE;
}
if(GetKey(Key::K6).bPressed){
Clear(BLANK);
state=BOSS;
}
}break;
case RHYTHM:{rhythmGalaxy.OnUserUpdate(*this);}break;
case TECHNICAL:{technicalGalaxy.OnUserUpdate(*this);}break;
case SPEED:{speedGalaxy.OnUserUpdate(*this);}break;
case CHAOS:{chaosGalaxy.OnUserUpdate(*this);}break;
case ENDURANCE:{enduranceGalaxy.OnUserUpdate(*this);}break;
case BOSS:{bossGalaxy.OnUserUpdate(*this);}break;
}
if(GetKey(Key::ESCAPE).bPressed)state=RADAR;
}
return true;
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"Game":"DDR",
"Name":"AMay",
"Difficulties":[15,16],
"Boss":19
"Difficulties":[10,12],
"Boss":18
}

View File

@ -0,0 +1,8 @@
1: 10^
2: 10v
3: 10^ on Fail
4: 10-
5: 5 + 10
6: 5 ++20