diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 911bdbd..4c1b2a2 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 714fae4..1d68481 100644 --- a/main.cpp +++ b/main.cpp @@ -10,6 +10,7 @@ vi2d lowerRightCoords={500,0}; std::vector>board; int sum=0; float timePerTick=0.03; +int frameSkips=0; float acc=0; float acc2=0; vi2d sandCoord={500,0}; @@ -126,7 +127,10 @@ public: acc2+=fElapsedTime; if (acc>=timePerTick){ acc-=timePerTick; - updateGame(); + int framesToSkip=frameSkips; + while (framesToSkip-->0){ + updateGame(); + } } if (acc2>=0.01){ if (GetKey(RIGHT).bHeld){ @@ -143,6 +147,12 @@ public: if (GetKey(D).bHeld){ viewX+=60*fElapsedTime; } + if (GetKey(W).bHeld){ + frameSkips=std::clamp(frameSkips+1,0,1000); + } + if (GetKey(S).bHeld){ + frameSkips=std::clamp(frameSkips-1,0,1000); + } } if (GetKey(SPACE).bPressed){ showVisual=!showVisual; @@ -154,7 +164,7 @@ public: DrawStringDecal({0,(float)(ScreenHeight()-GetTextSize("S").y*0.4)},"Sand Pieces: "+std::to_string(sum),WHITE,{0.4,0.4}); if (showVisual) { // called once per frame - for (int x = upperLeftCoords.x; x <= lowerRightCoords.x; x++){ + for (int x = std::max(0,(int)(upperLeftCoords.x-viewX)); x <= std::min(lowerRightCoords.x,(int)(upperLeftCoords.x-viewX+ScreenWidth())); x++){ for (int y = upperLeftCoords.y; y <= lowerRightCoords.y; y++){ vi2d coords=getArrayCoords({x,y}); if (x==sandCoord.x&&y==sandCoord.y){ @@ -175,7 +185,7 @@ public: int main() { std::vectorconnections; - std::ifstream file("testinput"); + std::ifstream file("input"); ReadState state=READX; while (file.good()){ std::string line;