|
|
@ -10,6 +10,7 @@ vi2d lowerRightCoords={500,0}; |
|
|
|
std::vector<std::vector<char>>board; |
|
|
|
std::vector<std::vector<char>>board; |
|
|
|
int sum=0; |
|
|
|
int sum=0; |
|
|
|
float timePerTick=0.03; |
|
|
|
float timePerTick=0.03; |
|
|
|
|
|
|
|
int frameSkips=0; |
|
|
|
float acc=0; |
|
|
|
float acc=0; |
|
|
|
float acc2=0; |
|
|
|
float acc2=0; |
|
|
|
vi2d sandCoord={500,0}; |
|
|
|
vi2d sandCoord={500,0}; |
|
|
@ -126,7 +127,10 @@ public: |
|
|
|
acc2+=fElapsedTime; |
|
|
|
acc2+=fElapsedTime; |
|
|
|
if (acc>=timePerTick){ |
|
|
|
if (acc>=timePerTick){ |
|
|
|
acc-=timePerTick; |
|
|
|
acc-=timePerTick; |
|
|
|
updateGame(); |
|
|
|
int framesToSkip=frameSkips; |
|
|
|
|
|
|
|
while (framesToSkip-->0){ |
|
|
|
|
|
|
|
updateGame(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (acc2>=0.01){ |
|
|
|
if (acc2>=0.01){ |
|
|
|
if (GetKey(RIGHT).bHeld){ |
|
|
|
if (GetKey(RIGHT).bHeld){ |
|
|
@ -143,6 +147,12 @@ public: |
|
|
|
if (GetKey(D).bHeld){ |
|
|
|
if (GetKey(D).bHeld){ |
|
|
|
viewX+=60*fElapsedTime; |
|
|
|
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){ |
|
|
|
if (GetKey(SPACE).bPressed){ |
|
|
|
showVisual=!showVisual; |
|
|
|
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}); |
|
|
|
DrawStringDecal({0,(float)(ScreenHeight()-GetTextSize("S").y*0.4)},"Sand Pieces: "+std::to_string(sum),WHITE,{0.4,0.4}); |
|
|
|
if (showVisual) { |
|
|
|
if (showVisual) { |
|
|
|
// called once per frame
|
|
|
|
// 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++){ |
|
|
|
for (int y = upperLeftCoords.y; y <= lowerRightCoords.y; y++){ |
|
|
|
vi2d coords=getArrayCoords({x,y}); |
|
|
|
vi2d coords=getArrayCoords({x,y}); |
|
|
|
if (x==sandCoord.x&&y==sandCoord.y){ |
|
|
|
if (x==sandCoord.x&&y==sandCoord.y){ |
|
|
@ -175,7 +185,7 @@ public: |
|
|
|
int main() |
|
|
|
int main() |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::vector<Connection>connections; |
|
|
|
std::vector<Connection>connections; |
|
|
|
std::ifstream file("testinput"); |
|
|
|
std::ifstream file("input"); |
|
|
|
ReadState state=READX; |
|
|
|
ReadState state=READX; |
|
|
|
while (file.good()){ |
|
|
|
while (file.good()){ |
|
|
|
std::string line; |
|
|
|
std::string line; |
|
|
|