void PlayerBrowser::draw(){ s8 i = 0; PA_SetBrightness(0, -31); // all black PA_SetBrightness(1, -31); // all black PA_ResetSpriteSys(); PA_Init16cBg(1, 0); PA_Init16cBg(0, 0); PA_LoadTiledBg(1, 1, bgplayer1); PA_LoadTiledBg(0, 1, bgplayer0); PA_LoadSpritePal(0, 1, (void*)pbutton_Pal); PA_KeyboardOut(); PA_CreateSprite(0, TERM_SCREEN, (void*)term_Sprite, OBJ_SIZE_64X32, 1, 1, 0, 0); PA_CreateSprite(0, PLAYERS_SCREEN, (void*)players_Sprite, OBJ_SIZE_64X32, 1, 1, 64, 0); PA_CreateSprite(0, GAMES_SCREEN, (void*)games_Sprite, OBJ_SIZE_64X32, 1, 1, 128, 0); PA_CreateSprite(0, OPTIONS_SCREEN, (void*)options_Sprite, OBJ_SIZE_64X32, 1, 1, 192, 0); PA_SetSpriteAnim(0, 11, 1); for(i = -31; i < 0 ; i++){ PA_SetBrightness(0, i); PA_SetBrightness(1, i); PA_WaitForVBL(); } PA_16cText(0, 6, 85, 80, 95, "NAMEXXXXXX", 1, 1, 100); PA_16cText(0, 88, 85, 127, 95, "[12k*]", 1, 1, 100); PA_16cText(0, 128, 85, 136, 95, "X", 1, 1, 100); PA_16cText(0, 6, 95, 80, 115, "NAMEXXXXXX", 1, 1, 100); PA_16cText(0, 88, 95, 127, 115, "[12k*]", 1, 1, 100); PA_16cText(0, 128, 95, 136, 115, "X", 1, 1, 100); }
// Fonction d'affichage du splashscreen void splash() { int i; // Timer //splash 1 : palib,devkitpro,"plus ou moins ds" PA_LoadBackground(1, 1, &splashtop); PA_LoadBackground(0, 1, &splashbottom); fonduentree(); for (i = 0; i < 60*3; i++) { if(Pad.Newpress.A || Stylus.Newpress) break; PA_WaitForVBL(); } fondusortie(); PA_ResetBgSys(); PA_ResetSpriteSys(); }
void PA_Init2D(void){ // Turn on the screens and 2D cores and switch to mode 0 powerON(POWER_ALL); // POWER_CR = POWER_ALL_2D; REG_POWERCNT &= ~SWITCH_SCREENS; // on s'assure que l'écran est bien /* VRAM_A_CR=VRAM_ENABLE|VRAM_A_MAIN_BG; VRAM_B_CR=VRAM_ENABLE|VRAM_B_MAIN_SPRITE; VRAM_C_CR=VRAM_ENABLE|VRAM_C_SUB_BG; VRAM_D_CR=VRAM_ENABLE|VRAM_D_SUB_SPRITE; */ videoSetMode( MODE_0_2D | DISPLAY_SPR_ACTIVE | //turn on sprites DISPLAY_SPR_1D | //this is used when in tile mode DISPLAY_SPR_1D_SIZE_128| DISPLAY_SPR_1D_BMP //and this in bitmap mode ); videoSetModeSub( MODE_0_2D | DISPLAY_SPR_ACTIVE | //turn on sprites DISPLAY_SPR_1D | //this is used when in tile mode DISPLAY_SPR_1D_SIZE_128| DISPLAY_SPR_1D_BMP //and this in bitmap mode ); // DISPLAY_CR = MODE_0_2D | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE|DISPLAY_SPR_1D_SIZE_128|DISPLAY_SPR_1D_BMP; // SUB_DISPLAY_CR = MODE_0_2D | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE|DISPLAY_SPR_1D_SIZE_128|DISPLAY_SPR_1D_BMP; vramSetMainBanks(VRAM_A_MAIN_SPRITE,VRAM_B_MAIN_BG_0x06000000,VRAM_C_SUB_BG,VRAM_D_SUB_SPRITE); // Sprite inits... PA_ResetSpriteSys(); // Init's the sprite system PA_InitSpriteExtPal(); // Init's sprite extended palettes PA_ResetBgSys(); PA_InitBgExtPal(); // Init's bg extended palettes // VBL Inits SpriteVBL = PA_UpdateSpriteVBL; }
//------------------------------------------------------------ //------------------------------------------------------------ void resetAllGraphics() { // reset everything Sprite::freeAllSprites(); PA_ResetSpriteSys(); #ifndef DEBUG PA_ResetBgSys(); // attempting to clear VRAM memset(VRAM_A, 0, 0x20000); memset(VRAM_B, 0, 0x40000); memset(VRAM_C, 0, 0x60000); memset(VRAM_D, 0, 0x80000); memset(VRAM_E, 0, 0x90000); memset(VRAM_F, 0, 0x94000); memset(VRAM_G, 0, 0x98000); memset(VRAM_H, 0, 0xA0000); memset(VRAM_I, 0, 0x98000); #endif }
void LAN() { PA_ResetBgSys(); PA_ResetSpriteSys(); PA_InitText(MAIN_SCREEN, 0); PA_SetTextCol(MAIN_SCREEN, 31, 31, 31); if(!IPC_Init()) { PA_OutputText(MAIN_SCREEN, 0, 0, "IPC INIT FAILED"); while(true) {} } IPC_SetChannelCallback(0, &LWIFI_IPC_Callback); PA_VBLFunctionInit(customVBL); // inits/preps DS <-> DS PA_OutputText(MAIN_SCREEN, 1, 3, "Start Game = Start/nJoin Game = Select"); fadeIn(); while(playernumber == -1) { if(!lobbyinited) { LOBBY_Init(); LOBBY_SetStreamHandler(0x0001, &receive); lobbyinited = true; } // inits liblobby else if(Pad.Newpress.Start) { playernumber = 0; LOBBY_SetOwnName("Host"); LOBBY_CreateRoom(ROOM_NAME, MAX_PLAYERS, GAME_CODE, GAME_VER); } // creates a new game else if(Pad.Newpress.Select) { playernumber = 1; LOBBY_SetOwnName("Client"); LOBBY_JoinRoom(LOBBY_GetRoomByGame(0, GAME_CODE)); } // joins a created game PA_WaitForVBL(); } int max = LOBBY_GetUsercountInRoom(LOBBY_GetRoomByUser(LOBBY_GetUserByID(USERID_MYSELF))); PA_OutputText(MAIN_SCREEN, 1, 3, " "); PA_OutputText(MAIN_SCREEN, 1, 4, " "); PA_OutputText(MAIN_SCREEN, 1, 3, "Waiting for connection"); while(max < 2) { max = LOBBY_GetUsercountInRoom(LOBBY_GetRoomByUser(LOBBY_GetUserByID(USERID_MYSELF))); PA_OutputText(MAIN_SCREEN, 1, 4, "%d", max); PA_WaitForVBL(); } players.push_back(new Kirby(512/2 -96 -32, 256/3 -32, 1, players, &display)); Stage stage = setStage(FINALDESTINATION); PA_InitText(MAIN_SCREEN, 1); // inits text on the main screen (displays time) PA_SetTextCol(MAIN_SCREEN, 31, 31, 31); // text color = white PA_OutputText(MAIN_SCREEN, 1, 3, " "); PA_OutputText(MAIN_SCREEN, 1, 4, " "); while(true) { if(playernumber == 0) { players[0] -> act(); dat[0] = (int)(players[0] -> x); dat[1] = (int)(players[0] -> y); dat[2] = PA_GetSpriteAnimFrame(MAIN_SCREEN, players[0] -> SPRITENUM); LOBBY_SendToUser(LOBBY_GetUserByID(0), 0x0001, (unsigned char *)dat, 10); } scrollScreen(); PA_WaitForVBL(); } }
portTASK_FUNCTION(Unit_Task, pvParameters ) { body bd[MAX_BODY_LENGTH]; int i; u8 x = 5; u8 y = 5; unit.x = 5; unit.y = 5; u8 pfx; u8 pfy; u8 pfDirection; u8 tempx; u8 tempy; u8 tempDirection; unit.direction = D_DOWN; portTickType xLastWakeTime = xTaskGetTickCount(); PA_LoadSpritePal(DOWN_SCREEN, C_PAL, (void*) C_Pal); PA_LoadSpritePal(DOWN_SCREEN, BODY_PAL, (void*) man_Pal); PA_CreateSprite(DOWN_SCREEN, C, (void*) C_Sprite, OBJ_SIZE_32X32, TRUE, C_PAL, map[unit.x][unit.y].x-8, map[unit.x][unit.y].y-16); while (1) { x = unit.x; y = unit.y; switch (unit.direction) { case D_UP: y--; break; case D_DOWN: y++; break; case D_LEFT: x--; break; case D_RIGHT: x++; break; default: break; } if ((map[x][y].state == MAP_STATE_NULL) || (map[x][y].state == MAP_STATE_ITEM)) { pfx = unit.x; pfy = unit.y; pfDirection = unit.direction; if ((map[x][y].state == MAP_STATE_ITEM)) { if (length < MAX_BODY_LENGTH) // to max length { length++; fireCreate(map); } if (length == MAX_BODY_LENGTH) { dropshipCreate(map); } map[x][y].state = MAP_STATE_NULL; PA_StopSpriteAnim(DOWN_SCREEN,map[x][y].itemSpriteNum); PA_DeleteSprite(DOWN_SCREEN, map[x][y].itemSpriteNum); PA_CreateSprite(DOWN_SCREEN, BODY + (length-1), (void*) man_Sprite, OBJ_SIZE_16X32, TRUE, BODY_PAL, 0, 0); } unit.x = x; unit.y = y; PA_SetSpriteXY(DOWN_SCREEN, C, map[unit.x][unit.y].x - 8, map[unit.x][unit.y].y - 16); for (i = 0; i < length; i++) { tempx = bd[i].x; tempy = bd[i].y; tempDirection = bd[i].direction; map[tempx][tempy].state = MAP_STATE_NULL; bd[i].x = pfx; bd[i].y = pfy; map[pfx][pfy].state = MAP_STATE_C_BODY; bd[i].direction = pfDirection; pfx = tempx; pfy = tempy; pfDirection = tempDirection; PA_SetSpriteXY(DOWN_SCREEN, BODY + i, map[bd[i].x][bd[i].y].x, (map[bd[i].x][bd[i].y].y)-16); if(pfDirection!=bd[i].direction) PA_StartSpriteAnim(DOWN_SCREEN, BODY + i, bd[i].direction, bd[i].direction+2, 7); } } if((map[x][y].state == MAP_STATE_WALL) || map[x][y].state == MAP_STATE_C_BODY) //실패 { AS_SoundQuickPlay(die); PA_ResetSpriteSys (); PA_ResetBgSysScreen (DOWN_SCREEN); PA_LoadBackground(DOWN_SCREEN, 3, &FAILSCREEN); vTaskSuspend(NULL); } if(map[x][y].state == MAP_STATE_EXIT) //클리어 { PA_ResetSpriteSys (); PA_ResetBgSysScreen (DOWN_SCREEN); PA_LoadBackground(DOWN_SCREEN, 3, &CLEARSCREEN); vTaskSuspend(NULL); } vTaskDelayUntil(&xLastWakeTime, MSEC2TICK(300-(length*10)) ); } }
int main(){ // Initialisation de la PAlib de l'affichage et du son PA_Init(); // Initialisation de la PALib PA_InitVBL(); // Initialisation de l'affichage AS_Init(AS_MODE_16CH); //son AS_SetDefaultSettings(AS_PCM_8BIT, 16384, 0); //son (type,rate) splash(); //Splashscreen // Initialisation du texte PA_LoadDefaultText(0, 0); //bas PA_LoadDefaultText(1, 0); //haut PA_SetTextTileCol(1, TEXT_BLACK); // texte en noir (haut) PA_SetTextTileCol(0, TEXT_BLACK); // texte en noir (bas) //Palettes des couleurs pour les sprites des boutons (une seule suffit) (numéro 1) PA_LoadSpritePal(0, 1, (void*)plus_Pal); PA_LoadBackground(1, 1, &titre); // background de l'écran du haut //Accueil AS_SoundDefaultPlay(pinball, pinball_size, 127, 64, true, 0); //musique de fond en boucle fonduentree(); //fondu d'entrée if(PA_UserInfo.Language == 2) { PA_LoadBackground(0, 1, &jouer); } else { PA_LoadBackground(0, 1, &play); } PA_OutputText(1, 17, 8, "2.1"); //version PA_WaitFor(Pad.Newpress.Anykey || Stylus.Newpress); AS_SoundQuickPlay(clic); fondusortie(); //Nouvelle partie : etiquette et reset debut: PA_ClearTextBg(0); //efface tout le texte PA_ResetSpriteSys(); //efface tout les sprites PA_OutputText(1,1,22," "); // Les variables u32 nmax = 0; //Nombre maximal u32 nmin = 0; //Nombre minimal u32 coup = 0; //Nombre de coups u32 nombre = 0; //Nombre (valeur de départ) u32 diff = 0; u32 temps = 0; //Sélection de la difficulté. fonduentree(); PA_LoadBackground(0, 1, &niveau); while(1) { if(PA_UserInfo.Language == 2) { PA_OutputText(0,5,4,"Facile (B)"); PA_OutputText(0,5,5,"(entre 10 et 25)"); PA_OutputText(0,5,11,"Normal (Y)"); PA_OutputText(0,5,12,"(entre 10 et 60)"); PA_OutputText(0,5,18,"Difficile (X)"); PA_OutputText(0,5,19,"(entre 10 et 95)"); } else { PA_OutputText(0,5,4,"Easy (B)"); PA_OutputText(0,5,5,"(between 10 and 25)"); PA_OutputText(0,5,11,"Normal (Y)"); PA_OutputText(0,5,12,"(between 10 and 60)"); PA_OutputText(0,5,18,"Hard (X)"); PA_OutputText(0,5,19,"(between 10 and 95)"); } if((PA_StylusInZone(29, 21, 227, 57) && Stylus.Newpress) || Pad.Newpress.A) { nombre = 12; nmax = 25; nmin = 10; diff = 1; break; } if((PA_StylusInZone(29, 79, 227, 115) && Stylus.Newpress) || Pad.Newpress.A) { nombre = 35; nmax = 60; nmin = 10; diff = 2; break; } if((PA_StylusInZone(29, 135, 227, 170) && Stylus.Newpress) || Pad.Newpress.A) { nombre = 52; nmax = 95; nmin = 10; diff = 3; break; } PA_WaitForVBL(); } u32 dsnum = PA_RandMinMax(nmin, nmax); //La valeur aléatoire entre 40 et 70 PA_LoadBackground(0, 1, &jeu); //chargement du bg de jeu //Reset pour effacer l'écran de choix de la difficulté PA_ClearTextBg(0); //Bouton + - et +5 -5 PA_CreateSprite(0, 0, (void*)plus_Sprite, OBJ_SIZE_32X32, 1, 1, 40, 33); PA_CreateSprite(0, 1, (void*)moins_Sprite, OBJ_SIZE_32X32, 1, 1, 40, 110); PA_CreateSprite(0, 2, (void*)okb_Sprite, OBJ_SIZE_32X32, 1, 1, 218, 157); PA_CreateSprite(0, 4, (void*)moins5_Sprite, OBJ_SIZE_32X32, 1, 1, 75, 110); PA_CreateSprite(0, 5, (void*)plus5_Sprite, OBJ_SIZE_32X32, 1, 1, 75, 33); // Boucle principale PA_VBLCounterStart(0); while (1) { PA_OutputText(0,8,22,"%d", coup); //PA_OutputText(1,1,20,"La DS pense à : %d", dsnum); // Débug //PA_OutputText(1,1,19,"Temps : %d", PA_VBLCounter[0]/60); // Débug if(PA_UserInfo.Language == 2) { if(diff == 1) { PA_OutputText(1,1,22,"Facile (entre %d et %d)",nmin, nmax); } if(diff == 2) { PA_OutputText(1,1,22,"Normal (entre %d et %d)",nmin, nmax); } if(diff == 3) { PA_OutputText(1,1,22,"Difficile (entre %d et %d)",nmin, nmax); } } else { if(diff == 1) { PA_OutputText(1,1,22,"Easy (between %d and %d)",nmin, nmax); } if(diff == 2) { PA_OutputText(1,1,22,"Normal (between %d and %d)",nmin, nmax); } if(diff == 3) { PA_OutputText(1,1,22,"Hard (between %d and %d)",nmin, nmax); } } if(PA_UserInfo.Language == 2) { PA_OutputText(0,4,10,"Votre nombre:"); } else { PA_OutputText(0,4,10,"Your number:"); } PA_OutputText(0,4,12,"%d", nombre); if(PA_UserInfo.Language == 2) { PA_OutputText(0,1,22,"Coups:"); } else { PA_OutputText(0,1,22,"Tries:"); } if(Pad.Newpress.Up || (Stylus.Newpress && PA_SpriteTouched(0))) { nombre++; AS_SoundQuickPlay(clic); } if(Pad.Newpress.Down || (Stylus.Newpress && PA_SpriteTouched(1))) { nombre--; AS_SoundQuickPlay(clic); } if(Pad.Newpress.Left || (Stylus.Newpress && PA_SpriteTouched(4))) { nombre = nombre - 5; AS_SoundQuickPlay(clic); } if(Pad.Newpress.Right || (Stylus.Newpress && PA_SpriteTouched(5))) { nombre = nombre + 5; AS_SoundQuickPlay(clic); } if(nombre < nmin) { nombre = nmin; } if(nombre > nmax) { nombre = nmax; } if((PA_SpriteTouched(2) && Stylus.Newpress) || Pad.Newpress.A) { coup++; AS_SoundQuickPlay(clic); if (dsnum > nombre) { PA_OutputText(0,25,11," "); PA_OutputText(0,25,11,"Plus !"); } if (dsnum < nombre) { PA_OutputText(0,25,11," "); if(PA_UserInfo.Language == 2) { PA_OutputText(0,25,11,"Moins !"); } else { PA_OutputText(0,25,11,"Minus !"); } } if (dsnum == nombre) { temps = PA_VBLCounter[0]/60; PA_WaitFor(Stylus.Released || Pad.Released.A); PA_ResetSpriteSys(); PA_LoadBackground(0, 1, &gagne); PA_ClearTextBg(0); //efface tout le texte AS_SoundQuickPlay(ok); //Smiley qui applaudit PA_LoadSpritePal(0, 0, (void*)applaudissement_Pal); // la palette du smiley (num 0) PA_CreateSprite(0, 3,(void*)applaudissement_Sprite, OBJ_SIZE_32X32,1, 0, 180, 45); PA_StartSpriteAnimEx(0, 3, 0, 4, 12, ANIM_LOOP, 7); if(PA_UserInfo.Language == 2) { PA_OutputText(0,15,6,"Gagné !"); PA_OutputText(0,6,8,"Vous avez trouvé %d", dsnum); PA_OutputText(0,6,9,"en %d secondes", temps); PA_OutputText(0,6,10,"et %d coups.", coup); PA_OutputText(0,6,16,"START ou touchez"); PA_OutputText(0,6,17,"l'écran pour rejouer."); } else { PA_OutputText(0,15,6,"Win !"); PA_OutputText(0,6,9,"You find %d", dsnum); PA_OutputText(0,6,10,"in %d seconds", temps); PA_OutputText(0,6,11,"and %d tests. ", coup); PA_OutputText(0,6,15,"START or touch"); PA_OutputText(0,6,16,"the screen to replay."); } //Recommencer le jeu avec l'etiquette debut PA_WaitFor(Stylus.Newpress || Pad.Newpress.Start); AS_SoundQuickPlay(clic); goto debut; } } PA_WaitForVBL(); //Rafraichissement à ne pas bouger/enlever } return 0; }
Board::Board(int m):root_story(-1, -1, 0) { #ifdef CKM_STORED // pIgs = NULL; #endif size = 19; // UI = new FlBoard(); // time_color = UI->black_time->text_background(); //time_color2 = UI->black_time->text_color(); //UI->b = this; set_size(size); cur_player = BLACK; for (int i=0; i<19; i++) for (int j=0; j<19; j++) { b[i][j] = EMPTY; root_story.b[i][j] = EMPTY; } s = &root_story; pos = 0; root_story.score[0] = score[0] = 0; root_story.score[1] = score[1] = 0.5; mode = 0; set_mode(m); // owner = 0; //< pointer on the possibly associated IGS game memset(inib, EMPTY, 19*19); memset(dead, EMPTY, 19*19); memset(territory, EMPTY, 19*19); memset(b, EMPTY, 19*19); // memset(old_c, 0, sizeof(old_c)); //time color next = first; first = this; if (!stn) { stn = new Stone(); stn->set_size(20); // stn->init_image(); } // UI->black_box->image(stn->img[0]); // UI->white_box->image(stn->img[1]); // UI->black_name->hide(); // UI->white_name->hide(); // UI->black_time->hide(); //UI->white_time->hide(); // UI->moves_browser->board = this; // UI->observer_browser->callback(observer_cb, this); // UI->moves_browser->type(Fl_Browser::VERTICAL | Fl_Browser::MULTI_BROWSER); strcpy(blackname, ""); strcpy(blackrank, ""); strcpy(whitename, ""); strcpy(whiterank, ""); filename = 0; title = 0; PA_ResetBgSys(); PA_ResetSpriteSys(); PA_Init3D(); PA_Reset3DSprites(); PA_LoadTiledBg(0, 3, board19); PA_LoadTiledBg(1, 1, bgscoreigs); PA_Init16cBg(1, 0); PA_16cText(1, 120, 10, 255, 192, "chris28ttttt [17k]", 1, 2, 100); // PA_LoadSpritePal(0, 1, (void*)pass_Pal); PA_3DProcess(); // Update sprites PA_WaitForVBL(); if (!ptn) { ptn = new Pointer(); } u16 gfx[6]; gfx[PASSBUTTON] = PA_3DCreateTex((void*)pass_Texture, 64, 32, TEX_256COL); PA_3DCreateSpriteFromTex(PASSBUTTON, gfx[PASSBUTTON], 64, 32, 2, 33, 164); PA_3DProcess(); // Update sprites PA_WaitForVBL(); // while (COND_PLAY_MOVE) { while(!(mode&BOARD_OBSERVE)) { ptn->move(); //add_move(ptn->xpointer, ptn->ypointer); if (mode&BOARD_SCORING) { // if (s->nbvariants) return 1; if (mode&BOARD_PLAYING) { if (!dead[ptn->xpointer][ptn->ypointer]) { char c = 'a'+ptn->xpointer; if (c>='i') c++; char s[10]; // sprintf(s, "%c%d", c, this->size-my); // owner->igs->send(s); } } else { if (0)//(mk == 1) event button remove(ptn->xpointer,ptn->ypointer, cur_board->b[ptn->xpointer][ptn->ypointer], !dead[ptn->xpointer][ptn->ypointer]); else { if (b[ptn->xpointer][ptn->ypointer] == EMPTY) dead[ptn->xpointer][ptn->ypointer] = dead[ptn->xpointer][ptn->ypointer] == 2? 0:2; } // cur_board->dead[mx][my] = !cur_board->dead[mx][my]; // refresh(); // redraw(); update_territory(); } } else if (b[ptn->xpointer][ptn->ypointer] == EMPTY) { if (mode&BOARD_PLAYING) { //IGS char s[10]; char c = 'a'+ptn->xpointer; if (c>='i') c++; //sprintf(s, "%c%d", c, this->size-my); //owner->igs->send(s); } else { // edit mode add_move(ptn->xpointer, ptn->ypointer); // refresh(); update_pos(); } } // sprintf(debug,"player : %d",cur_player); // PA_16cText(1, 10, 30, 255, 192, debug, 1, 2, 100); // refresh(); // update_pos(); } // PA_CreateSprite(0, 1, (void*)pass_Sprite, OBJ_SIZE_64X32, 1, 1, 1, 60); }