diff options
Diffstat (limited to 'World.cpp')
| -rw-r--r-- | World.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
@@ -7,6 +7,7 @@ World::World(int l):level(l) level--; next_level(); reset(); + next_stone=2; } void World::reset() @@ -17,6 +18,7 @@ void World::reset() player.x2=player.x=0; player.speed=level; + player.speed=0; player.anim=0; player.y=bricks[0][0].altitude+1; player.y2=0; @@ -187,7 +189,7 @@ void World::sim(double time) return; } -// player.speed--; + player.speed--; } @@ -201,6 +203,10 @@ void World::sim(double time) void World::mouseclick(int x, int y) { + std::random_device rd; //Will be used to obtain a seed for the random number engine + std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd() + std::uniform_int_distribution<> dis(2, 4); + if(player.dead){reset();return;} if(player.win){next_level();return;} if(x<0||x>=bricks.size())return; @@ -217,6 +223,36 @@ void World::mouseclick(int x, int y) } if(brick.type>1&&brick.altitude==y) { + // brick.type++; + // if(brick.type>=5) + // { + bricks[x].erase(bricks[x].begin()+idx); + // } + // return; + } + idx++; + + + } + bricks[x].push_back({y,next_stone}); + next_stone=dis(gen); + player.speed++; + return; + + if(x<0||x>=bricks.size())return; + idx=0; + for(Brick &brick:bricks[x]) + { + if(brick.type==0&&brick.altitude>=y) + { + return; + } + if(brick.type<=1&&brick.altitude==y) + { + return; + } + if(brick.type>1&&brick.altitude==y) + { brick.type++; if(brick.type>=5) { @@ -229,6 +265,6 @@ void World::mouseclick(int x, int y) } bricks[x].push_back({y,2}); -// player.speed++; + player.speed++; } |
