void byoSnake::OnPaint(wxPaintEvent& event) { wxSize size = GetClientSize(); wxBitmap buffer(wxImage(size.GetWidth(),size.GetHeight())); wxBufferedPaintDC DC(this,buffer); DrawBorder(&DC); DrawSnake(&DC); DrawApple(&DC); DrawStats(&DC); }
void display() { glClear(GL_COLOR_BUFFER_BIT); DrawField(); DrawSnake(); for (int i=0;i<10;i++) m[i].DrawApple(); glFlush(); glutSwapBuffers(); }
WORD GOLDrawCallback( void ) { unsigned char i; OBJ_HEADER *pObject; extern unsigned int trip[NUM_TOUCHPADS]; switch (screenState) { case SCREEN_BOARD_TEST: PerformBoardTest(); break; case SCREEN_DISPLAY_MAIN: ShowScreenMain(); displayChangeTime = tick; screenState = SCREEN_MAIN; break; case SCREEN_MAIN: RTCCProcessEvents(); if (previousSecond != _time_str[11]) { previousSecond = _time_str[11]; strcpy( pageInformation.instructions, _date_str ); strcat( pageInformation.instructions, " " ); strcat( pageInformation.instructions, _time_str ); pObject = GOLFindObject( ID_INSTRUCTIONS ); StSetText( (STATICTEXT *)pObject, pageInformation.instructions ); SetState( pObject, ST_DRAW ); } break; case SCREEN_DISPLAY_FLASH: ShowScreenFlash(); displayChangeTime = tick; screenState = SCREEN_FLASH; break; case SCREEN_FLASH: FlashMonitorMedia(); break; case SCREEN_DISPLAY_FLASH_ERROR: ShowScreenFlashError(); displayChangeTime = tick; screenState = SCREEN_FLASH_ERROR; break; case SCREEN_FLASH_ERROR: break; case SCREEN_DISPLAY_GAMES: ShowScreenGames(); displayChangeTime = tick; screenState = SCREEN_GAMES; break; case SCREEN_GAMES: break; case SCREEN_DISPLAY_SNAKE: ShowScreenSnake(); displayChangeTime = tick; screenState = SCREEN_SNAKE; break; case SCREEN_SNAKE: DrawSnake(); break; case SCREEN_DISPLAY_SNAKE_SCORE: ShowScreenScore(); displayChangeTime = tick; screenState = SCREEN_SNAKE_SCORE; break; case SCREEN_SNAKE_SCORE: break; case SCREEN_DISPLAY_BLASTER: ShowScreenBlaster(); // Set the touchpad sensitivity for quicker game play. for (i=0; i<NUM_TOUCHPADS; i++) { trip[i]=TRIP_VALUE_BLASTER; } displayChangeTime = tick; screenState = SCREEN_BLASTER; break; case SCREEN_BLASTER: DrawBlaster(); break; case SCREEN_DISPLAY_BLASTER_SCORE: ShowScreenScore(); // Reset the touchpad sensitivity to normal. for(i=0; i<NUM_TOUCHPADS; i++) { trip[i]=TRIP_VALUE; } displayChangeTime = tick; screenState = SCREEN_BLASTER_SCORE; break; case SCREEN_BLASTER_SCORE: break; case SCREEN_DISPLAY_SHAPELET: ShowScreenShapelet(); displayChangeTime = tick; screenState = SCREEN_SHAPELET; break; case SCREEN_SHAPELET: break; case SCREEN_DISPLAY_SHAPELET_SCORE: ShowScreenScore(); displayChangeTime = tick; screenState = SCREEN_SHAPELET_SCORE; break; case SCREEN_SHAPELET_SCORE: break; case SCREEN_DISPLAY_DEMOS: ShowScreenDemos(); displayChangeTime = tick; screenState = SCREEN_DEMOS; break; case SCREEN_DEMOS: break; case SCREEN_DISPLAY_RGB: ShowScreenRGB(); displayChangeTime = tick; screenState = SCREEN_RGB; break; case SCREEN_RGB: break; case SCREEN_DISPLAY_GRAPH: ShowScreenGraph(); displayChangeTime = tick; screenState = SCREEN_GRAPH; break; case SCREEN_GRAPH: UpdateGraph(); break; case SCREEN_DISPLAY_CAPTURE_MEDIA: ShowScreenCaptureMedia(); displayChangeTime = tick; screenState = SCREEN_CAPTURE_MEDIA; break; case SCREEN_CAPTURE_MEDIA: CaptureMonitorMedia(); break; case SCREEN_DISPLAY_CAPTURE: ShowScreenCapture(); displayChangeTime = tick; screenState = SCREEN_CAPTURE; break; case SCREEN_CAPTURE: UpdateGraph(); CaptureMonitorMedia(); break; case SCREEN_DISPLAY_UTILITIES: ShowScreenUtilities(); displayChangeTime = tick; screenState = SCREEN_UTILITIES; break; case SCREEN_UTILITIES: break; case SCREEN_DISPLAY_TIME: ShowScreenTime(); displayChangeTime = tick; screenState = SCREEN_TIME; break; case SCREEN_TIME: break; case SCREEN_DISPLAY_CTMU: ShowScreenCTMU(); displayChangeTime = tick; screenState = SCREEN_CTMU; break; case SCREEN_CTMU: CalibrateCTMU(); break; case SCREEN_DISPLAY_BAR_DEMO: ShowScreenBarDemo(); displayChangeTime = tick; screenState = SCREEN_BAR_DEMO; break; case SCREEN_BAR_DEMO: DrawBarDemo(); break; } return 1; // Callback complete }
/**************************************************************************** Function: WORD GOLDrawCallback( void ) Description: This callback is performed at the beginning of the GOLDraw() function. Processing that needs to be done on a regular basis and is not triggered by a message should be done here. Precondition: None Parameters: None Returns: None Remarks: All graphic control adding and removing must be done from this function, not from the message callback. ***************************************************************************/ WORD GOLDrawCallback( void ) { switch (screenState) { // Display Start-up screen and play Welcome message case SCREEN_START: // Display the start up screen PictCreate( ID_ICON, // ID 0,0,GetMaxX(),GetMaxY(), // dimension PICT_DRAW, // will be displayed, has frame 1, // scale factor is x1 picture, // bitmap NULL ); // default GOL scheme screenState = SCREEN_START_DELAY; break; case SCREEN_START_DELAY: if(enableSoundFlag) { while(speakerBusy()); // Speaker: Welcome to MPLAB Starter Kit for PIC24H MCU Demonstration speakerActivate(SPEECH_ADDR_WELCOME, SPEECH_SIZE_WELCOME); Delay(6000); } // Initialize the reference timer TickInit(); // Initialize the accelerometer AccelerometerInit(); screenState = SCREEN_DISPLAY_MAIN; break; // Display Main screen case SCREEN_DISPLAY_MAIN: ShowScreenMain(); screenState = SCREEN_MAIN; displayChangeTime = tick; break; case SCREEN_MAIN: break; // Display Accelerometer Tri-axial Outputs graph case SCREEN_DISPLAY_GRAPH: ShowScreenGraph(); screenState = SCREEN_GRAPH; displayChangeTime = tick; break; case SCREEN_GRAPH: AccelerometerStop(); UpdateGraph(); break; // Display connect External Sensor information case SCREEN_DISPLAY_ES_INFO: ShowScreenESInfo(); screenState = SCREEN_ES_INFO; displayChangeTime = tick; break; case SCREEN_ES_INFO: Delay(2000); screenState = SCREEN_DISPLAY_ES_GRAPH; break; // Display External Sensor output graph case SCREEN_DISPLAY_ES_GRAPH: AccelerometerStop(); ShowScreenESGraph(); initESADC(); screenState = SCREEN_ES_GRAPH; displayChangeTime = tick; break; case SCREEN_ES_GRAPH: UpdateESGraph(); break; // Display Orientation screen case SCREEN_DISPLAY_ORIENTATION: ShowScreenOrientation(); screenState = SCREEN_ORIENTATION; displayChangeTime = tick; break; case SCREEN_ORIENTATION: UpdateOrientation(); break; // Display Games screen case SCREEN_DISPLAY_GAMES: ShowScreenGames(); screenState = SCREEN_GAMES; displayChangeTime = tick; break; case SCREEN_GAMES: break; // Display Bomber Jet screen case SCREEN_DISPLAY_JET: ShowScreenJet(); AccelerometerStop(); AccelerometerInit(); if(enableSoundFlag) { while(speakerBusy()); speakerActivate(SPEECH_ADDR_START, SPEECH_SIZE_START); while(speakerBusy()); } screenState = SCREEN_JET; displayChangeTime = tick; break; case SCREEN_JET: DrawJet(); break; // Display Snake screen case SCREEN_DISPLAY_SNAKE: ShowScreenSnake(); AccelerometerStop(); AccelerometerInit(); if(enableSoundFlag) { while(speakerBusy()); speakerActivate(SPEECH_ADDR_START, SPEECH_SIZE_START); while(speakerBusy()); } screenState = SCREEN_SNAKE; displayChangeTime = tick; break; case SCREEN_SNAKE: DrawSnake(); break; // Display Score screen case SCREEN_DISPLAY_SCORE: ShowScreenScore(); if(enableSoundFlag) { while(speakerBusy()); speakerActivate(SPEECH_ADDR_GAME, SPEECH_SIZE_GAME); while(speakerBusy()); speakerActivate(SPEECH_ADDR_OVER, SPEECH_SIZE_OVER); } displayChangeTime = tick; screenState = SCREEN_SCORE; break; case SCREEN_SCORE: break; } return 1; // Callback complete }