Ejemplo n.º 1
0
// Function: main()
int main(int argc, char ** argv){

	PA_Init();    // PA Init...
	PA_InitVBL();	// VBL Init...
	
	// Init the sound system
	AS_Init(AS_MODE_SURROUND | AS_MODE_16CH);
	AS_SetDefaultSettings(AS_PCM_8BIT, 11025, AS_SURROUND);
	
	PA_SetBgColor(0, PA_RGB(31, 31, 31)); // White background color

	// First, convert the gif to a sprite format...
	u8 *spritegfx = PA_GifToTiles((void*)Mollusk, // Gif file
											spritepal); // our palette
	
	// Next, load the sprite...
	PA_CreateSprite(0, 0, spritegfx, OBJ_SIZE_64X64, 1, 0, 64, 64);  // Just like plain sprites !
	PA_LoadSpritePal(0, 0, spritepal);  // Just like plain palettes !

	// spritegfx can be used over and over again to load other sprites... 
	// If you do not need it anymore, use free(spritegfx); to free the memory it uses !

	s32 spritex = -64;  // Sprite position
	s32 pan = 0;   // Audio panning
	
	PA_SetSpriteHflip(0, 0, 1); // Turn sprite around...	again...	
	
  while(1)  {  
  		int channel0 = PA_PlaySimpleSound(Zoom); // Play sound...

		for (spritex = -64; spritex < 256; spritex +=2){
			pan = spritex/2; 
			if (pan < 0) pan = 0; if (pan > 127) pan = 127; // Limit range...
			
			PA_SetSpriteX(0, 0, spritex);
			PA_SetSoundChannelPan(channel0, pan);
			PA_WaitForVBL();
		}
		
		PA_SetSpriteHflip(0, 0, 0); // Turn sprite around...
		
		int channel1 = PA_PlaySimpleSound(Zoom);
 
 		for (spritex = 256; spritex > -65; spritex -=2){
			pan = spritex/2; 
			if (pan < 0) pan = 0; if (pan > 127) pan = 127; // Limit range...
			
			PA_SetSpriteX(0, 0, spritex);
			PA_SetSoundChannelPan(channel1, pan);
			PA_WaitForVBL();
		} 
		
		PA_SetSpriteHflip(0, 0, 1); // Turn sprite around...	again...	
  
	}
		
	return 0;
} // End of main()
Ejemplo n.º 2
0
// Main function
int main(void)	{
	// PAlib init
	PA_Init();
	PA_InitVBL();
	
	PA_InitText(1, 0);

	PA_LoadSpritePal(0, 0, (void*)sprite0_Pal);	// Palette....	

	s32 x = 120; s32 y = 64;

	PA_CreateSprite(0, 0,(void*)som_Sprite, OBJ_SIZE_16X32,1, 0, x, y); // Sprite
	
	while(1)
	{
		// Animation code...
		if(Pad.Newpress.Up) PA_StartSpriteAnim(0, 0, 0, 3, 4);
		if(Pad.Newpress.Down) PA_StartSpriteAnim(0, 0, 8, 11, 4);		
		
		if(Pad.Newpress.Right) {
			PA_StartSpriteAnim(0, 0, 4, 7, 4);	
			PA_SetSpriteHflip(0, 0, 0);
		}
		if(Pad.Newpress.Left) {
			PA_StartSpriteAnim(0, 0, 4, 7, 4);	
			PA_SetSpriteHflip(0, 0, 1);
		}

		
		if(!((Pad.Held.Left)||(Pad.Held.Up)||(Pad.Held.Down)||(Pad.Held.Right))) PA_SpriteAnimPause(0, 0, 1);
	
	
		// Moving Code
		y += Pad.Held.Down - Pad.Held.Up;
		x += Pad.Held.Right - Pad.Held.Left;		
		PA_SetSpriteXY(0, 0, x, y);
	
		PA_WaitForVBL();
	}
	
	return 0;
}
Ejemplo n.º 3
0
// 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);
	}
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
// Main function
int main(void)	{
	// PAlib init
	PA_Init();
	PA_InitVBL();
	
	PA_InitText(0, 0);  // Initialise the text system on the top screen	
	PA_InitText(1, 0);  // Initialise the text system on the top screen

	PA_OutputSimpleText(1, 0, 5, "Please insert your DS Motion and press any key"); // Ask to insert the DS Motion...

	PA_WaitFor(Pad.Newpress.Anykey);  // Wait for any key to be pressed before continuing...
	PA_ClearTextBg(1);		// Erase text screen...
	
	 // Turn on the DS Motion...
	 PA_MotionInit();
	 
	while ( !PA_CheckDSMotion()) { // Checks for the DS Motion, continues looking for it until it actually finds it...
		PA_WaitForVBL();
		
		// If no DSMotion found...
		PA_OutputText(1, 0, 5, "      DS Motion not found ! \nPlease insert your DS Motion and press any key"); // Ask to insert the DS Motion... again...
		
		PA_WaitFor(Pad.Newpress.Anykey);  // Wait for any key to be pressed before continuing...
		PA_MotionInit();
	}
	
	PA_ClearTextBg(1); // erase the text...
	
	PA_MotionToPad(1); // Overrides the pad keys and puts the DS Motion instead

	PA_LoadSpritePal(0, 0, (void*)sprite0_Pal);	// Palette....	

	s32 x = 120; s32 y = 64;

	PA_CreateSprite(0, 0,(void*)som_Sprite, OBJ_SIZE_16X32,1, 0, x, y); // Sprite
	
	while(1)
	{
		// Animation code...
		if(Pad.Newpress.Up) PA_StartSpriteAnim(0, 0, 0, 3, 6);
		if(Pad.Newpress.Down) PA_StartSpriteAnim(0, 0, 8, 11, 6);		
		
		if(Pad.Newpress.Right) {
			PA_StartSpriteAnim(0, 0, 4, 7, 6);	
			PA_SetSpriteHflip(0, 0, 0);
		}
		if(Pad.Newpress.Left) {
			PA_StartSpriteAnim(0, 0, 4, 7, 6);	
			PA_SetSpriteHflip(0, 0, 1);
		}

		
		if(!((Pad.Held.Left)||(Pad.Held.Up)||(Pad.Held.Down)||(Pad.Held.Right))) PA_SpriteAnimPause(0, 0, 1);
	
	
		// Moving Code
		y += Pad.Held.Down - Pad.Held.Up;
		x += Pad.Held.Right - Pad.Held.Left;		
		PA_SetSpriteXY(0, 0, x, y);
		
		PA_OutputText(1, 3, 7, "Up     : %d-%d-%d", Pad.Newpress.Up, Pad.Held.Up, Pad.Released.Up);
		PA_OutputText(1, 3, 8, "Down   : %d-%d-%d", Pad.Newpress.Down, Pad.Held.Down, Pad.Released.Down);
		PA_OutputText(1, 3, 9, "Left   : %d-%d-%d", Pad.Newpress.Left, Pad.Held.Left, Pad.Released.Left);		
		PA_OutputText(1, 3, 10, "Right  : %d-%d-%d", Pad.Newpress.Right, Pad.Held.Right, Pad.Released.Right);	
	
		PA_WaitForVBL();
	}
	
	return 0;
}