void initMinimap(int selStage) { PA_ResetBgSysScreen(SUB_SCREEN); if(selStage == FINALDESTINATION) { PA_EasyBgLoad(SUB_SCREEN, 3, finaldestinationminimap); } else if(selStage == POKEMONSTADIUM) { PA_EasyBgLoad(SUB_SCREEN, 3, pokemonstadiumminimap); } // else if(selStage == CORNERIA) { // PA_EasyBgLoad(SUB_SCREEN, 3, corneria); // } // else if(selStage == CASTLESIEGE) { // PA_EasyBgLoad(SUB_SCREEN, 3, castleseige); // } PA_LoadSpritePal(SUB_SCREEN, 1, (void*)charminis_Pal); for(int n = 0; n < (int)players.size(); n++) { PA_CreateSprite(SUB_SCREEN, n+1, (void*)charminis, OBJ_SIZE_16X16, COLOR256, 1, -16, -16); if(players[n] -> name == "kirby") PA_StartSpriteAnimEx(SUB_SCREEN, n+1, KIRBY, KIRBY, 1, ANIM_LOOP, -1); else if(players[n] -> name == "mewtwo") PA_StartSpriteAnimEx(SUB_SCREEN, n+1, MEWTWO, MEWTWO, 1, ANIM_LOOP, -1); else if(players[n] -> name == "mario") PA_StartSpriteAnimEx(SUB_SCREEN, n+1, MARIO, MARIO, 1, ANIM_LOOP, -1); else if(players[n] -> name == "ike") PA_StartSpriteAnimEx(SUB_SCREEN, n+1, IKE, IKE, 1, ANIM_LOOP, -1); } PA_LoadSpritePal(SUB_SCREEN, 0, (void*)visibleminimap_Pal); PA_CreateSprite(SUB_SCREEN, 0, (void*)visibleminimap_Sprite, OBJ_SIZE_64X64, COLOR256, 0, -64, -64); // loads the sprite icons for the minimap } // initializes the minimap display on the sub screen
bool Projectile::act() { if(TYPE == THUNDERSHOCK && PA_GetSpriteAnimFrame(MAIN_SCREEN, num) == 44) { Floor f = checkFloorCollision(32, 64); if(f.length != 0) { dy = 0; y = f.y-64; PA_StartSpriteAnimEx(MAIN_SCREEN, num, 45, 47, 20, ANIM_LOOP, -1); } Wall w = checkWallCollision(32, 64); if(w.length != 0) dx *= -1; } else if(TYPE == THUNDERSHOCK && PA_GetSpriteAnimFrame(MAIN_SCREEN, num) >= 45 && PA_GetSpriteAnimFrame(MAIN_SCREEN, num) <= 47) { if(checkWallCollision(32, 64).length != 0) dx *= -1; if(dy == 0) { dy = 1; if(checkFloorCollision(32, 64).length == 0) { dy = GLOBALGRAVITY; PA_StartSpriteAnimEx(MAIN_SCREEN, num, 44, 44, 20, ANIM_LOOP, -1); } else dy = 0; } } if(TYPE == FIREBALL) { dy += .1; if(dy > GLOBALGRAVITY) dy = GLOBALGRAVITY; Floor f = checkFloorCollision(32, 32); if(f.length != 0) dy *= -1; Wall w = checkWallCollision(32, 32); if(w.length != 0) dx *= -1; Ceiling c = checkCeilingCollision(32, 32); if(c.length != 0) dy *= -1; } x += dx; y += dy; PA_SetSpriteXY(MAIN_SCREEN, num, (int)(x - display->scrollx), (int)(y - display->scrolly)); if (x + 64 - display->scrollx < 0 || x - display->scrollx > 256 || y + 64 - display->scrolly < 0 || y - display->scrolly > 192) PA_SetSpriteXY(MAIN_SCREEN, num, -64, -64); time++; if (time > length) return true; return false; }
void dropshipCreate(mapTile map[][MAX_MAP_Y_LENGTH]){ u8 i, j; u8 x, y; for(i=0; i<fireCount; i++) PA_DeleteSprite(DOWN_SCREEN, FIREINMAP + i); for(i=0; i<MAX_MAP_X_LENGTH; i++) for(j=0; j<MAX_MAP_Y_LENGTH; j++) { if (i != 0 && i != (MAX_MAP_X_LENGTH - 1) && j != 0 && j != (MAX_MAP_Y_LENGTH - 1)) map[i][j].state = MAP_STATE_NULL; } x = MAX_MAP_X_LENGTH / 2 - 2; y = MAX_MAP_Y_LENGTH / 2 - 2; PA_LoadSpritePal(DOWN_SCREEN, DROPSHIP_PAL, (void*) dropship_Pal); PA_CreateSprite(DOWN_SCREEN, DROPSHIP, (void*) dropship_Sprite, OBJ_SIZE_64X64, TRUE, DROPSHIP_PAL, map[x][y].x, map[x][y].y); PA_StartSpriteAnimEx (DOWN_SCREEN, DROPSHIP, 0, 4, 3, ANIM_UPDOWN, -1); for(i=1; i<3; i++) for(j=1; j<3; j++) map[x+i][y+j].state = MAP_STATE_EXIT; AS_SoundQuickPlay(dropship); }
// shortcuts for projectiles Projectile::Projectile(double xpos, double ypos, double xchange, double ychange, int l, int t, int ob, Hitbox h, Stage* mine, Display *d) { display = d; mystage = mine; num = -1; for(int n = 0; n < effproj_used_size; n++) { if(!effproj_used[n]) { num = n+5; effproj_used[n] = true; break; } } owner = ob; TYPE = t; x = xpos; y = ypos; dx = xchange; enabled = true; if (dx > 0) PA_SetSpriteHflip(MAIN_SCREEN, num, 0); else PA_SetSpriteHflip(MAIN_SCREEN, num, 1); dy = ychange; length = l; time = 0; hit = h; PA_SetSpriteXY(MAIN_SCREEN, num, (int)(x - display->scrollx), (int)(y - display->scrolly)); if (TYPE == SHADOWBALL_SMALL) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 18, 21, 20, ANIM_LOOP, -1); } if (TYPE == SHADOWBALL_MEDIUM) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 22, 25, 20, ANIM_LOOP, -1); } if (TYPE == SHADOWBALL_LARGE) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 26, 29, 20, ANIM_LOOP, -1); } if (TYPE == FINALCUTTER) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 30, 30, 20, ANIM_LOOP, -1); } if (TYPE == FIREBALL) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 31, 34, 20, ANIM_LOOP, -1); } if (TYPE == FLUDDWATER) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 35, 35, 20, ANIM_LOOP, -1); } if (TYPE == IKESWORD) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 36, 42, 20, ANIM_LOOP, -1); } if (TYPE == FOXLASER) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 43, 43, 20, ANIM_LOOP, -1); } if(TYPE == THUNDERSHOCK) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 44, 44, 20, ANIM_LOOP, -1); } if(TYPE == THUNDER1) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 48, 51, 15, ANIM_LOOP, -1); } if(TYPE == THUNDER2) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 52, 53, 15, ANIM_LOOP, -1); } if(TYPE == THUNDER3) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 54, 55, 15, ANIM_LOOP, -1); } if(TYPE == THUNDER4) { PA_StartSpriteAnimEx(MAIN_SCREEN, num, 56, 58, 15, ANIM_LOOP, -1); } }
Fighter* Projectile::checkHits(Fighter* other) { Hitbox temp = hit; Hitbox atkbox; vector<Circle> circles = temp.getCircles(); for (uint8 n = 0; n < circles.size(); n++) { Circle current = circles[n]; Circle newcircright(current.getX() + x, current.getY() + y, current.getRadius(), current.getKnockback(), current.damage); Circle newcircleft(64 - current.getX() + x, current.getY() + y, current.getRadius(), current.getKnockback(), current.damage); if (dx < 0) atkbox.addCircle(newcircright); else atkbox.addCircle(newcircleft); } if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) { if(!projs[n].enabled) enabled = false; } } } if (!enabled) { if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) { projs[n].enabled = false; } } } return other; } if (other -> respawntimer > 0) return other; if (other -> invincibility > 0) return other; if(atkbox.hits(other -> getAtkbox())) { if(atkbox.getHitCircle(other -> getAtkbox()).priority < other -> getAtkbox().getHitCircle(atkbox).priority) { if (dx < 0) other -> takeDamage(atkbox.getHitCircle(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM))), 1, owner, 0); else other -> takeDamage(atkbox.getHitCircle(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM))), -1, owner, 0); } else if(atkbox.getHitCircle(other -> getAtkbox()).priority == other -> getAtkbox().getHitCircle(atkbox).priority) { removeProj(num); } else { removeProj(num); return other; // they win priority } } else if(atkbox.hits(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM)))) { if(other -> MYCHAR == KIRBY && PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM) == 189) { if(TYPE != THUNDER1 && TYPE != THUNDER2 && TYPE != THUNDER3 && TYPE != THUNDER4 && TYPE != IKESWORD) removeProj(num); else atkbox.enabled = false; } else if (other -> action == AIRDODGE || other -> action == ROLL || other -> action == DODGE) { /*doesn't hit*/ } else if (other -> action == SHIELD) { other -> shieldstr -= (int)((atkbox.getHitCircle(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM))).damage)); if(TYPE != THUNDER1 && TYPE != THUNDER2 && TYPE != THUNDER3 && TYPE != THUNDER4 && TYPE != IKESWORD) removeProj(num); else atkbox.enabled = false; if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) projs[n].enabled = false; } } } else if(other -> COUNTER) { if(TYPE != THUNDER1 && TYPE != THUNDER2 && TYPE != THUNDER3 && TYPE != THUNDER4 && TYPE != IKESWORD) removeProj(num); else atkbox.enabled = false; other -> COUNTER = false; if(other -> MYCHAR == IKE && (PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM) == 139 || PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM) == 140)) { PA_StartSpriteAnimEx(MAIN_SCREEN, other -> SPRITENUM, 143, 144, 10, ANIM_LOOP, -1); other -> action = ATTACK; other -> delay = 60/10 * 2; other -> freeze(30); other -> dx = 0; PA_StartSpriteAnimEx(MAIN_SCREEN, other -> SPRITENUM, 139, 139, 1, ANIM_LOOP, -1); } if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) projs[n].enabled = false; } } } else if(other -> CAPE) { dx *= -1; owner = other -> charnum; vector<Circle> temp = hit.getCircles(); hit.reset(); for(int n = 0; n < (int)temp.size();n++) { hit.addCircle(Circle(temp[n].getX(), temp[n].getY(), temp[n].getRadius(), Knockback(temp[n].getKnockback().dx * -1, temp[n].getKnockback().dy, temp[n].getKnockback().length), temp[n].damage)); } if(dx > 0) PA_SetSpriteHflip(MAIN_SCREEN, num, 0); if(dx < 0) PA_SetSpriteHflip(MAIN_SCREEN, num, 1); } else if (other -> ABSORB && (TYPE != IKESWORD)) { other -> percentage -= atkbox.getHitCircle(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM))).damage; if(other -> percentage < 0) other -> percentage = 0; if(TYPE != THUNDER1 && TYPE != THUNDER2 && TYPE != THUNDER3 && TYPE != THUNDER4) removeProj(num); else atkbox.enabled = false; if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) projs[n].enabled = false; } } } else { other -> takeDamage(atkbox.getHitCircle(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM))), 1, owner, 0); if (TYPE != FINALCUTTER && TYPE != IKESWORD && TYPE != THUNDER1 && TYPE != THUNDER2 && TYPE != THUNDER3 && TYPE != THUNDER4) removeProj(num); else enabled = false; if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) projs[n].enabled = false; } } } } return other; }
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; }