|
@@ -66,12 +66,14 @@ int main(int argc,char** argv)
|
|
|
int level=1; //difficulty level
|
|
|
//bool sound=false;
|
|
|
|
|
|
- /*//PTHREAD STUFF
|
|
|
+ //PTHREAD STUFF
|
|
|
pthread_t thread[THREADS_NUM];
|
|
|
int bkgd_music; //#0
|
|
|
int enshoot_sound; //#1
|
|
|
int win_theme; //#2
|
|
|
- int lose_theme; //#3
|
|
|
+ /* This is not used
|
|
|
+ * int lose_theme; //#3
|
|
|
+ */
|
|
|
int shoot_sound; //#4
|
|
|
|
|
|
if(argc>1){ //./invaders -m/m/mute -> the game starts with no sounds.
|
|
@@ -121,8 +123,8 @@ int main(int argc,char** argv)
|
|
|
|
|
|
/////////ENTERING MAIN LOOP
|
|
|
|
|
|
- /*if(sound)
|
|
|
- bkgd_music = pthread_create(&thread[0],NULL,pmusic,NULL); //executing background music in parallel thread*/
|
|
|
+ if(sound)
|
|
|
+ bkgd_music = pthread_create(&thread[0],NULL,pmusic,NULL); //executing background music in parallel thread
|
|
|
|
|
|
if(argc>1){
|
|
|
if(strcmp(argv[1],"--uber-debug")==0){ player1.weaponclass=5; player1.weaponclassrkt=5; player1.rocketlauncher=true; player1.length=MAX_LENGTH; }
|
|
@@ -140,7 +142,7 @@ int main(int argc,char** argv)
|
|
|
|
|
|
if(command == commands[8]){ //q = exit game
|
|
|
endwin();
|
|
|
- //pkill_music(thread[0]);
|
|
|
+ pkill_music(thread[0]);
|
|
|
cout<<lightgreen<<"Game exited correctly."<<none<<endl;
|
|
|
return 1;
|
|
|
}
|
|
@@ -164,16 +166,16 @@ int main(int argc,char** argv)
|
|
|
}
|
|
|
|
|
|
if(command==commands[5] || command==commands[6]){ //spacebar = shoot!
|
|
|
- //if(sound) shoot_sound = pthread_create(&thread[4],NULL,pshoot_sound,NULL);
|
|
|
+ if(sound) shoot_sound = pthread_create(&thread[4],NULL,pshoot_sound,NULL);
|
|
|
player1.shoot(bullets);
|
|
|
if(player1.rocketlauncher) player1.shootrkt(rockets);
|
|
|
}
|
|
|
|
|
|
- /*if(command==commands[7]){ //mute/unmute
|
|
|
+ if(command==commands[7]){ //mute/unmute
|
|
|
if(sound) pkill_music(thread[0]);
|
|
|
else bkgd_music = pthread_create(&thread[0],NULL,pmusic,NULL);
|
|
|
sound=!sound;
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
if(enemyalive(enemies)) //if there's at least one enemy alive:
|
|
|
{
|
|
@@ -188,7 +190,7 @@ int main(int argc,char** argv)
|
|
|
//mvaddch(it->y,it->x,' ');
|
|
|
it->next_pos(); //evaluate new positions
|
|
|
if(it->alive && (double)rand()/RAND_MAX<(shootrate*enemy_num/n_enemies)){ //try a bomb-dropping
|
|
|
- //if(sound) shoot_sound = pthread_create(&thread[1],NULL,penshoot_sound,NULL);
|
|
|
+ if(sound) enshoot_sound = pthread_create(&thread[1],NULL,penshoot_sound,NULL);
|
|
|
it->shoot(bombs);
|
|
|
}
|
|
|
}
|
|
@@ -204,7 +206,7 @@ int main(int argc,char** argv)
|
|
|
}
|
|
|
boss1.next_pos();
|
|
|
if((double)rand()/RAND_MAX<shootrate*25.){ //boss's shootrate is 25 times the one of normal enemies
|
|
|
- //if(sound) shoot_sound = pthread_create(&thread[1],NULL,penshoot_sound,NULL);
|
|
|
+ if(sound) enshoot_sound = pthread_create(&thread[1],NULL,penshoot_sound,NULL);
|
|
|
boss1.shoot(bombs);
|
|
|
}
|
|
|
}
|
|
@@ -247,10 +249,10 @@ int main(int argc,char** argv)
|
|
|
///////ENDGAME CHECKS
|
|
|
if(boss1.health<1 || gameover(player1,bombs))
|
|
|
{
|
|
|
- /*if(sound){
|
|
|
+ if(sound){
|
|
|
pkill_music(thread[0]);
|
|
|
win_theme = pthread_create(&thread[2],NULL,pwin_theme,NULL);
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
WINDOW *replay;
|
|
|
if(boss1.health<1) // YOU WON
|