void testplay() { int i,j,c; players=2; srand(time(0)); generatenewgame(); testprintnewgame(); for(i=0;i<players;i++) { resetplayer(i); c=getcardid("copper"); if(c<0) error("testplay: couldn't find copper.\n"); for(j=0;j<7;j++) gaincard(i,c); c=getcardid("estate"); if(c<0) error("testplay: couldn't find estate.\n"); for(j=0;j<3;j++) gaincard(i,c); } currentplayer=0; playgame(); }
void updatebombs(){ int i,j; for(i=0;i<20;i++){ if(bomb[i].alive){ int dieatlast=0; bomb[i].x=bomb[i].x+bomb[i].velx; bomb[i].y-=bomb[i].jumpfactor/10; bomb[i].jumpfactor--; if(bomb[i].x<(mapxoff-WIDTH) || bomb[i].x>mapxoff+WIDTH || bomb[i].y<mapyoff || bomb[i].y>mapyoff+HEIGHT){ bomb[i].alive=0; } else if(bomb[i].y>mapblockheight*mapheight-30) bomb[i].alive=0; if( bomb[i].x-mapxoff>0 && (bomb[i].x-mapxoff)<(WIDTH-bomb[i].width)) bomb[i].draw(); if(bomb[i].jumpfactor<0){ if(collided(bomb[i].x+bomb[i].width/2,bomb[i].y+bomb[i].height)) { bomb[i].jump=false; while(collided(bomb[i].x+bomb[i].width/2,bomb[i].y+bomb[i].height)) bomb[i].y-=2; if(i<10){ for(int k=0;k<20;k++){ if(bulldogs[k].alive && bulldogs[k].hitpoints>0){ if(met(bulldogs[k].x,bulldogs[k].y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,bulldogs[k].width,BOMBRADIUS*2,bulldogs[k].height,BOMBRADIUS*2)){ scores+=500; bulldogs[k].hitpoints-=bomb[i].damagept; if((bulldogs[k].hitpoints)<=0){ bulldogs[k].type2=REBELDYING; bulldogs[k].totalframes=REBELMAX[REBELDYING]; bulldogs[k].curframe=0; bulldogs[k].velx=0; bulldogs[k].jump=false; } } } if(k>=MAXBOMBERS) continue; if(bombman[k].alive && bombman[k].hitpoints>0){ if(met(bombman[k].x,bombman[k].y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,bombman[k].width,BOMBRADIUS*2,bombman[k].height,BOMBRADIUS*2)){ scores+=1000; bombman[k].hitpoints-=bomb[i].damagept; if((bombman[k].hitpoints)<=0){ bombman[k].type2=REBELDYING; bombman[k].totalframes=REBELMAX[REBELDYING]; bombman[k].curframe=0; bombman[k].velx=0; bombman[k].jump=false; } } } } //bomb[i].alive=0; } if(i>=10 && inputflag){ if(met(tarma.x,tarma.y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,tarma.width,BOMBRADIUS*2,tarma.height,BOMBRADIUS*2)){ tarma.hitpoints-=bomb[i].damagept; if(tarma.hitpoints<=0) resetplayer(); bomb[i].alive=0; } } bomb[i].alive=0; } } if(!bomb[i].alive) continue; for(j=0;j<20;j++){ if(bulldogs[j].alive &&i<10 && bulldogs[j].hitpoints>0){ if(met(bulldogs[j].x,bulldogs[j].y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,bulldogs[j].width,BOMBRADIUS*2,bulldogs[j].height,BOMBRADIUS*2)){ dieatlast=1; scores+=500; bulldogs[j].hitpoints-=bomb[i].damagept; if((bulldogs[j].hitpoints)<=0){ bulldogs[j].type2=REBELDYING; bulldogs[j].totalframes=REBELMAX[REBELDYING]; bulldogs[j].curframe=0; bulldogs[j].velx=0; bulldogs[j].jump=false; } } } if(j>=MAXBOMBERS) continue; if(bombman[j].alive &&i<10 && bombman[j].hitpoints>0){ if(met(bombman[j].x,bombman[j].y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,bombman[j].width,BOMBRADIUS*2,bombman[j].height,BOMBRADIUS*2)){ dieatlast=1; scores+=1000; bombman[j].hitpoints-=bomb[i].damagept; if((bombman[j].hitpoints)<=0){ bombman[j].type2=REBELDYING; bombman[j].totalframes=REBELMAX[REBELDYING]; bombman[j].curframe=0; bombman[j].velx=0; bombman[j].jump=false; } } } } if(dieatlast) bomb[i].alive=0; if(!bomb[i].alive) continue; if(i>=10 && inputflag){ if(met(tarma.x,tarma.y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,tarma.width,BOMBRADIUS*2,tarma.height,BOMBRADIUS*2)){ tarma.hitpoints-=bomb[i].damagept; if(tarma.hitpoints<=0) resetplayer(); bomb[i].alive=0; } } } } }
void updatebullets(){ int i,j; for(i=0;i<50;i++){ if(pistols[i].alive){ pistols[i].x=pistols[i].x+pistols[i].velx; pistols[i].y=pistols[i].y+pistols[i].vely; if(pistols[i].x<(mapxoff-WIDTH) || pistols[i].x>mapxoff+WIDTH || pistols[i].y<mapyoff || pistols[i].y>mapyoff+HEIGHT){ pistols[i].alive=0; continue; } else if( pistols[i].x-mapxoff>0 && pistols[i].x-mapxoff<WIDTH) pistols[i].draw(); for(j=0;j<20;j++){ if(bulldogs[j].alive &&i<25 && bulldogs[j].hitpoints>0){ if(met(pistols[i].x,pistols[i].y,bulldogs[j].x,bulldogs[j].y,pistols[i].width,bulldogs[j].width,pistols[i].height,bulldogs[j].height)){ pistols[i].alive=0; scores+=100; bulldogs[j].hitpoints--; if((bulldogs[j].hitpoints)<=0){ bulldogs[j].type2=REBELDYING; bulldogs[j].totalframes=REBELMAX[REBELDYING]; bulldogs[j].curframe=0; bulldogs[j].velx=0; bulldogs[j].jump=false; } break; } } if(j>=MAXBOMBERS) continue; if(bombman[j].alive &&i<25 && bombman[j].hitpoints>0){ if(met(pistols[i].x,pistols[i].y,bombman[j].x,bombman[j].y,bombman[i].width,bombman[j].width,bombman[i].height,bombman[j].height)){ pistols[i].alive=0; scores+=500; bombman[j].hitpoints--; if((bombman[j].hitpoints)<=0){ bombman[j].type2=REBELDYING; bombman[j].totalframes=REBELMAX[REBELDYING]; bombman[j].curframe=0; bombman[j].velx=0; bombman[j].jump=false; } break; } } } if(!pistols[i].alive) continue; if(i>25 && inputflag){ if(met(pistols[i].x,pistols[i].y,tarma.x,tarma.y,pistols[i].width,tarma.width,pistols[i].height,tarma.height)){ scores-=100; tarma.hitpoints--; if(!tarma.hitpoints) resetplayer(); pistols[i].alive=0; } } } } }
void updatehero(){ tarma.animate(); if(tarma.crouch) tarma.height=35; else tarma.height=70; if(tarma.jump==false){ if(!collided(tarma.x+tarma.width/2,tarma.y+tarma.height+5)){ tarma.jump=true; tarma.jumpfactor=-1; } } if(tarma.jump) { tarma.lasty=tarma.y; tarma.y -= tarma.jumpfactor/5; if(tarma.y<20){ tarma.y=20; } tarma.jumpfactor--; } if(tarma.jumpfactor<0){ if(collided(tarma.x+tarma.width/2,tarma.y+tarma.height)) { tarma.jump=false; lastjump=mils; while(collided(tarma.x+tarma.width/2,tarma.y+tarma.height)) tarma.y-=2; } } if(tarma.facing==LEFT){ if(collided(tarma.x,tarma.y+tarma.height)){ tarma.x=tarma.lastx; } } if(tarma.facing==RIGHT){ if(collided(tarma.x+tarma.width,tarma.y+tarma.height)){ tarma.x=tarma.lastx; } } for(int i=0;i<20;i++){ if(bulldogs[i].alive){ if(met(tarma.x,tarma.y,bulldogs[i].x,bulldogs[i].y,tarma.width,bulldogs[i].width,tarma.height,bulldogs[i].height)){ tarma.x=tarma.lastx; } } if(i>=MAXBOMBERS) continue; if(bombman[i].alive){ if(met(tarma.x,tarma.y,bombman[i].x,bombman[i].y,tarma.width,bombman[i].width,tarma.height,bombman[i].height)){ tarma.x=tarma.lastx; } } } if(tarma.y>(mapheight*mapblockheight-tarma.height-50) ){ resetplayer(); if(gameover) return; } if(tarma.x<5) tarma.x=5; mapxoff=tarma.x+tarma.width/2-WIDTH/2+10; mapyoff=tarma.y+tarma.height/2-HEIGHT/2+10; if(mapxoff<0) mapxoff=0; if(mapxoff>mapwidth*mapblockwidth-WIDTH) mapxoff=mapwidth*mapblockwidth-WIDTH; if(mapyoff<0) mapyoff=0; if(mapyoff>mapheight*mapblockheight-HEIGHT) mapyoff=mapheight*mapblockheight-HEIGHT; MapDrawBG(buffer,mapxoff,mapyoff,0,0,WIDTH-1,HEIGHT-1); MapDrawFG(buffer,mapxoff,mapyoff,0,0,WIDTH-1,HEIGHT-1,0); tarma.draw(); }