main () { int startTimems = timems(); int i; char *j[10]; for (i = 0; i < 10; i++) { printf("%d\n",i); j[i] = malloc(1024); j[i][512] = 65; } for (i = 0; i < 10; i++) printf("%c",j[i][512]); printf("Execution time (ms): %d\n",timems()-startTimems); exit(0); }
int main () { int startTimems = timems(); int i,j; x = 30; x = bar(x); printf ("answer = %d\n",x); for(j=0;j<3;j++) { for(i=0;i<30;i++) { x = fib(i); printf ("answer = %d\n",x); } } printf("Execution time (ms): %d\n",timems()-startTimems); exit (0x77); }
ParametersMap MapRequest::run( std::ostream& stream, const Request& request ) const { if (!_map.get()) { return ParametersMap(); } // Prepare the map (once for all renderings!) _map->prepare (); // Create a temporary file name based on system time const filesystem::path tempDir(MapModule::GetParameter (MapModule::PARAM_HTTP_TEMP_DIR), filesystem::native); RenderingConfig conf; // Choose the renderer boost::shared_ptr<Renderer> renderer(Factory<Renderer>::create(_output)); // Generate an id for the map file based on current time ptime timems (boost::date_time::microsec_clock<ptime>::local_time ()); std::string filePrefix = "map_" + to_iso_string (timems); std::string resultFilename = renderer->render (tempDir, filePrefix, _temporaryEnvironment.getRegistry<JourneyPattern>(), *_map, conf); // Broadcast of the result std::string resultURL = MapModule::GetParameter (MapModule::PARAM_HTTP_TEMP_URL) + "/" + resultFilename; // Send the URL to the the generated local JPEG file. stream << resultURL; Log::GetInstance ().debug ("Sent result url " + resultURL); return ParametersMap(); }
void GameClient::update( GameClientUpdateContext& updateContext ) { const timems timeMs = timems( updateContext.timeDelta * 1000.0f ); m_renderScene.clearState(); m_entitySystem.update(); Camera camera; camera.create( m_pRenderView->getCamera() ); m_gameCamera.update( camera, updateContext.pTerrainState, updateContext.timeDelta ); if( s_useFreeCamera ) { m_freeCamera.update( m_pRenderView->getCamera(), updateContext.timeDelta ); } else { m_pRenderView->getCamera().create( camera ); } m_physicsWorld.update( updateContext.timeDelta ); m_physicsCharacterControllerComponent.update(); m_physicsBodyComponent.update(); m_playerControlComponent.update( m_gameCamera, camera, updateContext.timeDelta ); m_lifeTimeComponent.update( m_entitySystem, timeMs ); m_coinComponent.update( updateContext.pPlayerCollider, updateContext.collectedCoins, updateContext.totalGameTime ); m_transformComponent.update(); }
static void on_connect(uv_stream_t* stream, int status) { MALLOC(http_connection_t, conn); get_unique_id(conn->id); conn->request = NULL; conn->response = NULL; conn->time = timems(); conn->routes = (struct http_routes *)stream->data; conn->timeout = NULL; conn->replied = 0; REFERENCE_INIT(conn, _conn_destroy); uv_tcp_init(uv_loop, &conn->stream); http_parser_init(&conn->parser, HTTP_REQUEST); conn->write_req.data = conn; conn->parser.data = conn; conn->stream.data = conn; /* TODO: Use the return values from uv_accept() and * uv_read_start() */ uv_accept(stream, (uv_stream_t*)&conn->stream); uv_read_start( (uv_stream_t*)&conn->stream, http_stream_on_alloc, http_stream_on_read ); }
/** * Generate Unique ID that is used for each message, * it was inspired by MongoID's */ void get_unique_id(char * uuid) { struct timeval tp; long long time = (long long) timems(); long long rnd0; gettimeofday(&tp, NULL); srand(tp.tv_usec); if (!process_id) { process_id = random() & 0xFFFFFF; } if (!counter || counter == 0xFFFFFE) { counter = random() & 0xFFFFFF; } sprintf(uuid, "%08llx%06llx%04llx%06llx", time & 0xFFFFFFFF, process_id, random() & 0xFFFF, ++counter); }
int http_send_response(http_connection_t * conn) { uv_buf_t resbuf; char time[90]; assertWithInfo(conn->replied == 0); conn->replied = 1; sprintf(time, "%.f ms", timems() - conn->time); HEADER("X-Connection-Id", conn->id); HEADER("X-Response-Time", time); HEADER("Access-Control-Allow-Origin", config->web_allow_origin); http_build_header_ptr(conn->response); resbuf = uv_buf_init(conn->response->header_ptr, conn->response->header_len); uv_write(&conn->write_req, (uv_stream_t*) &conn->stream, &resbuf, 1, http_server_sent_header); return 0; }
void main(int argc, char *argv[]) { int len, rcode; char tname[32]; char *err, *ext = ""; unsigned char buf[64*1024], callip[IPaddrlen]; DNSmsg reqmsg, repmsg; Request req; alarm(2*60*1000); cfg.cachedb = 1; ARGBEGIN{ case 'd': debug++; break; case 'f': dbfile = EARGF(usage()); break; case 'r': cfg.resolver = 1; break; case 'R': norecursion = 1; break; case 'x': ext = EARGF(usage()); break; default: usage(); break; }ARGEND if(debug < 2) debug = 0; if(argc > 0) getcaller(argv[0]); cfg.inside = 1; dninit(); snprint(mntpt, sizeof mntpt, "/net%s", ext); if(myipaddr(ipaddr, mntpt) < 0) sysfatal("can't read my ip address"); dnslog("dnstcp call from %s to %I", caller, ipaddr); memset(callip, 0, sizeof callip); parseip(callip, caller); db2cache(1); memset(&req, 0, sizeof req); setjmp(req.mret); req.isslave = 0; procsetname("main loop"); /* loop on requests */ for(;; putactivity(0)){ now = time(nil); memset(&repmsg, 0, sizeof repmsg); len = readmsg(0, buf, sizeof buf); if(len <= 0) break; getactivity(&req, 0); req.aborttime = timems() + S2MS(15*Min); rcode = 0; memset(&reqmsg, 0, sizeof reqmsg); err = convM2DNS(buf, len, &reqmsg, &rcode); if(err){ dnslog("server: input error: %s from %s", err, caller); free(err); break; } if (rcode == 0) { if(reqmsg.qdcount < 1){ dnslog("server: no questions from %s", caller); break; } else if(reqmsg.flags & Fresp){ dnslog("server: reply not request from %s", caller); break; } else if((reqmsg.flags & Omask) != Oquery){ dnslog("server: op %d from %s", reqmsg.flags & Omask, caller); break; } } if(debug) dnslog("[%d] %d: serve (%s) %d %s %s", getpid(), req.id, caller, reqmsg.id, reqmsg.qd->owner->name, rrname(reqmsg.qd->type, tname, sizeof tname)); /* loop through each question */ while(reqmsg.qd) if(reqmsg.qd->type == Taxfr) dnzone(&reqmsg, &repmsg, &req); else { dnserver(&reqmsg, &repmsg, &req, callip, rcode); reply(1, &repmsg, &req); rrfreelist(repmsg.qd); rrfreelist(repmsg.an); rrfreelist(repmsg.ns); rrfreelist(repmsg.ar); } rrfreelist(reqmsg.qd); /* qd will be nil */ rrfreelist(reqmsg.an); rrfreelist(reqmsg.ns); rrfreelist(reqmsg.ar); if(req.isslave){ putactivity(0); _exits(0); } } refreshmain(mntpt); }
// open/load a whole statdatabase from file to ram ready for process adding // return 0....VDnums. // -1 for failure long DBIO_LoadFromFile( long f, long VDcount, long *allreq ) { gzFile fp( (gzFile)f ); // cast to native file type long totalReq=0, n; VDinfoP VDptr = NULL,oldvd; if ( fp ){ { long VhostStat, DBStat, alltime1, x; char *listName; char id[32]; StatList *stat = NULL; alltime1 = (long)timems(); DBStat = gzread( fp, id, 8 ); while( DBStat ) { if ( strcmpd( "FWDB", id ) ){ OutDebug( "File is not a database" ); return -1; } if ( !strcmpd( "FWDBASE", id ) ) db_version = 4; else db_version = atof( id+4 ); // Read the VDinfo into a temp buffer of appropriate size. Note that we don't // actually construct a VDinfo instance here as we do not want its dtor to be // called on exit of the current scope. char vdataBuf[sizeof(VDinfo)]; VhostStat = gzread( fp, vdataBuf, sizeof(VDinfo) ); if( VhostStat ){ char msg[256]; long listnum = 0; // reinterpret our temp VDinfo buffer for convenience VDinfo& VDdata=*reinterpret_cast<VDinfo*>(vdataBuf); OutDebugs( "Reading Host #%d, %s", VDcount, VDdata.domainName ); sprintf( msg, "Loading Host #%d, %s", VDcount, VDdata.domainName ); DBIO_UpdateProgress( 0, 1, msg ); oldvd = VDptr; VDptr = InitVirtualDomain( VDcount, VDdata.domainName, 1 ); if ( oldvd ) oldvd->next = VDptr; VDptr->logType = VDdata.logType; // = LOGFORMAT_DATABASE; VDptr->firstTime = VDdata.firstTime; VDptr->lastTime = VDdata.lastTime; VDptr->totalInDataSize = VDdata.totalInDataSize; VDptr->totalFailedRequests = VDdata.totalFailedRequests; VDptr->totalRequests = VDdata.totalRequests; VDptr->totalCachedHits = VDdata.totalCachedHits; VDptr->totalUniqueClients = VDdata.totalUniqueClients; VDptr->totalFlushedClients = VDdata.totalFlushedClients; VDptr->totalRepeatClients = VDdata.totalRepeatClients; VDptr->totalDays = VDdata.totalDays; VDptr->totalBytes = VDdata.totalBytes; VDptr->totalBytesIn = VDdata.totalBytesIn; totalReq += VDptr->totalRequests; VDcount++; n = 0; // The proper way to read the database which may change in future..... while( VhostStat ){ memset( id, 0, 16 ); listName = &id[5]; DBStat = gzread( fp, id, 8 ); if ( !strcmpd( "FWDB", id ) ) { OutDebug( "New host found" ); x = 0; // Another VHOST header, stop and restart new vhost } else x = gzread( fp, id+8, 8 ); if ( !strcmpd( listName, "hour" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byHour, fp, id ); else if ( !strcmpd( listName, "wkday" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byWeekday, fp, id ); else if ( !strcmpd( listName, "wdays" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byWeekdays[n++], fp, id ); else if ( !strcmpd( listName, "month" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byMonth, fp, id ); else if ( !strcmpd( listName, "date" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byDate, fp, id ); else if ( !strcmpd( listName, "client" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byClient, fp, id ); else if ( !strcmpd( listName, "src" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byServers, fp, id ); else if ( !strcmpd( listName, "url" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byFile, fp, id ); else if ( !strcmpd( listName, "browser" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byBrowser, fp, id ); else if ( !strcmpd( listName, "oper" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byOperSys, fp, id ); else if ( !strcmpd( listName, s_robotsTag ) ) x = DBIO_LoadStatList( VDptr, VDptr->byRobot, fp, id ); else if ( !strcmpd( listName, "refer" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byRefer, fp, id ); else if ( !strcmpd( listName, "rsite" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byReferSite, fp, id ); else if ( !strcmpd( listName, "dir" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byDir, fp, id ); else if ( !strcmpd( listName, "groups" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byGroups, fp, id ); else if ( !strcmpd( listName, "topdir" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byTopDir, fp, id ); else if ( !strcmpd( listName, "type" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byType, fp, id ); // "errs" only for older databases (pre 4.5) without top referals on errors info else if ( !strcmpd( listName, "errs" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byErrors, fp, id ); // s_errorsWithTopReferralsTag only for newer databases (post 4.5) with top referals on errors info else if ( !strcmpd( listName, s_errorsWithTopReferralsTag ) ) x = DBIO_LoadStatList( VDptr, VDptr->byErrors, fp, id ); else if ( !strcmpd( listName, "errurl" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byErrorURL, fp, id ); else if ( !strcmpd( listName, "pages" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byPages, fp, id ); else if ( !strcmpd( listName, "searchstr")) x = DBIO_LoadStatList( VDptr, VDptr->bySearchStr, fp, id ); else if ( !strcmpd( listName, "searchsite")) x = DBIO_LoadStatList( VDptr, VDptr->bySearchSite, fp, id ); else if ( !strcmpd( listName, "down" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byDownload, fp, id ); else if ( !strcmpd( listName, "advert" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byAdvert, fp, id ); else if ( !strcmpd( listName, "adcamp" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byAdCamp, fp, id ); else if ( !strcmpd( listName, "mplayers" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byMediaPlayers, fp, id ); else if ( !strcmpd( listName, "audio" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byAudio, fp, id ); else if ( !strcmpd( listName, "video" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byVideo, fp, id ); else if ( !strcmpd( listName, "mtypes" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byMediaTypes, fp, id ); else if ( !strcmpd( listName, "prot" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byProtocol, fp, id ); else if ( !strcmpd( listName, "https" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byHTTPS, fp, id ); else if ( !strcmpd( listName, "http" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byHTTP, fp, id ); else if ( !strcmpd( listName, "mail" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byMail, fp, id ); else if ( !strcmpd( listName, "ftp" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byFTP, fp, id ); else if ( !strcmpd( listName, "telnet" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byTelnet, fp, id ); else if ( !strcmpd( listName, "dns" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byDNS, fp, id ); else if ( !strcmpd( listName, "pop3" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byPOP3, fp, id ); else if ( !strcmpd( listName, "real" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byReal, fp, id ); else if ( !strcmpd( listName, "others" ) ) x = DBIO_LoadStatList( VDptr, VDptr->byOthers, fp, id ); else if ( !strcmpd( listName, s_brokenLinkReferalsTag ) ) x = DBIO_LoadStatList( VDptr, VDptr->byBrokenLinkReferal, fp, id ); else if ( !strcmpd( listName, s_intBrokenLinkReferalsTag ) ) x = DBIO_LoadStatList( VDptr, VDptr->byIntBrokenLinkReferal, fp, id ); else if ( !strcmpd( listName, s_unrecognisedAgentsTag) ) x = DBIO_LoadStatList( VDptr, VDptr->byUnrecognizedAgents, fp, id ); else if ( !strcmpd( listName, s_szClustersTag) ) x = DBIO_LoadStatList( VDptr, VDptr->byClusters, fp, id ); DBIO_UpdateProgress( listnum++, 37, NULL ); VhostStat = x; } // while doing stats FixClientBrowserOS_IDS( VDptr ); } // if vhost } //while loop in dbase if ( !DBStat ) OutDebug( "End of database" ); VDptr->time2 = timems() - VDptr->time1; if ( VDptr->time2 == 0 ) VDptr->time2=1; } } *allreq += totalReq; // make sure its 1 less, VDcount of 1 means 1 host, but must be 0, VDcount of 8 is 7hosts, so its returned as 7. // as the first host info is the file not the hosts. return VDcount-1; }
/* * a process to act as a dns server for outside reqeusts */ void dnudpserver(char *mntpt) { volatile int fd, len, op, rcode; char *volatile err; volatile char tname[32]; volatile uchar buf[Udphdrsize + Maxudp + 1024]; volatile DNSmsg reqmsg, repmsg; Inprogress *volatile p; volatile Request req; Udphdr *volatile uh; /* * fork sharing text, data, and bss with parent. * stay in the same note group. */ switch(rfork(RFPROC|RFMEM|RFNOWAIT)){ case -1: break; case 0: break; default: return; } fd = -1; restart: procsetname("udp server announcing"); if(fd >= 0) close(fd); while((fd = udpannounce(mntpt)) < 0) sleep(5000); // procsetname("udp server"); memset(&req, 0, sizeof req); if(setjmp(req.mret)) putactivity(0); req.isslave = 0; req.id = 0; req.aborttime = 0; /* loop on requests */ for(;; putactivity(0)){ procsetname("served %d udp; %d alarms", stats.qrecvdudp, stats.alarms); memset(&repmsg, 0, sizeof repmsg); memset(&reqmsg, 0, sizeof reqmsg); alarm(60*1000); len = read(fd, buf, sizeof buf); alarm(0); if(len <= Udphdrsize) goto restart; redistrib(buf, len); uh = (Udphdr*)buf; len -= Udphdrsize; // dnslog("read received UDP from %I to %I", // ((Udphdr*)buf)->raddr, ((Udphdr*)buf)->laddr); getactivity(&req, 0); req.aborttime = timems() + Maxreqtm; // req.from = smprint("%I", ((Udphdr*)buf)->raddr); req.from = smprint("%I", buf); rcode = 0; stats.qrecvdudp++; err = convM2DNS(&buf[Udphdrsize], len, &reqmsg, &rcode); if(err){ /* first bytes in buf are source IP addr */ dnslog("server: input error: %s from %I", err, buf); free(err); goto freereq; } if (rcode == 0) if(reqmsg.qdcount < 1){ dnslog("server: no questions from %I", buf); goto freereq; } else if(reqmsg.flags & Fresp){ dnslog("server: reply not request from %I", buf); goto freereq; } op = reqmsg.flags & Omask; if(op != Oquery && op != Onotify){ dnslog("server: op %d from %I", reqmsg.flags & Omask, buf); goto freereq; } if(debug || (trace && subsume(trace, reqmsg.qd->owner->name))) dnslog("%d: serve (%I/%d) %d %s %s", req.id, buf, uh->rport[0]<<8 | uh->rport[1], reqmsg.id, reqmsg.qd->owner->name, rrname(reqmsg.qd->type, tname, sizeof tname)); p = clientrxmit(&reqmsg, buf); if(p == nil){ if(debug) dnslog("%d: duplicate", req.id); goto freereq; } if (Logqueries) { RR *rr; for (rr = reqmsg.qd; rr; rr = rr->next) syslog(0, "dnsq", "id %d: (%I/%d) %d %s %s", req.id, buf, uh->rport[0]<<8 | uh->rport[1], reqmsg.id, reqmsg.qd->owner->name, rrname(reqmsg.qd->type, tname, sizeof tname)); } /* loop through each question */ while(reqmsg.qd){ memset(&repmsg, 0, sizeof repmsg); switch(op){ case Oquery: dnserver(&reqmsg, &repmsg, &req, buf, rcode); break; case Onotify: dnnotify(&reqmsg, &repmsg, &req); break; } /* send reply on fd to address in buf's udp hdr */ reply(fd, buf, &repmsg, &req); freeanswers(&repmsg); } p->inuse = 0; freereq: free(req.from); req.from = nil; freeanswers(&reqmsg); if(req.isslave){ putactivity(0); _exits(0); } } }
void io(void) { volatile long n; volatile uchar mdata[IOHDRSZ + Maxfdata]; Job *volatile job; Mfile *volatile mf; volatile Request req; memset(&req, 0, sizeof req); /* * a slave process is sometimes forked to wait for replies from other * servers. The master process returns immediately via a longjmp * through 'mret'. */ if(setjmp(req.mret)) putactivity(0); req.isslave = 0; stop = 0; while(!stop){ procsetname("%d %s/dns Twrites of %d 9p rpcs read; %d alarms", stats.qrecvd9p, mntpt, stats.qrecvd9prpc, stats.alarms); n = read9pmsg(mfd[0], mdata, sizeof mdata); if(n<=0){ dnslog("error reading 9P from %s: %r", mntpt); sleep(2000); /* don't thrash after read error */ return; } stats.qrecvd9prpc++; job = newjob(); if(convM2S(mdata, n, &job->request) != n){ freejob(job); continue; } mf = newfid(job->request.fid, 0); if(debug) dnslog("%F", &job->request); getactivity(&req, 0); req.aborttime = timems() + Maxreqtm; req.from = "9p"; switch(job->request.type){ default: warning("unknown request type %d", job->request.type); break; case Tversion: rversion(job); break; case Tauth: rauth(job); break; case Tflush: rflush(job); break; case Tattach: rattach(job, mf); break; case Twalk: rwalk(job, mf); break; case Topen: ropen(job, mf); break; case Tcreate: rcreate(job, mf); break; case Tread: rread(job, mf); break; case Twrite: /* &req is handed to dnresolve() */ rwrite(job, mf, &req); break; case Tclunk: rclunk(job, mf); break; case Tremove: rremove(job, mf); break; case Tstat: rstat(job, mf); break; case Twstat: rwstat(job, mf); break; } freejob(job); /* * slave processes die after replying */ if(req.isslave){ putactivity(0); _exits(0); } putactivity(0); } /* kill any udp server, notifier, etc. processes */ postnote(PNGROUP, getpid(), "die"); sleep(1000); }
void main(){ _setcursortype(_NOCURSOR); randomize(); clrscr(); for(int o = 0; o<9; o++){ gotoxy(3, 3+o); //puts(banner2[o]); cprintf("%s",banner2[o]); delay(50); } for(int p = 0; p<9; p++){ gotoxy(20, 15+p); cprintf("%s",banner3[p]); // puts(banner3[p]); delay(50); } gotoxy(55, 25); cout<<"by Shreyas Kishore, XI-F"; getch(); clrscr(); char ch; int selprev; box(0,0,77,24,50); gotoxy(35,1); char name[] = "ЕFlappy BirdЦ"; int n = 0; for(int l = 0; l<=7; l++){ gotoxy(12,16 +l); // cprintf("%s",banner1[p]); puts(banner1[l]); } gotoxy(35,1); while(name[n] != '\0'){ cout<<name[n]; n++; delay(25); } box(30, 4, 17, 10, 30); gotoxy(35, 7); cout<<"Choose Mode:"; gotoxy(35,10); cout<<"Normal Mode"; gotoxy(35,13); cout<<"Disco Mode"; while((int)ch != 13){ if((int)ch == 72){selprev = selection; selection = 0;} if((int)ch == 80){selprev = selection; selection = 1;} if(selprev != selection){ for(int i = 32; i<=48; i++){ for( int j = 7; j<= 14; j++){ gotoxy(i,j); cout<<" "; } } } if(selection == 0) box(32,8,13,2); if(selection == 1) box(32,11,13, 2); box(0,0,77,24,1000); gotoxy(35,1); cout<<"ЕFlappy BirdЦ"; box(30, 4, 17, 10, 300); gotoxy(35, 7); cout<<"Choose Mode:"; gotoxy(35,10); cout<<"Normal Mode"; gotoxy(35,13); cout<<"Disco Mode"; ch = getch(); } //SetConsoleCursorInfo(_NOCURSOR); int x = 25, y = 2, xprev, yprev, con = 0, scorecalc = 0, phase= 0; float del = 200; makecyl(); box(); gotoxy(35,1); //name = "Flappy Bird"; n = 0; while(name[n] != '\0'){ cout<<name[n]; n++; delay(25); } line(2, 24, 78, 24, 60, 3); long event_fall = timems(), press, event_makecyl = timems(), event_display = timems(), event_shift = timems(); while(y<=24 && data[yprev][xprev]==0){ gotoxy(x,y); //cout<<setclr(9); cout<<""; gotoxy(xprev, yprev); cout<<" "; if(timemssince(event_display)>50){ display(); event_display = timems(); linewphase(2, 24, 78, 24, 1000, phase); } if(timemssince(event_shift)>50){ shift(); scorecalc++; event_shift = timems(); data_assign(); phase++; score= (scorecalc-35)/30; if(score<0)score = 0; } if(timemssince(event_makecyl)>1500){ makecyl(); event_makecyl = timems(); } if(timemssince(event_fall)>del){ del-=30; xprev = x; yprev = y; y++; if(del<40) del = 40; event_fall = timems(); } if(getchn()){ if(con == 0){ xprev = x; yprev = y; //if(y<2) y = 2; del = 200; con = 1; press = timems(); } } if(con==1 && timemssince(press)>0 && timemssince(press)<=30){yprev=y; y--; con++;} else if(con==2 && timemssince(press)>30 && timemssince(press)<=80){yprev=y;y--; con++;} else if(con==3 && timemssince(press)>80 && timemssince(press)<=150){yprev=y;y--; con++;} else if(con==4 && timemssince(press)>150 && timemssince(press)<=240){yprev=y;y--; con++;} else if(con==5 && timemssince(press)>240 && timemssince(press)<=350){yprev=y;y--; con=0;} if(y<2)y=2; } for(int xx=34; xx<=46; xx++){ for(int yy = 11; yy<=15; yy++){ gotoxy(xx,yy); cout<<" "; } } box(32, 9, 13, 6, 5, 4); gotoxy(36,12); cout<<"GAME OVER!"; gotoxy(36,14); cout<<"Score: "<<score; getch(); }