void editorLoad(const char* fn, SDL_Surface* screen) { //Set filename editorFileName(fn); //Init cursor initCursor(&cur); //Read info's for level. pf.levelInfo = mkLevelInfo( fn ); //Load field loadField(&pf, fileName); initDraw(pf.levelInfo, screen); SDL_FreeSurface(stealGfxPtr()->boardImg); stealGfxPtr()->boardImg = loadImg( DATADIR"data/editbg.png" ); selBrickBG = loadImg( DATADIR"data/editselbrick.png" ); saveBtnBG = loadImg( DATADIR"data/edit-save.png" ); saveBtnSprite = cutSprite( saveBtnBG, 0,0, saveBtnBG->w, saveBtnBG->h ); changed=0; selBrick=BRICKSBEGIN; teleState=0; fieldRect.x = HSCREENW - 74; fieldRect.y = HSCREENH - 114; fieldRect.w = HSCREENW + 154; fieldRect.h = HSCREENH + 114; }
void View3D::initializeGL() { if (glewInit() != GLEW_OK) { g_logger.error("%s", "Failed to initialize GLEW"); m_badOpenGL = true; return; } g_logger.info("OpenGL implementation:\n" " GL_VENDOR = %s\n" " GL_RENDERER = %s\n" " GL_VERSION = %s\n" " GLSL_VERSION = %s\n" " GLEW_VERSION = %s", (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER), (const char*)glGetString(GL_VERSION), (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), (const char*)glewGetString(GLEW_VERSION)); // GL_CHECK has to be defined for this to actually do something glCheckError(); initCursor(10, 1); initAxes(); initGrid(2.0f); glCheckError(); m_boundingBoxShader.reset(new ShaderProgram()); m_boundingBoxShader->setShaderFromSourceFile("shaders:bounding_box.glsl"); m_meshFaceShader.reset(new ShaderProgram()); m_meshFaceShader->setShaderFromSourceFile("shaders:meshface.glsl"); m_meshEdgeShader.reset(new ShaderProgram()); m_meshEdgeShader->setShaderFromSourceFile("shaders:meshedge.glsl"); m_annotationShader.reset(new ShaderProgram()); m_annotationShader->setShaderFromSourceFile("shaders:annotation.glsl"); double dPR = getDevicePixelRatio(); int w = width() * dPR; int h = height() * dPR; m_incrementalFramebuffer.init(w, h); initializeGLGeometry(0, m_geometries->get().size()); // FIXME: Do something about this mess. The shader editor widget needs to // be initialized with the default shader, but View3D can only compile // shaders after it has a valid OpenGL context. PointViewerMainWindow * pv_parent = dynamic_cast<PointViewerMainWindow *>(parentWidget()); if (pv_parent) pv_parent->openShaderFile("shaders:las_points.glsl"); setFocus(); }
MapView::MapView(): QGraphicsScene() { gridStrategy = NULL; displayStrategy = NULL; paintStrategy = NULL; initCursor(); modified = false; }
void compositorInvalidate( WstCompositor *wctx, void *userData ) { AppCtx *appCtx= (AppCtx*)userData; #if defined (WESTEROS_PLATFORM_EMBEDDED) || defined (WESTEROS_HAVE_WAYLAND_EGL) if ( appCtx->isEmbedded ) { bool needHolePunch= false; int hints= WstHints_noRotation; if ( appCtx->eglDisplay == EGL_NO_DISPLAY ) { setupEGL( appCtx ); } eglMakeCurrent( appCtx->eglDisplay, appCtx->eglSurface, appCtx->eglSurface, appCtx->eglContext ); GLfloat priorColor[4]; glGetFloatv( GL_COLOR_CLEAR_VALUE, priorColor ); glBlendFuncSeparate( GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE ); glClearColor( 0.0, 0.0, 0.0, 0.0 ); glClear( GL_COLOR_BUFFER_BIT ); glEnable(GL_BLEND); appCtx->rects.clear(); WstCompositorComposeEmbedded( wctx, appCtx->x, appCtx->y, appCtx->width, appCtx->height, appCtx->matrix, appCtx->alpha, hints, &needHolePunch, appCtx->rects ); glClearColor( priorColor[0], priorColor[1], priorColor[2], priorColor[3] ); eglSwapBuffers(appCtx->eglDisplay, appCtx->eglSurface); } #endif #if defined (WESTEROS_PLATFORM_EMBEDDED) if ( appCtx->showCursor && !appCtx->cursorReady ) { appCtx->showCursor= initCursor( appCtx ); } #endif #if !defined (WESTEROS_PLATFORM_EMBEDDED) glutSwapBuffers(); #endif }
MapView::MapView(Model::Map * m) : QGraphicsScene() { gridStrategy = NULL; displayStrategy = NULL; paintStrategy = NULL; setMap(m); initCursor(); modified = false; }
void MapView::setEnableCursor(bool ena) { if (ena) { removeLayer(CURSOR); initCursor(); } else { removeLayer(CURSOR); } }
void OptionsMenu::init() { if(!inited) { addObject(mainMenu.getCamera()); addObject(mainMenu.getSkybox()); addObject(mainMenu.getBridge()); addObject(mainMenu.getFloor()); addObject(mainMenu.getFadeConstant()); addObject(mainMenu.getLogo()); initFonts(); initCursor(); } inited = true; }
bool Diving::play(uint16 playerCount, bool hasPearlLocation) { init(); initScreen(); initCursor(); _vm->_draw->blitInvalidated(); _vm->_video->retrace(); while (!_vm->shouldQuit()) { evilFishEnter(); checkShots(); updateAnims(); _vm->_draw->animateCursor(1); _vm->_draw->blitInvalidated(); _vm->_util->waitEndFrame(); _vm->_util->processInput(); int16 mouseX, mouseY; MouseButtons mouseButtons; int16 key = checkInput(mouseX, mouseY, mouseButtons); if (key == kKeyEscape) break; if (mouseButtons == kMouseButtonsLeft) shoot(mouseX, mouseY); if ((_whitePearlCount >= 20) || (_blackPearlCount >= 2)) break; } deinit(); return _blackPearlCount >= 2; }
int Main(void) { // Load resources texsmallball = CORE_LoadBmp("data/tyrian_ball.32.bmp" , false); texcursor = CORE_LoadBmp("data/cursor.bmp", false); initCursor(); initParticlePool(MAX_PARTICLES); initEmmiter(); // Set up rendering glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT); // Sets up clipping glClearColor( 0.0f, 0.1f, 0.3f, 0.0f ); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho( 0.0, SCR_WIDTH, 0.0, SCR_HEIGHT, 0.0, 1.0); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DWORD start_tick= GetTickCount(); while (!SYS_GottaQuit()) { // Render glClear( GL_COLOR_BUFFER_BIT ); CORE_RenderCenteredSprite(cursor->pos, vmake(cursor->radius , cursor->radius ), cursor->index); //fixed substep float dt =1.0f/(substep*FPS); //add gravity // tVector emitterforces=vmake(0.0f,0.0f); tVector emitterforces= GRAVITY; //vmake(0,gravityForce); updateEmitter( myEmmiter, emitterforces, dt); applyDeflectors(myEmmiter); renderParticles(myEmmiter); SYS_Show(); start_tick= GetTickCount(); // Keypress! const float scale=2.0f; if (SYS_KeyPressed('O')) { if(cursor)cursor->pos.x-=1.0f*scale; } if (SYS_KeyPressed('P')) { if(cursor)cursor->pos.x+=1.0f*scale; } if (SYS_KeyPressed('Q')) { if(cursor)cursor->pos.y+=1.0f*scale; } if (SYS_KeyPressed('A')) { if(cursor)cursor->pos.y-=1.0f*scale; } if (SYS_KeyPressed('S')) { atractorScale*=1.1f; if( atractorScale > 1000.0f)atractorScale=1000.0f; } if (SYS_KeyPressed('W')) { atractorScale*=0.9f; } // Keep system running SYS_Pump(); SYS_Sleep(17); } CORE_UnloadBmp(texsmallball); CORE_UnloadBmp(texcursor); destroyEmmmiter(myEmmiter); destroyParticlePool(); destroyCursor(); return 0; }
void View3D::initializeGL() { // GLEW has a problem with core contexts. It calls glGetString(GL_EXTENSIONS), // which causes GL_INVALID_ENUM on GL 3.2+ core context as soon as glewInit() is called. // It also doesn't fetch the function pointers. The solution is for GLEW to use glGetStringi instead. // The current version of GLEW is 1.10.0 but they still haven't corrected it. // The only fix is to use glewExperimental for now. // https://www.opengl.org/wiki/OpenGL_Loading_Library glewExperimental = true; if (glewInit() != GLEW_OK) { g_logger.error("%s", "Failed to initialize GLEW"); m_badOpenGL = true; return; } g_logger.info("OpenGL implementation:\n" "GL_VENDOR = %s\n" "GL_RENDERER = %s\n" "GL_VERSION = %s\n" "GLSL_VERSION = %s\n" "GLEW_VERSION = %s\n", (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER), (const char*)glGetString(GL_VERSION), (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), (const char*)glewGetString(GLEW_VERSION)); // GL_CHECK has to be defined for this to actually do something glCheckError(); initCursor(10, 1); initAxes(); initGrid(2.0f); glCheckError(); m_boundingBoxShader.reset(new ShaderProgram()); m_boundingBoxShader->setShaderFromSourceFile("shaders:bounding_box.glsl"); m_meshFaceShader.reset(new ShaderProgram()); m_meshFaceShader->setShaderFromSourceFile("shaders:meshface.glsl"); m_meshEdgeShader.reset(new ShaderProgram()); m_meshEdgeShader->setShaderFromSourceFile("shaders:meshedge.glsl"); double dPR = getDevicePixelRatio(); int w = width() * dPR; int h = height() * dPR; m_incrementalFramebuffer = allocIncrementalFramebuffer(w, h); glFrameBufferStatus(m_incrementalFramebuffer); glCheckError(); const GeometryCollection::GeometryVec& geoms = m_geometries->get(); for (size_t i = 0; i < geoms.size(); ++i) { if (m_boundingBoxShader->isValid()) { // TODO: build a shader manager for this geoms[i]->setShaderId("boundingbox", m_boundingBoxShader->shaderProgram().programId()); geoms[i]->setShaderId("meshface", m_meshFaceShader->shaderProgram().programId()); geoms[i]->setShaderId("meshedge", m_meshEdgeShader->shaderProgram().programId()); geoms[i]->initializeGL(); } } // FIXME: Do something about this mess. The shader editor widget needs to // be initialized with the default shader, but View3D can only compile // shaders after it has a valid OpenGL context. PointViewerMainWindow * pv_parent = dynamic_cast<PointViewerMainWindow *>(parentWidget()); pv_parent->openShaderFile("shaders:las_points.glsl"); setFocus(); }
int main() { //SD device initialization up_dev.device_reference = NULL; while(!loadSDCard(up_dev.device_reference)) { printf("SD card is not connected.\n"); } initVGA(); initAudioDeviceController(); initSoundMixer(); struct CmdScheduler* scheduler = initCmdScheduler(); //Serial device initialization com = initRS232(scheduler); initPushKeyController(); initDatabase(); initMemory(); //sync database update(); //Test VGA Output /*struct Image* testImg; while((testImg = loadSDImage("TEST.BMP")) == NULL); draw(35, 35, testImg); killImage(testImg);*/ //alt_up_char_buffer_string(char_buffer, "Initialization Completed", 27, 5); alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0); alt_up_char_buffer_clear(char_buffer); //graphicTester(); struct Frame* mainFrame = initMainFrame(); mainFrame->drawFrame(mainFrame); //Test End mouse = initCursor(10, 100, mainFrame); //graphicTester(); //drawAllSongsInList(2); //drawAllSongsInList(2); /*int i; struct Frame* b; for (i = 0; i < 5000; i++){ drawAllSongsInList(2); //b = initSongInListPanel(mainFrame, 2); //killSongInListPanel(&b); printf("Iteration %d\n", i); }*/ initAudioBuffer(); initAnimate(mouse); int i = 2; syncPlay(1, 100, 0); while(1) { cmdProcessing(scheduler); i = soundTester(i); } return 0; }
int initGame(SDL_Surface* screen) { if(player()->gameStarted) { printf("ERROR: Called init when a game was running\n"); return(0); } //Only load the back-image once. if( !ptrRestart ) { ptrRestart = loadImg( DATADIR"data/ptr-restart.png" ); ptrRestartRect.x=HSCREENW-160; ptrRestartRect.w=ptrRestartRect.x+ptrRestart->w; ptrRestartRect.y=HSCREENH+120-ptrRestart->h; ptrRestartRect.h=ptrRestartRect.y+ptrRestart->h; } debugNumInit++; initCursor(&cur); restartConfirm=0; //Read info's for level. (this is done instead of using the one in packInfo so it don't need resetting) pf.levelInfo = mkLevelInfo( player()->levelFile ); if(!loadField(&pf, player()->levelFile )) { printf("Error: Couldn't init playfield.\n"); return(0); } if(!initDraw(pf.levelInfo,screen)) { printf("Error: Couldn't init graphics.\n"); return(0); } char* buf = malloc(sizeof(char)*128); sprintf(buf, "themes/%s",pf.levelInfo->soundDir); loadSamples( buf, levelInfo( player()->level)->musicFile ); //Load samples from sounddir, note we use the levelInfo from packInfo for the music since the playlist is hacked onto that. free(buf); txtLoadGameCharSet( pf.levelInfo->fontName ); pf.levelInfo->time *= 1000; //Convert seconds to ms countdown=500; countdownSeconds=3; gameState=GAMESTATECOUNTDOWN; player()->gameStarted=1; //Clear player stats memset( &player()->hsEntry, 0, sizeof( hsEntry_t ) ); //Set the levelNum player()->hsEntry.levelNum = player()->level; startStopImg=0; if(pf.levelInfo->startImg) { gameState=GAMESTATESTARTIMAGE; } //We also simulate the first switch tick here so all looks right at the countdown. switchUpdateAll( &pf ); justWon=0; return(1); }
/* * Main Game Loop */ int main() { // Use the name of your pixel buffer DMA core pixel_buffer =alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer_dma_0"); initVGA(); usleep(5000000); ps2 = alt_up_ps2_open_dev("/dev/ps2_0"); ps2->timeout = 2000000; alt_up_ps2_clear_fifo(ps2); alt_up_ps2_init(ps2); unsigned char byte1; while(alt_up_ps2_read_data_byte(ps2, &byte1)!=0); char_lcd_dev = alt_up_character_lcd_open_dev ("/dev/character_lcd_0"); alt_up_character_lcd_init (char_lcd_dev); char_buffer = alt_up_char_buffer_open_dev("/dev/char_drawer"); alt_up_char_buffer_init(char_buffer); alt_up_sd_card_dev *device_reference = NULL; struct Env* p = initEnv(); initGameInfo(); struct Collidable* collisionChecker = initCollidable(); addCollisionToEnv(p, collisionChecker); promptSDcard(p, device_reference); usleep(1000); alt_up_char_buffer_string(char_buffer, "Loading ", 40, 30); unsigned end_time, start_time; int count = 0; lock = 0; struct animation* starAnimation = loadSDImageSeq("ST0.BMP", 2, 8); struct animation* star2Animation = loadSDImageSeq("ST00.BMP", 3, 7); struct animation* alien0 = loadSDImageSeq("A100.BMP", 2, 2); //2 images where first 2 characters are prefix struct animation* alien1 = loadSDImageSeq("A000.BMP", 2, 15); struct animation* ship0 = loadSDImageSeq("S00.BMP", 2, 16); struct animation* ship1 = loadSDImageSeq("S10.BMP", 2, 27); struct animation* bossAnimate = loadSDImageSeq("BO00.BMP", 2, 28); struct animation* ship2 = loadSDImageSeq("S20.BMP", 2, 35); struct animation* ship3 = loadSDImageSeq("S30.BMP", 2, 30); struct animation* ship4 = loadSDImageSeq("S40.BMP", 2, 10); struct animation* explode1 = initAnimation((int*)explode01, 1); addImage(explode1, initAnimation((int*)explode02, 0)); addImage(explode1, initAnimation((int*)explode03, 0)); addImage(explode1, initAnimation((int*)explode04, 0)); addImage(explode1, initAnimation((int*)explode05, 0)); struct animation** shipAnimationCollection = (struct animation**)malloc(sizeof(struct animation*)*5); shipAnimationCollection[0] = ship0; shipAnimationCollection[1] = ship1; shipAnimationCollection[2] = ship2; shipAnimationCollection[3] = ship3; shipAnimationCollection[4] = ship4; initWeapon(collisionChecker, p); struct Cursor* mouse = initCursor(p, collisionChecker); addToEnv(p, mouse->super); addObjToCollide(collisionChecker, mouse->super); setCursor(p, mouse); struct KeyController* keyController = initKeyController(); struct SwitchController* switchController = initSwitchController(); struct CursorController* ctrl = initCursorController(mouse->super, switchController, keyController); alt_up_char_buffer_string(char_buffer, "Loading Sounds ", 30, 30); audioController = initAudioController(); loadSound( audioController, LOOP_ONE ); loadSound( audioController, LASER_SOUND ); alt_irq_register(AUDIO_IRQ, audioController, (void*) audio_ISR); alt_irq_enable(AUDIO_IRQ); play_background_loop( audioController, LOOP_ONE ); enableAudioController( audioController ); printhex(info.score); mainMenu(mouse, ctrl, p); disableAudioController(audioController); stop_background_loop(audioController); unloadSoundById(audioController, LASER_SOUND); unloadSoundById(audioController, LOOP_ONE); alt_up_char_buffer_string(char_buffer, "Loading Sounds ", 30, 30); //loadSound(audioController, WIN_SOUND); //loadSound(audioController, LOSE_SOUND); loadSound( audioController, TOWER_UPGRADE_SOUND ); loadSound( audioController, LOOP_TWO ); play_background_loop(audioController, LOOP_TWO); enableAudioController( audioController ); alt_up_char_buffer_clear(char_buffer); //usleep(1000); struct Alien* testAlienCollection[60]; gameSetup(p, shipAnimationCollection, mouse, starAnimation, star2Animation); usleep(500000); //time delay for panel to be drawn // char LPS[50]; float lps_; int n = 0; for(n = 0; n < 20; n++) { testAlienCollection[n] =initAlien(n, 10*n, 10, alien0, explode1, "IdontKnow", 1.4, 150, 500, collisionChecker); addToEnvNR(p, testAlienCollection[n]->super); } for(n = 0; n < 20; n++) { testAlienCollection[n+20] =initAlien(10*n, n, 10, alien1, explode1, "whatName", 1.4, 190, 850, collisionChecker); addToEnvNR(p, testAlienCollection[n+20]->super); } for(n = 0; n < 20; n++) { testAlienCollection[n+40] =initAlien(10*n, n, 20, bossAnimate, explode1, "IamBoss", 1.6, 800, 1500, collisionChecker); testAlienCollection[n+40]->score = 300; addToEnvNR(p, testAlienCollection[n+40]->super); } int stage = 0; /* * Game Starts!!!!!! */ alt_alarm_start (&alarm,alt_ticks_per_second(),my_alarm_callback,(void*)p); int startTimer = 0; char second_row1[15]; alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1); sprintf(second_row1, "wave# %d ", stage); alt_up_character_lcd_string(char_lcd_dev, second_row1); while(1) { alt_timestamp_start(); start_time = (unsigned)alt_timestamp(); /*-----------------------------------------------------------------------------------------------*/ checkCollision(collisionChecker); //a major function that check each collision happen between each object updateCursorController(ctrl, 1); count++; if (startTimer > count) info.startButton = false; else { if(stage == 7) info.isWin = true; else if(startTimer == count){ //play_background_loop(audioController, LOOP_TWO); enableAudioController( audioController ); } } if (info.startButton){ disableAudioController(audioController); //stop_background_loop(audioController); startTimer = count + 15000; checkStages(testAlienCollection, stage%7, collisionChecker); stage++; //if(stage > 6) stage = 0; info.startButton = false; alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1); sprintf(second_row1, "wave# %d ", stage); alt_up_character_lcd_string(char_lcd_dev, second_row1); } if(info.isEnd || info.isWin) { disableAudioController(audioController); stop_background_loop(audioController); endGame(testAlienCollection, collisionChecker, p, mouse, ctrl, keyController); } /*-----------------------------------------------------------------------------------------------*/ end_time = (unsigned)alt_timestamp(); lps_ = (float)alt_timestamp_freq()/(float)(end_time - start_time); sprintf(LPS, "The current LPS is %.2f", lps_); alt_up_char_buffer_string(char_buffer, LPS, 3, 2); } return 0; }
int Main(void) { // Load resources texsmallball = CORE_LoadBmp("data/tyrian_ball.32.bmp" , false); texcursor = CORE_LoadBmp("data/cursor.bmp", false); initCursor(); initParticlePool(MAX_PARTICLES); //checking pool //while(particlePool.current) //{ // particlePool.current=particlePool.current->next; //} //particlePool.current = particlePool.head->next; initEmmiter(); //for (int i = 0; i < NUM_PARTICLES; i++) //{ //float radius; //radius = 8.f; //particle[i]=particlePool.current; //particlePool.current=particlePool.current->next; //particle[i]->radius = radius; //particle[i]->mass = 1.f; //particle[i]->index = texsmallball; //particle[i]->pos = vmake(CORE_FRand(radius, SCR_WIDTH-radius), CORE_FRand(radius, SCR_HEIGHT-radius)); //particle[i]->vel = vmake(CORE_FRand(-MAX_BALL_SPEED, +MAX_BALL_SPEED), CORE_FRand(-MAX_BALL_SPEED, +MAX_BALL_SPEED)); //} // Set up rendering glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT); // Sets up clipping glClearColor( 0.0f, 0.1f, 0.3f, 0.0f ); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho( 0.0, SCR_WIDTH, 0.0, SCR_HEIGHT, 0.0, 1.0); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DWORD start_tick= GetTickCount(); while (!SYS_GottaQuit()) { // Render glClear( GL_COLOR_BUFFER_BIT ); CORE_RenderCenteredSprite(cursor->pos, vmake(cursor->radius , cursor->radius ), cursor->index); //fixed substep float dt =1.0f/(substep*FPS); //adaptive substep //DWORD elapsed_ticks= GetTickCount()- start_tick; //float elapsed_dt= elapsed_ticks/TICKS_PER_SECOND; //float edt_dt = elapsed_dt/dt; //int ite = (int)edt_dt; //float lastdt= edt_dt - ite; tVector forces=vmake(0,-100.0f); // for( int i=0; i < ite; i++) updateEmitter( myEmmiter, forces, dt); // updateEmitter( myEmmiter, forces, lastdt); applyDeflectors(myEmmiter); renderParticles(myEmmiter); SYS_Show(); start_tick= GetTickCount(); // Keypress! if (SYS_KeyPressed('O')) { if(cursor)cursor->pos.x-=1.0f;; } if (SYS_KeyPressed('P')) { if(cursor)cursor->pos.x+=1.0f;; } if (SYS_KeyPressed('Q')) { if(cursor)cursor->pos.y+=1.0f;; } if (SYS_KeyPressed('A')) { if(cursor)cursor->pos.y-=1.0f;; } if (0)//SYS_KeyPressed('I')) { //start single ball at random float radius=16.f; GLuint texBall=texsmallball; float mass=1.0f; int index=(int)CORE_FRand(0, MAX_PARTICLES-1); //particle[index]->mass = mass; //particle[index]->index = texBall; //particle[index]->radius = radius; // particle[index]->pos = vmake(CORE_FRand(radius, SCR_WIDTH-radius), CORE_FRand(SCR_HEIGHT*.5f, SCR_HEIGHT-radius)); //particle[index]->vel = vmake(0, 10); } if (0)//SYS_KeyPressed(' ')) { //give an impulse to all balss // for (int i = 0; i < MAX_PARTICLES; i++) // { //if (fabs(particle[i]->vel.x) < 0.1f) // particle[i]->vel.x = CORE_FRand(-MAX_BALL_SPEED, +MAX_BALL_SPEED); //particle[i]->vel.y = CORE_FRand(0, JUMP_SPEED); // } } if (0)//SYS_KeyPressed(VK_CONTROL)) { //reset all glClear( GL_COLOR_BUFFER_BIT ); // for (int i = 0; i < MAX_PARTICLES; i++) // { //float radius=particle[i]->radius; //particle[i]->pos = vmake(CORE_FRand(radius, SCR_WIDTH-radius), CORE_FRand(radius, SCR_HEIGHT-radius)); //particle[i]->vel = vmake(0, 10); // } SYS_Show(); } // Keep system running SYS_Pump(); SYS_Sleep(17); } CORE_UnloadBmp(texsmallball); CORE_UnloadBmp(texcursor); destroyEmmmiter(myEmmiter); destroyParticlePool(); destroyCursor(); return 0; }
/*ARGSUSED*/ int main(int argc, char *argv[]) { XEvent ev; XGCValues gv; XSetWindowAttributes attr; (void) argc; argv0 = argv[0]; /* Open a connection to the X server. */ dpy = XOpenDisplay(""); if (dpy == 0) Panic("can't open display."); get_resources(); /* Find the screen's dimensions. */ display_width = DisplayWidth(dpy, DefaultScreen(dpy)); display_height = DisplayHeight(dpy, DefaultScreen(dpy)); /* Set up an error handler. */ XSetErrorHandler(ErrorHandler); /* Get the pixel values of the only two colours we use. */ black = BlackPixel(dpy, DefaultScreen(dpy)); white = WhitePixel(dpy, DefaultScreen(dpy)); /* Get font. */ font = XLoadQueryFont(dpy, font_name); if (font == 0) font = XLoadQueryFont(dpy, "fixed"); if (font == 0) Panic("can't find a font."); /* Get a cursor. */ initCursor(); /* Create the window. */ root = DefaultRootWindow(dpy); attr.override_redirect = True; attr.background_pixel = white; attr.border_pixel = black; attr.cursor = mouse_cursor; attr.event_mask = ExposureMask | VisibilityChangeMask | ButtonMotionMask | PointerMotionHintMask | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask; window = XCreateWindow(dpy, root, 0, 0, display_width, 1.2 * (font->ascent + font->descent), 0, CopyFromParent, InputOutput, CopyFromParent, CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWCursor | CWEventMask, &attr); /* Create GC. */ gv.foreground = black; gv.background = white; gv.font = font->fid; gc = XCreateGC(dpy, window, GCForeground | GCBackground | GCFont, &gv); /* Create the menu items. */ readMenu(); /* Bring up the window. */ XMapRaised(dpy, window); /* Make sure all our communication to the server got through. */ XSync(dpy, False); /* The main event loop. */ for (;;) { getEvent(&ev); dispatch(&ev); } }