int main (int argc, char* argv[]) { SDL_Event event; int active=1; fullscreen=0; sdlglinit(640,480,BPP,fullscreen); ourinit(); while(1) { while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_VIDEORESIZE: surface=SDL_SetVideoMode(event.resize.w,event.resize.h,BPP,videoflags); if(!surface) error("Couldn't get surface after resize: %s\n",SDL_GetError()); initgl(); /* needed before resize to avoid every setting being reset, like background colour, depth settings etc. the absence of this line causes wrong depth stuff. */ resizeglscene(event.resize.w,event.resize.h); break; case SDL_KEYDOWN: handlekeypress(&event.key.keysym); break; case SDL_QUIT: goto theend; } } if(active) drawglscene(); } theend: killglwindow(); return 0; }
int main (int argc, char* argv[]) { SDL_Event event; int active=1; fullscreen=0; sdlglinit(640,480,BPP,fullscreen); ourinit(); while(1) { while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_VIDEORESIZE: surface=SDL_SetVideoMode(event.resize.w,event.resize.h,BPP,videoflags); if(!surface) error("Couldn't get surface after resize: %s\n",SDL_GetError()); initgl(); /* after setting video mode, we lost every gl setting. set again. */ resizeglscene(event.resize.w,event.resize.h); break; case SDL_KEYDOWN: keys[event.key.keysym.sym]=1; handlekeypress(&event.key.keysym); break; case SDL_KEYUP: keys[event.key.keysym.sym]=0; break; case SDL_QUIT: goto theend; } } /* check for held keys */ heldkeys(); if(active) drawglscene(); } theend: killglwindow(); return 0; }
void main() { if(InitGraphics() == -1) return; initialisedata(); clearviewport(); rectangle(0,0,(maxx+1)*width+2, (maxy+1)*width+2); sx = (maxx+1)*width+6; sy = (maxy+1)*width+2; int loop = 0; while(!endgame) { loop++; for (int i = 0; i < NUM_PLAYERS; i++) { drawplayer(plist[i]); } showscoreboard(); delay(DELAY_INTERVAL); for (i = 0; i < NUM_PLAYERS; i++) { showbox(plist[i]); } if (kbhit()) { handlekeypress(); } if (endgame) break; // 1 to n is computer plaer, 0 is me for (i = 1; i < NUM_PLAYERS; i++) { decidemove(plist[i]); } for (i = 0; i < NUM_PLAYERS; i++) { adjustdir(plist[i]); moveit(plist[i]); } for (i = 0; i < NUM_PLAYERS; i++) { updatescore(plist[i]); if (plist[i].score >= WINNING_SCORE) { endgame = true; setfillstyle(1, BLUE); bar(200,120,439,300); outtextxy(250,200,"GAME OVER"); if (i == 0) { outtextxy(250,250,"YOU WIN"); } else { outtextxy(250,250,"YOU LOSE"); } showscoreboard(); char tr = getch(); } } } }