void onOnceBeforeDraw() override { fTypeface = SkTypeface::MakeFromFile("/skimages/samplefont.ttf"); initChars(); }
/* Main Function */ int main( int argc, char *argv[] ) { //Color constants' initilizations BLACK = makeColour( 0, 0, 0 ); WHITE = makeColour(63,63,63 ); RED = makeColour(63, 0, 0 ); GREEN = makeColour( 0,63, 0 ); BLUE = makeColour( 0, 0,63 ); //Initializations initInterrupts(); initScreen(); initChars(); //Enable Interrupts enableBalloonIRQ(1000*ONE_MS, balloonISR ); int keys_to_watch = 0x04 | 0x02 ; enableKeyIRQ( keys_to_watch, keyISR ); // fillScreen(BLACK); int i = 0; welcomeMessage(); mouse_status = resetPS2(); int left, right; int lastTime; while(1) { //in case of losing (past 20 misses) if(missed >= MAX_MISS) { disableInterrupt(IRQ_COUNTER); fillScreen(RED); emptyScreen(); printStr(10, 10, "Too many misses..."); printStr(14, 13, "GAME OVER!"); printStr(8, 16, "Press KEY2 to restart"); for(i = 0; i < 30000000; i++); // while(missed >= 20); // printStr(8, 20, "HOOOOOORAY"); enableInterrupt(IRQ_COUNTER); printStr(10, 10, " "); printStr(14, 13, " "); printStr(8, 16, " "); } drawChar (1, 6, ' '); disableInterrupt(IRQ_COUNTER); if (*pSWITCH != 0) { if (*pSWITCH&1) { increment = 1; circleRad = 30; } else if (*pSWITCH&2) { increment = 2; circleRad = 20; } else if (*pSWITCH&4) { increment = 3; circleRad = 15; } } else { increment = 1; circleRad = 30; } enableInterrupt(IRQ_COUNTER); /// MUSIC PLAYER /// // drawChar (1, 5, 16); if(musicCounter == 0) { left = 0; right = 1; } if(musicCounter < musicLength/4) { i = musicCounter; for(i; i<musicCounter+200; i++) { playMusic(music[left], music[right]); left+=2; right+=2; } musicCounter += 200; } else { musicCounter = 0; left = 0; right = 1; } /// MUSIC /// if ( mouse_status == PS2_MOUSE ) { // drawChar (1, 5, 22); if( getMouseMotion( &dxMouse, &dyMouse, &mouse_button ) ) { if( mouse_button & MOUSE_BUTTON1 ) { if(getColor(xMouse+1, yMouse) == RED) { score += increment; drawCircle(xCircle, yCircle, 30, BLACK); /// SOUND EFFECT /// int sleft = 0; int sright = 1; int i; for(i=0; i<effectLength/4; i++) { playMusic(effect[sleft], effect[sright]); sleft+=2; sright+=2; } sleft = 0; sright = 1; /// SOUND EFFECT /// } else { if(time != lastTime) { missed++; time = lastTime; } } } /* if( mouse_button & MOUSE_BUTTON2 ) fillScreen( BLACK ); if( mouse_button & MOUSE_BUTTON3 ) { printStr(17, 13, "PAUSED!"); disableInterrupts(IRQ_COUNTER); while( 1 ) { if( mouse_button & MOUSE_BUTTON2 ) { enableInterrupts(IRQ_COUNTER); printStr(17, 13, " "); break; } } } */ if(getColor(xMouse+1, yMouse) == RED) dragColor = RED; else dragColor = BLACK; drawPixel( xMouse, yMouse, dragColor ); xMouse += dxMouse; yMouse -= dyMouse; xMouse = max( 0, min( xMouse, MAX_X_PIXELS-1 ) ); yMouse = max( 0, min( yMouse, MAX_Y_PIXELS-1 ) ); drawPixel( xMouse, yMouse, WHITE ); //drawCursor(xMouse, yMouse); } } } return 0; }