*/
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_GL_SetSwapInterval(0);
++ //SDL_GL_SetSwapInterval(0);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
**** GAMELOOP ****
**************************/
+ std::cout << "Num threads: " << std::thread::hardware_concurrency() << std::endl;
++
+ //currentWorld->mob.back()->followee = player;
+
gameRunning = true;
while(gameRunning){
mainLoop();
p->loc.y += p->vel.y * delta;
p->loc.x +=(p->vel.x * p->speed) * delta;
- /*
- * Update coordinates of all entities except for structures.
- */
-
- for(auto &e : entity){
+ // update entity coords
+ for ( auto &e : entity ) {
e->loc.y += e->vel.y * delta;
- if(e->type != STRUCTURET && e->canMove){
+ // dont let structures move?
+ if ( e->type != STRUCTURET && e->canMove ) {
e->loc.x += e->vel.x * delta;
- if(e->vel.x < 0)e->left = true;
- else if(e->vel.x > 0)e->left = false;
+ // update boolean directions
+ if ( e->vel.x < 0 )
+ e->left = true;
+ else if ( e->vel.x > 0 )
+ e->left = false;
}
}
-
+ // iterate through particles
+ particles.erase( std::remove_if( particles.begin(), particles.end(), [&delta](Particles &part){return part.kill(delta);}), particles.end());
+ for ( auto part = particles.begin(); part != particles.end(); part++ ) {
+ if ( (*part).canMove ) {
+ (*part).loc.y += (*part).vely * delta;
+ (*part).loc.x += (*part).velx * delta;
+
+ for ( auto &b : build ) {
+ if ( b->bsubtype == FOUNTAIN ) {
+ if ( (*part).loc.x >= b->loc.x && (*part).loc.x <= b->loc.x + b->width ) {
+ if ( (*part).loc.y <= b->loc.y + b->height * .25)
+ particles.erase( part );
+
- for(unsigned int i=0;i<particles.size();i++){
- if(particles[i]->kill(delta)){
- delete particles[i];
- particles.erase(particles.begin()+i);
- }else if(particles[i]->canMove){
- particles[i]->loc.y += particles[i]->vely * delta;
- particles[i]->loc.x += particles[i]->velx * delta;
-
- for(auto &b : build){
- if(b->bsubtype==FOUNTAIN){
- if(particles[i]->loc.x >= b->loc.x && particles[i]->loc.x <= b->loc.x + b->width){
- if(particles[i]->loc.y <= b->loc.y + b->height * .25){
- delete particles[i];
- particles.erase(particles.begin()+i);
- }
}
}
}
}
return tmp;
- }
++
+ }
+
+ Village::Village(const char *meme, World *w){
+ name = meme;
+ start.x = w->getTheWidth() / 2.0f;
+ end.x = -start.x;
+ in = false;
+ }