Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent cc45154afa
commit 0788e569e3
  1. BIN
      C++ProjectTemplate
  2. 16
      main.cpp

Binary file not shown.

@ -10,6 +10,7 @@ vi2d lowerRightCoords={500,0};
std::vector<std::vector<char>>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::vector<Connection>connections;
std::ifstream file("testinput");
std::ifstream file("input");
ReadState state=READX;
while (file.good()){
std::string line;

Loading…
Cancel
Save