int main(int argc, const char* argv[]) { msgType mdialogok = MSGDIALOG_NORMAL | MSGDIALOG_BUTTON_TYPE_OK; msgType mdialogyesno = MSGDIALOG_NORMAL | MSGDIALOG_BUTTON_TYPE_YESNO; sysRegisterCallback(EVENT_SLOT0, handleevent, NULL); init_screen(); ioPadInit(7); waitFlip(); Lv2FsStat entry; int is_mounted = lv2FsStat(MOUNT_POINT, &entry); showmessage(mdialogyesno, (is_mounted == 0) ? "Do you want to unmount dev_rwflash ?" : "Do you want to mount dev_rwflash ?"); if(dlg_action == MSGDIALOG_BUTTON_YES) { if(is_mounted == 0) showmessage(mdialogok, (lv2FsUnmount(MOUNT_POINT) == 0) ? "Successfully unmounted dev_rwflash." : "An error occured while unmounting dev_rwflash."); else showmessage(mdialogok, (lv2FsMount(DEV_FLASH1, FS_FAT32, MOUNT_POINT, 0) == 0) ? "Successfully mounted dev_rwflash." : "An error occured while mounting dev_rwflash."); } return 0; }
void winwarn(pdfapp_t *app, char *msg) { char buf[1024]; snprintf(buf, sizeof buf, "warning: %s", msg); showmessage(app, 10, buf); fprintf(stderr, "mupdf: %s\n", buf); }
content2::content2(QString ip,QString port,int pp, QWidget *parent) : QWidget(parent),ip_(ip),port_(port) { QPalette palette; palette.setBrush(QPalette::Window,QBrush(QColor(250,255,240,150))); setPalette(palette); setAutoFillBackground(true); button = new QPushButton(this); button->setText("开始录制"); button->setCheckable(true); connect(button,SIGNAL(toggled(bool)),this,SLOT(button_text(bool))); button2 = new QPushButton(this); button2->setText("屏幕截图"); picture = new pic_show(this,ip,port); button->move( width()-10-button->width(),10 ); connect(picture,SIGNAL(showmessage(QString)),this,SIGNAL(showmess(QString))); connect(button2,SIGNAL(clicked()),picture,SLOT(capture())); }
void game::start() { float FPS=40; SDL_Rect tmprect_surprises,tmprect_surprises2; int moneymove=0; Uint32 start; loadmap("map2.map"); while(running) { start=SDL_GetTicks(); handelevents(); //logic if(direction[0]) { player1->setDirection('l'); if(player1->getRect()->x>80) //it was x>0 player1->setXvel(-1); else{ camera.x--; baseclass::coord.x--; player1->setXvel(0); } if(camera.x<0) camera.x=6400-screen_width; //player1->set // std::cout<<"la position de coord - est :"<<coord.x<<"la position de camera est :"<<camera.x<<std::endl; } else if(direction[1]) { player1->setDirection('r'); if(player1->getRect()->x <80) player1->setXvel(1); else{ player1->setXvel(0); camera.x++; baseclass::coord.x++; } if(camera.x>=6400-screen_width) camera.x=0; // std::cout<<"la position de coord + est :"<<coord.x<<"la position de camera est :"<<camera.x<<std::endl; } else player1->setXvel(0); int start2=(baseclass::coord.x-(baseclass::coord.x%baseclass::tile_size))/baseclass::tile_size; int end2=(baseclass::coord.x+baseclass::coord.w+(baseclass::tile_size-(baseclass::coord.x+baseclass::coord.w)%baseclass::tile_size))/baseclass::tile_size; if(start2<0) start2=0; if(end2>map1[0].size()) end2=map1[0].size(); bool nocollision=0; for (int i=0;i<map1.size();i++) { for (int j=start2;j<end2;j++) { if( map1[i][j]==0) continue; SDL_Rect dest_rect={j*30-baseclass::coord.x,i*30,30,30}; for (int g=0;g<bullets.size();g++) { if(collision(bullets[g]->getRect(),&dest_rect)) { b1->setFrame(1); // b1->setX(bullets[g]->getRect()->x+20); if(player1->getDirection()=='r') b1->setX(j*30-14); else b1->setX(j*30+24); b1->setY(bullets[g]->getRect()->y); delete bullets[g]; bullets.erase(bullets.begin()+g); } } for (int j=0;j<Champignons.size();j++) { SDL_Rect tmprect ={Champignons[j]->getRect()->x-baseclass::coord.x,Champignons[j]->getRect()->y,30,30}; for (int k=0;k<Champignons.size();k++) { if(k!=j){ SDL_Rect tmprect2 ={Champignons[k]->getRect()->x-baseclass::coord.x,Champignons[k]->getRect()->y,30,30}; if (collision(&tmprect,&tmprect2)) { Champignons[j]->setxvel(1); Champignons[j]->setdirection('r'); Champignons[k]->setxvel(-1); Champignons[k]->setdirection('l'); std::cout<<"here is collision between two enemies "<<std::endl; } } } } for (int j=0;j<Champignons.size();j++) { SDL_Rect tmprect ={Champignons[j]->getRect()->x-baseclass::coord.x,Champignons[j]->getRect()->y,30,30}; for (int k=0;k<Tortues.size();k++) { SDL_Rect tmprect2 ={Tortues[k]->getRect()->x-baseclass::coord.x,Tortues[k]->getRect()->y,30,30}; if ((tmprect.x+30==tmprect2.x)&&(Tortues[k]->getetat()==2)&&(Champignons[j]->getPuissance()==1)) { Champignons[j]->setxvel(-1); Champignons[j]->setdirection('r'); Tortues[k]->setxvel(1); Tortues[k]->setdirection('l'); }else if ((tmprect.x==tmprect2.x+30)&&(Tortues[k]->getetat()==2)&&(Champignons[j]->getPuissance()==1)) { Champignons[j]->setxvel(1); Champignons[j]->setdirection('r'); Tortues[k]->setxvel(-1); Tortues[k]->setdirection('l'); }else if ((tmprect.x==tmprect2.x+30)&&(Tortues[k]->getetat()==1)&&(Champignons[j]->getPuissance()==1)) { delete Champignons[j]; Champignons.erase(Champignons.begin()+j); } else if ((tmprect.x+30==tmprect2.x)&&(Tortues[k]->getetat()==1)&&(Champignons[j]->getPuissance()==1)) { delete Champignons[j]; Champignons.erase(Champignons.begin()+j); } } } for (int j=0;j<Tortues.size();j++) { SDL_Rect tmprect ={Tortues[j]->getRect()->x-baseclass::coord.x,Tortues[j]->getRect()->y,30,30}; for (int k=0;k<Tortues.size();k++) { if(k!=j){ SDL_Rect tmprect2 ={Tortues[k]->getRect()->x-baseclass::coord.x,Tortues[k]->getRect()->y,30,30}; if ((collision(&tmprect,&tmprect2))&&(Tortues[j]->getetat()!=1)&&(Tortues[k]->getetat()!=1)) { Tortues[j]->setxvel(1); Tortues[j]->setdirection('r'); Tortues[k]->setxvel(-1); Tortues[k]->setdirection('l'); std::cout<<"here is collision between two tortues "<<std::endl; } if (collision(&tmprect,&tmprect2)&&Tortues[j]->getetat()==1) { delete Tortues[k]; Tortues[j]->setxvel(5); Tortues.erase(Tortues.begin()+k); } } } } } } for (int i=0;i<bullets.size();i++) { if((bullets[i]->getRect()->x >= screen->w)||(bullets[i]->getRect()->x <=0)) { delete bullets[i]; bullets.erase(bullets.begin()+i); } } for (int i=0;i<bullets.size();i++) { for (int j=0;j<Champignons.size();j++) { SDL_Rect tmprect ={Champignons[j]->getRect()->x-baseclass::coord.x,Champignons[j]->getRect()->y,30,30}; if(collision(&tmprect,bullets[i]->getRect())) { b1->setFrame(1); b1->setX(Champignons[j]->getRect()->x); b1->setY(Champignons[j]->getRect()->y); delete bullets[i]; delete Champignons[j]; bullets.erase(bullets.begin()+i); Champignons.erase(Champignons.begin()+j); } } for (int j=0;j<Tortues.size();j++) { SDL_Rect tmprect ={Tortues[j]->getRect()->x-baseclass::coord.x,Tortues[j]->getRect()->y,30,30}; if(collision(&tmprect,bullets[i]->getRect())) { b1->setFrame(1); b1->setX(Tortues[j]->getRect()->x); b1->setY(Tortues[j]->getRect()->y); delete bullets[i]; delete Tortues[j]; bullets.erase(bullets.begin()+i); Tortues.erase(Tortues.begin()+j); } } } for (int i=0;i<bullets.size();i++) { for (int j=0;j<fleur_toxiques.size();j++) { SDL_Rect tmprect ={fleur_toxiques[j]->getRect()->x-baseclass::coord.x,fleur_toxiques[j]->getRect()->y,30,30}; if(collision(&tmprect,bullets[i]->getRect())) { b1->setFrame(1); b1->setX(fleur_toxiques[j]->getRect()->x); b1->setY(tmprect.y); delete bullets[i]; delete fleur_toxiques[j]; bullets.erase(bullets.begin()+i); fleur_toxiques.erase(fleur_toxiques.begin()+j); } } } for (int j=0;j<Champignons.size();j++) { int set_life_power=0; SDL_Rect tmprect ={Champignons[j]->getRect()->x-baseclass::coord.x,Champignons[j]->getRect()->y,30,30}; if(collision(&baseclass::coord,Champignons[j]->getRect())) { if(collision(&tmprect,player1->getRect())) { std::cout<<"collesion enemy yvel "<<tmprect.y<< "pleyer y vel "<<player1->getRect()->y<<std::endl; if((player1->getRect()->y< tmprect.y )&&(Champignons[j]->getPuissance()>0)) { Champignons[j]->setpuissance(0); std::cout<<"collesion enemy yvel "<<Champignons[j]->getFrame()<<std::endl; // delete Champignons[j]; // Champignons.erase(Champignons.begin()+j); } else if((player1->getRect()->y==tmprect.y )&&(set_life_power>=0)&&(Champignons[j]->getPuissance()>0)) { player1->setHealth(-1); //std::cout<<"enemy killl me et mon lhealth est :"<<player1->getHealth(); delete Champignons[j];//version before i was neot here Champignons.erase(Champignons.begin()+j); //version before i was neot here } } if((player1->getRect()->x> tmprect.x+60||player1->getRect()->x < tmprect.x-60)&&(Champignons[j]->getPuissance()==0)) { delete Champignons[j];//version before i was neot here Champignons.erase(Champignons.begin()+j); //version before i was neot here } Champignons[j]->move(map1); } } for (int j=0;j<Tortues.size();j++) { bool setEtat =false; SDL_Rect tmprect ={Tortues[j]->getRect()->x-baseclass::coord.x,Tortues[j]->getRect()->y,30,30}; if(collision(&baseclass::coord,Tortues[j]->getRect())) { if(collision(&tmprect,player1->getRect())) { std::cout<<"collesion enemy yvel "<<tmprect.y<< "pleyer y vel "<<player1->getRect()->y<<std::endl; if((player1->getRect()->y< tmprect.y )&&(Tortues[j]->getetat()==2)) { Tortues[j]->setetat(1); // delete Tortues[j]; // Tortues.erase(Tortues.begin()+j); } else if((player1->getRect()->y== tmprect.y )&&(Tortues[j]->getetat()==2)) { player1->setHealth(-1); //std::cout<<"enemy killl me et mon lhealth est :"<<player1->getHealth(); delete Tortues[j];//version before i was neot here Tortues.erase(Tortues.begin()+j); //version before i was neot here } } Tortues[j]->move(map1); } } for (int i=0;i<moneis.size();i++) { SDL_Rect tmprect ={moneis[i]->getRect()->x-baseclass::coord.x,moneis[i]->getRect()->y,30,30}; if(collision(&tmprect,player1->getRect())) { delete moneis[i];//version before i was neot here moneis.erase(moneis.begin()+i); //version before i was neot here player1->setmoney(1); if (player1->getmoney()==100) { player1->setmoney(0); player1->setHealth(1); } } } for (int i=0;i<surprises.size();i++) { tmprect_surprises ={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30}; if((player1->getRect()->x+15>=tmprect_surprises.x)&&(player1->getRect()->x<=tmprect_surprises.x+20)&&(player1->getRect()->y==tmprect_surprises.y+40)) { moneymove=1; tmprect_surprises2={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30}; std::cout<<"player get y"<<player1->getRect()->y<<std::endl; if (player1->getmoney()==100) { } } } for (int i=0;i<fleur_ames.size();i++) { SDL_Rect tmprect ={fleur_ames[i]->getRect()->x-baseclass::coord.x,fleur_ames[i]->getRect()->y,30,30}; if(collision(player1->getRect(),&tmprect)) { delete fleur_ames[i]; fleur_ames.erase(fleur_ames.begin()+i); player1->setpower(1); } } for (int i=0;i<fleur_toxiques.size();i++) { SDL_Rect tmprect ={fleur_toxiques[i]->getRect()->x-baseclass::coord.x,fleur_toxiques[i]->getRect()->y,30,30}; if(collision(player1->getRect(),&tmprect)&&fleur_toxiques[i]->getmouvement()==true) { player1->setpower(-1); } } if (moneymove>0 && moneymove<30) { moneymove++; for (int i=0;i<surprises.size();i++) { tmprect_surprises ={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30}; if (tmprect_surprises.x==tmprect_surprises2.x&& surprises[i]->getmovement()==false) { if (i!=2&&moneymove==5) { monies_surp.push_back(new money(mon2,surprises[i]->getRect()->x,tmprect_surprises.y-60,-1,0)); //because every tile is TILE_SIZE width and height, we can calculate } surprises[i]->setY(-1); } } } if (moneymove>=30 && moneymove<=59) { moneymove++; for (int i=0;i<surprises.size();i++) { tmprect_surprises ={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30}; if (tmprect_surprises.x==tmprect_surprises2.x&& surprises[i]->getmovement()==false) { if (i==2&&moneymove==31) { fleur_ames.push_back(new fleur_ame(fleur_am1,surprises[i]->getRect()->x-1,tmprect_surprises.y,10,0)); //because every tile is TILE_SIZE width and height, we can calculate } surprises[i]->setY(1); } } } for (int i=0;i<monies_surp.size();i++) { if (monies_surp[i]->getFrame()>1.5) { delete monies_surp[i]; monies_surp.erase(monies_surp.begin()+i); player1->setmoney(1); if (player1->getmoney()>100) { player1->setHealth(1); player1->setmoney(0); } } } if (moneymove==59) { for (int i=0;i<surprises.size();i++) { tmprect_surprises ={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30}; if (tmprect_surprises.x==tmprect_surprises2.x&& surprises[i]->getmovement()==false){ surprises[i]->setmovement(true); surprises[i]->setFrame(3); player1->setpower(1); } } } /*for (int i=0;i<surprises.size();i++) {*/ //tmprect_surprises ={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30}; // } //surprises[i]->setmovement(true); for (int i=0;i<bullets.size();i++) { bullets[i]->setangle(20); bullets[i]->move(); } player1->move(map1); if(1000/FPS>SDL_GetTicks()-start) { SDL_Delay(1000/FPS-(SDL_GetTicks()-start)); } time++; if(time>15) { time=0; temps2--; } //render SDL_BlitSurface(background,&camera,screen,NULL); b1->show2(screen); relatifdetails("Mario Bross World 1 "); currenttime(); showmap(); player1->showplayer(screen); // playe->show2(screen); // su->show(screen); for (int i=0;i<bullets.size();i++) { bullets[i]->show("bullet2.bmp",screen); } for (int i=0;i<surprises.size();i++) { surprises[i]->show(screen); } for (int i=0;i<fleur_toxiques.size();i++) { fleur_toxiques[i]->show(screen); } for (int i=0;i<fleur_ames.size();i++) { fleur_ames[i]->show(screen); } for (int i=0;i<moneis.size();i++) { moneis[i]->show(screen); } for (int i=0;i<monies_surp.size();i++) { monies_surp[i]->show2(screen); } for (int i=0;i<Champignons.size();i++) { Champignons[i]->show(screen); } for (int i=0;i<Tortues.size();i++) { Tortues[i]->show(screen); } SDL_Flip(screen); if(temps2==0||player1->getHealth()==0 || player1->getRect()->y >=screen->h)//||player1->getRect()) { running=false; SDL_Delay(3000); showmessage("Game Over"); } SDL_Rect tmprect2={finish.x-coord.x,finish.y,30,30}; if(player1->getRect()->x+player1->getRect()->w>= tmprect2.x-tmprect2.w*2) { showmessage("You win"); SDL_Delay(1000); running=false; } if(1000/FPS>SDL_GetTicks()-start) { SDL_Delay(1000/FPS-(SDL_GetTicks()-start)); } } }