// main function int main(void) { REG_DISPCTL = MODE3 | BG2_ENABLE; // REG_DISPCTL = 1027/0x0403 drawRect(0, 0, 240, 160, RGB(31, 31, 31)); //color1: white; drawRect while (1) { // draw UGLY GOOGLE // draw "G" drawRect(50, 40, 5, 5, RGB(0, 0, 31)); // color2: blue drawRect(45, 35, 5, 5, RGB(0, 0, 31)); drawRect(40, 20, 15, 5, RGB(0, 0, 31)); drawRect(45, 15, 5, 5, RGB(0, 0, 31)); drawRect(50, 10, 5, 5, RGB(0, 0, 31)); drawRect(55, 5, 5, 30, RGB(0, 0, 31)); drawRect(85, 10, 5, 5, RGB(0, 0, 31)); drawRect(90, 15, 5, 5, RGB(0, 0, 31)); drawRect(95, 20, 15, 5, RGB(0, 0, 31)); drawRect(90, 35, 5, 5, RGB(0, 0, 31)); drawRect(80, 40, 5, 15, RGB(0, 0, 31)); drawRect(75, 30, 20, 5, RGB(0, 0, 31)); // draw "OO" drawHollowRect(65, 55, 30, 35, RGB(31, 0, 0)); // color3: red; drawHollowRect drawHollowRect(65, 90, 30, 35, RGB(31, 21, 0)); // color4: orange // draw 'g' drawHollowRect(65, 125, 20, 20, RGB(0, 0, 31)); setPixel(64, 145, RGB(0, 0, 31)); // setPixel setPixel(64, 146, RGB(0, 0, 31)); setPixel(64, 147, RGB(0, 0, 31)); setPixel(63, 148, RGB(0, 0, 31)); plotLine(145, 85, 150, 100, RGB(0, 0, 31)); // plotLine drawHollowRect(90, 125, 26, 15, RGB(0, 0, 31)); // draw 'l' drawRect(40, 160, 5, 60, RGB(0, 31, 0)); // color5: green // draw 'e' drawRect(80, 180, 25, 5, RGB(31, 0, 0)); drawRect(75, 200, 5, 5, RGB(31, 0, 0)); drawRect(70, 195, 5, 5, RGB(31, 0, 0)); drawRect(65, 190, 5, 5, RGB(31, 0, 0)); drawRect(70, 185, 5, 5, RGB(31, 0, 0)); drawRect(75, 180, 5, 5, RGB(31, 0, 0)); drawRect(85, 180, 5, 15, RGB(31, 0, 0)); drawRect(95, 185, 20, 5, RGB(31, 0, 0)); } }
/** Attempt at recursively drawing hollow rectangles to create a larger shape. **/ void recursiveFun(int r, int c, int width, int height, u16 color) { if (width >= 2) { drawHollowRect(r, c, height, width, color); recursiveFun(r+1, c, height - 2, width/2, color); recursiveFun(r, c+1, height - 2, width/2, color); } }
void drawSpaceship(int r, int c, int size) { drawRect(r + 17, c, 3, 3, RED); // Left Corner drawRect(r + 17, c + 17, 3, 3, RED); // Right corner drawRect(r + 13, c + 2, size - 4 , size - 15, WHITE); // Main body drawRect(r + 5, c + 4, size - 8, size - 12, WHITE); drawRect(r + 4, c + 5, 2, 5, BLACK); drawRect(r + 4, c + 13, 2, 5, BLACK); drawRect(r + 2, c + 8, 4, 4, WHITE); drawRect(r + 6, c + 7, 6, 1, WHITE); drawRect(r, c + 9, 2, 2, BLUE); drawRect(r + 16, c + 6, 8, 2, BLACK); drawHollowRect(r + 10, c + 7, 6, 4, BLACK); }
void drawChooser(Choice choice) { drawHollowRect(choice.row - 1, choice.col - 1, STRWIDTH(strlen(choice.str)) + 2, STRHEIGHT + 2, YELLOW); }
int main(void) { SetMode(MODE_3 | BG2_ENABLE); fillScreen(BLACK); drawImage3(0, 0, STARTSCREEN_WIDTH, STARTSCREEN_HEIGHT, &startScreen[0]); int i = 1; while(i) { if(keyDown(KEY_START)) { i = 0; } } fillScreen(BLACK); int x = 120; int y = 60; int d = 0; int t = 20; int m = 10; int s = 0; int p = 0; int c = 1; u16 color = WHITE; drawHollowRect(0,0,SCREEN_WIDTH-1, SCREEN_HEIGHT-10, color); setPixel(x,y,color); while(c) { // Reset if(keyDown(KEY_SELECT)) { c = 0; main(); } // Set Direction if(keyDown(KEY_DOWN) && (d != 2)){ d = 0; } else if(keyDown(KEY_RIGHT) && (d != 3)) { d = 1; } else if(keyDown(KEY_UP) && (d != 0)) { d = 2; } else if(keyDown(KEY_LEFT) && (d != 1)) { d = 3; } // Move snake if(d==0) { y++; } else if(d==1) { x++; } else if(d==2) { y--; } else if(d==3) { x--; } // Check for collisions if(videoBuffer[OFFSET(x,y)] != BLACK) { fillScreen(BLACK); drawImage3(0, 0, GAMEOVER_WIDTH, GAMEOVER_HEIGHT, &gameOver[0]); drawImage3(100, 70, RETRY_WIDTH, RETRY_HEIGHT, &retry[0]); int i = 1; while(i) { if(keyDown(KEY_START)) { while(keyDown(KEY_START)) { } i = 0; } } c = 0; main(); } // Draw snake setPixel(x,y,color); delay(t); // Increase score s++; s = s%m; // Set Speed if(s == 0) { t--; m = m + m/3; drawRect(1 + p,152,2,6,WHITE); p = p + 4; } // Wait for V blank waitForVblank(); } return 0; }
int main() { REG_DISPCNT = MODE3 | BG2_ENABLE; pl.y = 80; pl.oldy = pl.y; pl.x = 0; h2.x = 2; h2.oldx = h2.x; h2.y = 0; g.x = 219; for(int i = 0; i < 7; i++) { BAN[i].isbanana = 0; ENEMY[i].isenemy = 0; } while(!KEY_DOWN_NOW(BUTTON_START)) { drawImageSpray(0,0,160,240,bg); } drawRect(0,0,160,240,WHITE); gameon = 1; while(1) { if(gameon == 1) { drawBanana(); drawEnemy(); drawHeart(); drawImageSpray(0,219,20,20,monkeyW); drawHollowRect(0,0,20,239,RED); drawRect(pl.oldy,0,20,20,WHITE); drawImageSpray(pl.y,0,20,20,monkey); pl.oldy= pl.y; h2.oldx = h2.x; if(KEY_DOWN_NOW(BUTTON_UP)) { if(pl.y > 22) { pl.y = pl.y - 2; } } if(KEY_DOWN_NOW(BUTTON_DOWN)) { if(pl.y <= 138) { pl.y = pl.y + 2; } } if(h2.x <= 0) { gameon = 0; gameover(); } //if(h2.x >= 219) //{ // gameon = 0; //} waitForVblank(); colMonLog(); colMonBan(); colMonGoal(); } } }