int main(int ac, char **av, char **ev) { if (ac > 1 && (ev)) if (loadmap(av[1])) return (1); return (0); }
int main(int argc, char *argv) { //a basic set up... loadmap(); glutInit(&argc, &argv); glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(640, 480); //glPixelStorei(GL_UNPACK_ALIGNMENT, 1); //create the window, the argument is the title glutCreateWindow("t'nother stupid game"); //pass the callbacks glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc (keyboard); glutIdleFunc(idle); glEnable(GL_BLEND); //alpha doesn't work without these glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //SCREW GLUT!!! AND ALL THE EVENT DRIVEN PROGRAMING PARADIGMS!!!!! //THIS //IS //U N I X !!!!!!!!!! //(and on unix, we do multiprograming, not this silly event driven sillyness) //(whell, unix is actually a copyright owned by bell labs, this is really the "berkly software distrobution" but absolutely no one cares) //DANG!!! ok, I geuss will just stick with that for now :( ...... glutMainLoop(); //Maybe lator we'll use freeglut.... less greedy with le cpu.... return 0; }
int initgame(){ loadtexture("all", "px.jpg", 4,0,8); loadtexture("all", "speed.jpg", 4,0,11); loadtexture(course[loadc].dir, "lf.jpg", 4,0,2); loadtexture(course[loadc].dir, "rt.jpg", 4,0,3); loadtexture(course[loadc].dir, "dn.jpg", 4,0,4); loadtexture(course[loadc].dir, "up.jpg", 4,0,5); loadtexture(course[loadc].dir, "ft.jpg", 4,0,6); loadtexture(course[loadc].dir, "bk.jpg", 4,0,7); loadtexture(course[loadc].dir, "terrain.jpg", 4,0,9); loadtexture(course[loadc].dir, "map.bmp", 4,0,13); loadmap (&course[loadc]); player.rotvel = 0; player.vel = 0; player.dir = 0; player.rotdir = 0; player.rot = 180; player.x = -600; player.z = -1000; debugf("Reset Player Variables"); playmusic("data/music/growler.mp3"); newgame = 0; timestart = SDL_GetTicks(); printf("\nLoaded Map:\n %s (data/%s)\n %s\n\n", course[loadc].name, course[loadc].dir, course[loadc].description); return 1; }
int main(int argc, char *argv[]) { io_openlinkeddatafile(datafile); initmap(); loadconfig(); initstuff(); loadmap(); mainloop(); saveconfig(); return 0; }
void command(int cmd, char *arg) { if (verbose) { if (arg) printf("Executing command %c %s%s\n", cmd, arg, ofline); else printf("Executing command %c %s\n", cmd, ofline); } switch (cmd) { case 't': loadmap(arg); break; case 'i': showemul(strtoi(arg, NULL, 0)); break; case 'm': loadmidi(arg); break; case 'f': loadfile(arg); break; case 'h': usage(); break; case 'r': resettable(); break; default: printf("Command %c %s not recognized.\n", cmd, ofline); break; } }
void inithdr(int fd) { Symbol s; extern Machdata powermach; seek(fd, 0, 0); if (!crackhdr(fd, &fhdr)) fatal(0, "read text header"); if(fhdr.type != FPOWER) fatal(0, "bad magic number"); if(syminit(fd, &fhdr) < 0) fatal(0, "%r\n"); symmap = loadmap(symmap, fd, &fhdr); if (mach->sbreg && lookup(0, mach->sbreg, &s)) mach->sb = s.value; machdata = &powermach; }
void setsym(void) { Symbol s; if((fsym = getfile(symfil, 1, wtflag)) < 0) { symmap = dumbmap(-1); return; } if (crackhdr(fsym, &fhdr)) { machbytype(fhdr.type); symmap = loadmap(symmap, fsym, &fhdr); if (symmap == 0) symmap = dumbmap(fsym); if (syminit(fsym, &fhdr) < 0) dprint("%r\n"); if (mach->sbreg && lookup(0, mach->sbreg, &s)) mach->sb = s.value; } else symmap = dumbmap(fsym); }
int main(int argc,char *argv[]) { struct DataMap *ptr; struct DataMapScalar *sx,*sy; struct DataMapArray *ax,*ay; size_t index[256]; size_t start[256]; size_t count[256]; int s; unsigned char vbflg=0; unsigned char help=0; unsigned char option=0; unsigned char zflg=0; FILE *fp=NULL; gzFile zfp=0; FILE *mapfp; int n,c,x; int ncid; int block=0; int varid; int strsze; char **strptr; char *tmpbuf=NULL; OptionAdd(&opt,"-help",'x',&help); OptionAdd(&opt,"-option",'x',&option); OptionAdd(&opt,"vb",'x',&vbflg); OptionAdd(&opt,"z",'x',&zflg); if (argc>1) { arg=OptionProcess(1,argc,argv,&opt,NULL); if (help==1) { OptionPrintInfo(stdout,hlpstr); exit(0); } if (option==1) { OptionDump(stdout,&opt); exit(0); } if (zflg) { zfp=gzopen(argv[arg],"r"); if (zfp==0) { fprintf(stderr,"File not found.\n"); exit(-1); } } else { fp=fopen(argv[arg],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } } } else { OptionPrintInfo(stdout,errstr); exit(-1); } /* load the map */ mapfp=fopen(argv[arg+1],"r"); loadmap(mapfp); fclose(mapfp); s=nc_open(argv[arg+2],NC_WRITE,&ncid); if (s !=NC_NOERR) { fprintf(stderr,"Error opening CDF file.\n"); exit(-1); } block=0; while (1) { if (zflg) ptr=DataMapReadZ(zfp); else ptr=DataMapFread(fp); if (ptr==NULL) break; for (c=0;c<ptr->snum;c++) { sx=ptr->scl[c]; for (n=0;n<snum;n++) { sy=sptr[n]; if (strcmp(sx->name,sy->name) !=0) continue; if (sx->type !=sy->type) continue; break; } if (n !=snum) { /* mapped variable */ s=nc_inq_varid(ncid,cdfsname[n],&varid); if (s !=NC_NOERR) { fprintf(stderr,"Error accessing CDF file.\n"); exit(-1); } index[0]=block; switch (sx->type) { case DATACHAR: s=nc_put_var1_text(ncid,varid,index,sx->data.cptr); break; case DATASHORT: s=nc_put_var1_short(ncid,varid,index,sx->data.sptr); break; case DATAINT: s=nc_put_var1_int(ncid,varid,index,sx->data.iptr); break; case DATAFLOAT: s=nc_put_var1_float(ncid,varid,index,sx->data.fptr); break; case DATADOUBLE: s=nc_put_var1_double(ncid,varid,index,sx->data.dptr); break; case DATASTRING: start[0]=block; start[1]=0; count[0]=1; count[1]=strlen(*((char **) sx->data.vptr))+1; s=nc_put_vara_text(ncid,varid,start,count, *((char **) sx->data.vptr)); break; } if (s !=NC_NOERR) { fprintf(stderr,"Error writing CDF file (%d).\n",s); exit(-1); } } } for (c=0;c<ptr->anum;c++) { ax=ptr->arr[c]; for (n=0;n<anum;n++) { ay=aptr[n]; if (strcmp(ax->name,ay->name) !=0) continue; if (ax->type !=ay->type) continue; if (ax->dim !=ay->dim) continue; break; } if (n !=anum) { /* mapped variable */ s=nc_inq_varid(ncid,cdfaname[n],&varid); if (s !=NC_NOERR) { fprintf(stderr,"Error accessing CDF file.\n"); exit(-1); } start[0]=block; count[0]=1; n=1; for (x=0;x<ax->dim;x++) { start[1+x]=0; count[1+x]=ax->rng[x]; n=n*ax->rng[x]; } if (ax->type==DATASTRING) { int ndims; int dimids[NC_MAX_VAR_DIMS]; size_t dimlen; s=nc_inq_varndims(ncid,varid,&ndims); if (s !=NC_NOERR) { fprintf(stderr,"Error accessing CDF file.\n"); exit(-1); } s=nc_inq_vardimid(ncid,varid,dimids); if (s !=NC_NOERR) { fprintf(stderr,"Error accessing CDF file.\n"); exit(-1); } if (ndims-2!=ax->dim) { fprintf(stderr,"Error matching dimensions.\n"); exit(-1); } s=nc_inq_dimlen(ncid,dimids[ndims-1],&dimlen); if (s !=NC_NOERR) { fprintf(stderr,"Error accessing CDF file.\n"); exit(-1); } strsze=dimlen; tmpbuf=malloc(n*strsze); if (tmpbuf==NULL) { fprintf(stderr,"Failed to allocate buffer.\n"); exit(-1); } memset(tmpbuf,0,n*strsze); start[1+ax->dim]=0; count[1+ax->dim]=strsze; strptr=(char **) ax->data.vptr; for (x=0;x<n;x++) strncpy(tmpbuf+x*strsze,strptr[x],strsze); } switch (ax->type) { case DATACHAR: s=nc_put_vara_text(ncid,varid,start,count,ax->data.cptr); break; case DATASHORT: s=nc_put_vara_short(ncid,varid,start,count,ax->data.sptr); break; case DATAINT: s=nc_put_vara_int(ncid,varid,start,count,ax->data.iptr); break; case DATAFLOAT: s=nc_put_vara_float(ncid,varid,start,count,ax->data.fptr); break; case DATADOUBLE: s=nc_put_vara_double(ncid,varid,start,count,ax->data.dptr); break; case DATASTRING: s=nc_put_vara_text(ncid,varid,start,count,tmpbuf); break; } if (tmpbuf !=NULL) { free(tmpbuf); tmpbuf=NULL; } if (s !=NC_NOERR) { fprintf(stderr,"Error writing CDF file (%d).\n",s); exit(-1); } } } DataMapFree(ptr); block++; } nc_close(ncid); if (zflg) gzclose(zfp); else fclose(fp); return 0; }
void loadmapname(void) { enterfilename("LOAD MAP", mapname); loadmap(); }
//main main main int main(int argc, char *argv[]) { if(argc != 2) { printf("Usage: screenshot mapfile.map\n"); exit(0); } /* This must occur before any data files are loaded */ Initialize_Paths(); printf("-------------------------------------------------------------------------------\n"); printf(" %s\n", MAPTITLESTRING); printf("-------------------------------------------------------------------------------\n"); printf("\n---------------- startup ----------------\n"); gfx_init(640, 480, false); blitdest = screen; spr_warps[0].init(convertPath("gfx/leveleditor/leveleditor_warp.png"), 255, 0, 255); spr_warps[1].init(convertPath("gfx/leveleditor/leveleditor_warp_preview.png"), 255, 0, 255); spr_warps[2].init(convertPath("gfx/leveleditor/leveleditor_warp_thumbnail.png"), 255, 0, 255); spr_platformarrows[0].init(convertPath("gfx/leveleditor/leveleditor_platform_arrows.png"), 255, 0, 255, 128); spr_platformarrows[1].init(convertPath("gfx/leveleditor/leveleditor_platform_arrows_preview.png"), 255, 0, 255, 128); spr_platformarrows[2].init(convertPath("gfx/leveleditor/leveleditor_platform_arrows_thumbnail.png"), 255, 0, 255, 128); printf("\n---------------- load map ----------------\n"); std::string tileSetPNG[3]; tileSetPNG[0] = convertPath("gfx/packs/Classic/tileset.png"); tileSetPNG[1] = convertPath("gfx/packs/Classic/tileset_medium.png"); tileSetPNG[2] = convertPath("gfx/packs/Classic/tileset_small.png"); g_map.loadTileSet(convertPath("maps/tileset.tls"), tileSetPNG); //Setup Platforms for(short iPlatform = 0; iPlatform < MAX_PLATFORMS; iPlatform++) { g_Platforms[iPlatform].rIcon[0].x = (iPlatform % 6) * 32; g_Platforms[iPlatform].rIcon[0].y = (iPlatform / 6) * 32 + 224; g_Platforms[iPlatform].rIcon[0].w = 32; g_Platforms[iPlatform].rIcon[0].h = 32; g_Platforms[iPlatform].rIcon[1].x = (iPlatform % 4) * 42 + 240; g_Platforms[iPlatform].rIcon[1].y = (iPlatform / 4) * 42 + 174; g_Platforms[iPlatform].rIcon[1].w = 32; g_Platforms[iPlatform].rIcon[1].h = 32; for(short iCol = 0; iCol < MAPWIDTH; iCol++) { for(short iRow = 0; iRow < MAPHEIGHT; iRow++) { g_Platforms[iPlatform].tiles[iCol][iRow] = TILESETSIZE; } } g_Platforms[iPlatform].iVelocity = 4; } szMapName = argv[1]; loadmap(szMapName); takescreenshot(); return 0; }
NETHER::NETHER(char *mapname) { #ifdef _WRITE_REPORT_ debug_fp=fopen("report.txt","w"); fprintf(debug_fp,"Creating game...\n"); fflush(debug_fp); #endif if (shadows==1) { lightpos[0]=-1000; lightpos[1]=-3000; lightpos[2]=5000; lightpos[3]=1; lightposv.x=lightpos[0]; lightposv.y=lightpos[1]; lightposv.z=lightpos[2]; } else { lightpos[0]=0; lightpos[1]=0; lightpos[2]=5000; lightpos[3]=1; lightposv.x=lightpos[0]; lightposv.y=lightpos[1]; lightposv.z=lightpos[2]; } /* if */ #ifdef _WRITE_REPORT_ fprintf(debug_fp,"loading objects...\n"); fflush(debug_fp); #endif loadobjects(); #ifdef _WRITE_REPORT_ fprintf(debug_fp,"loading map...\n"); fflush(debug_fp); #endif /* Load map: */ if (!loadmap(mapname)) { map_w=map_h=0; map=0; } /* if */ #ifdef _WRITE_REPORT_ fprintf(debug_fp,"Initializing game variables...\n"); fflush(debug_fp); #endif /* Set camera: */ viewp.x=map_w/2; viewp.y=0; camera.x=6; camera.y=-6; camera.z=11; zoom=1; /* Init game: */ day=0; hour=0; minute=0; second=0; shipp.x=4.0; shipp.y=2.0; shipp.z=3.0; ship_op=OP_NONE; ship_op2=OP_NONE; ship_timemoving=0; resources[0][0]=20; resources[0][1]=0; resources[0][2]=0; resources[0][3]=0; resources[0][4]=0; resources[0][5]=0; resources[0][6]=0; resources[1][0]=20; resources[1][1]=0; resources[1][2]=0; resources[1][3]=0; resources[1][4]=0; resources[1][5]=0; resources[1][6]=0; statistics[0][0]=0; statistics[0][1]=0; statistics[0][2]=0; statistics[0][3]=0; statistics[0][4]=0; statistics[0][5]=0; statistics[0][6]=0; statistics[0][7]=0; statistics[1][0]=0; statistics[1][1]=0; statistics[1][2]=0; statistics[1][3]=0; statistics[1][4]=0; statistics[1][5]=0; statistics[1][6]=0; statistics[1][7]=0; recomputestatistics=true; game_state=STATE_PLAYING; animation_timer=0; construction_pointer=0; controlled=0; game_finished=0; game_started=INTRO_TIME; #ifdef _WRITE_REPORT_ fprintf(debug_fp,"Creating menus...\n"); fflush(debug_fp); #endif /* Init status: */ newmenu(GENERAL_MENU); redrawmenu=2; redrawradar=1; #ifdef _WRITE_REPORT_ fprintf(debug_fp,"Initializing AI...\n"); fflush(debug_fp); #endif /* Init AI: */ AI_precomputations(); #ifdef _WRITE_REPORT_ fprintf(debug_fp,"Loading sounds...\n"); fflush(debug_fp); #endif /* Load sounds: */ S_shot=Mix_LoadWAV("/usr/local/share/netherearth/sound/shot.wav"); S_explosion=Mix_LoadWAV("/usr/local/share/netherearth/sound/explosion.wav"); S_select=Mix_LoadWAV("/usr/local/share/netherearth/sound/select.wav"); S_wrong=Mix_LoadWAV("/usr/local/share/netherearth/sound/wrong.wav"); S_construction=Mix_LoadWAV("/usr/local/share/netherearth/sound/construction.wav"); #ifdef _WRITE_REPORT_ fprintf(debug_fp,"Game created.\n"); fflush(debug_fp); #endif } /* NETHER::NETHER */
int main() { init(); setupmap(); bool quit = false; bool paused = true; SDL_Event userinput; while( !quit ) { while( SDL_PollEvent( &userinput ) != 0 ) { switch( userinput.type ) { case SDL_QUIT: quit = true; break; case SDL_MOUSEBUTTONDOWN: click(userinput.button.x, userinput.button.y, userinput.button.button); break; case SDL_MOUSEBUTTONUP: if (userinput.button.button == SDL_BUTTON_RIGHT ) { drag = false; } break; case SDL_MOUSEMOTION: if (drag) { worldshiftx += userinput.motion.xrel; worldshifty += userinput.motion.yrel; } break; case SDL_MOUSEWHEEL: wheelcontrol(userinput.button.x); break; case SDL_KEYDOWN: switch(userinput.key.keysym.sym) { case SDLK_SPACE: paused = !paused; break; case SDLK_l: loadmap(); break; } break; } } if(!paused) { logic(); updatestate(); } draw(); SDL_Delay(500); } close(); }
void readtext(char *s) { Dir *d; Lsym *l; Value *v; Symbol sym; ulong length; extern Machdata mipsmach; if(mtype != 0){ symmap = newmap(0, 1); if(symmap == 0) print("%s: (error) loadmap: cannot make symbol map\n", argv0); length = 1<<24; d = dirfstat(text); if(d != nil) { length = d->length; free(d); } setmap(symmap, text, 0, length, 0, "binary"); free(d); return; } machdata = &mipsmach; if(!crackhdr(text, &fhdr)) { print("can't decode file header\n"); return; } symmap = loadmap(0, text, &fhdr); if(symmap == 0) print("%s: (error) loadmap: cannot make symbol map\n", argv0); if(syminit(text, &fhdr) < 0) { print("%s: (error) syminit: %r\n", argv0); return; } print("%s:%s\n\n", s, fhdr.name); if(mach->sbreg && lookup(0, mach->sbreg, &sym)) { mach->sb = sym.value; l = enter("SB", Tid); l->v->vstore.fmt = 'X'; l->v->vstore.u0.sival = mach->sb; l->v->type = TINT; l->v->set = 1; } l = mkvar("objtype"); v = l->v; v->vstore.fmt = 's'; v->set = 1; v->vstore.u0.sstring = strnode(mach->name); v->type = TSTRING; l = mkvar("textfile"); v = l->v; v->vstore.fmt = 's'; v->set = 1; v->vstore.u0.sstring = strnode(s); v->type = TSTRING; machbytype(fhdr.type); varreg(); }
int main(int argc, char *argv[]) { int rc, i, uid, n, c, ch, t, mtbl, line, offset; FILE *fp; char filename[64], inbuf[128], name[NATIONNMLEN+1], *p, *u; struct stat st_buf; /* set directory */ if(argc > 1) if(chdir(argv[1]) == -1) { gmove(20,18); gprintf("Error Setting Directory %s\n", argv[1]); ggetch(); gend(); exit(1); } /* set up display */ ginit(); gmove(5, 10); gputs("WARTOOL 1.0 Game Editor for Solomoriah's WAR!"); gmove(6, 10); gputs("Copyright 1994, J. Christopher Gonnerman"); gmove(7, 10); gputs("All Rights Reserved."); /* load map file */ rc = loadmap(); if(rc != 0) { gmove(20,10); gprintf("Error Loading Map (%s)\n", errors[rc]); ggetch(); gend(); exit(1); } /* load game save */ rc = loadsave(); if(rc != 0) { gmove(20,10); gprintf("Error Loading Game Save (%s)\n", errors[rc]); ggetch(); gend(); exit(1); } /* execute master file */ gmove(20,10); gputs("Reading Master Commands... "); grefresh(); fp = fopen(MASTERFL, "r"); if(fp != NULL) { for(i = 0; fgets(inbuf, 128, fp) != NULL; i++) { rc = execpriv(inbuf); if(rc == 0) { if((i+1) % 10 == 0) { gmove(20,48); gprintf("%3d lines", i+1); grefresh(); } } else { gmove(20,10); gprintf("Master Cmd Failed, Line %d, Code %d ", i+1, rc); (void)ggetch(); gend(); exit(2); } } fclose(fp); } /* main loop */ gmove(20,10); gputs("Press Any Key to Begin... "); gclrline(); ggetch(); mainscreen(); toolmain(); unlink("game.bak"); if(rename("game.sav", "game.bak") == 0) fp = fopen("game.sav", "w"); else fp = fopen("game.sv!", "w"); savegame(fp); fclose(fp); /* clean up */ endwin(); exit(0); }
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)); } } }