Beispiel #1
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	// Initialise the text system on the top screen
	PA_InitText(0,0);
	PA_InitText(1, 0);
	
	PA_OutputText(0, 1, 1, "PA_InitWifi() ...");
    PA_InitWifi();
	PA_OutputText(0, 1, 2, "done!\nPA_ConnectWifiWFC() ...");
    if (!PA_ConnectWifiWFC())
	{
		PA_OutputText(0, 1, 4, "error!");
		return 1;
	}
    PA_OutputText(0, 1, 4, "done!\nWIFI is now ready!");

	while (1)
	{
		PA_WaitForVBL();
	}
	
	return 0;
} // End of main()
Beispiel #2
0
void init() {
    PA_Init();
    PA_InitVBL();

    PA_InitText(0, 0);
    PA_InitText(1, 0);

    PA_LoadSpritePal(0, // Screen
            0, // Palette number
			(void*)btn_palette);	// Palette name
}
Beispiel #3
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL


	PA_InitText(1, 0);	
	
	// Load Backgrounds with their palettes !
	PA_EasyBgLoad(0, // screen
					3, // background number (0-3)
					bg0); // Background name, used by PAGfx...
	
	PA_OutputSimpleText(1, 2, 10, "Touch the screen to display   the color on top screen");	

	// Infinite loop to keep the program running
	while (1)
	{
		PA_OutputText(1, 2, 5, "Palette Color : %d   ", PA_EasyBgGetPixel(0, 3, Stylus.X, Stylus.Y)); // Screen, Bg_number, X/Y position
		// Returns the palette number (0-255)
		
		PA_SetBgColor(1, PA_EasyBgGetPixelCol(0, 3, Stylus.X, Stylus.Y));  // Same thing, but returns Color value...
		PA_WaitForVBL();

	}
	
	return 0;
} // End of main()
Beispiel #4
0
// Main function
int main(void)	{

	PA_Init();
	PA_InitVBL();
	
	PA_InitText(1, 0);
	
	PA_LoadSpritePal(0, 0, (void*)sprite0_Pal);	// Load the sprite palette
	
	// Load a few sprites...
	u8 i = 0; 
	for (i = 0; i < 16; i++) PA_CreateSprite(0, i,(void*)mollusk_Sprite, OBJ_SIZE_32X32,1, 0, i << 3, i << 3);
	
	
	PA_InitSpriteExtPrio(1); // Enable extended priorities
	
	
	PA_OutputSimpleText(1, 0, 10, "Please move the sprites to see how their priorities change");
	
	while(1)
	{	
		// Now we'll test every sprite to see if we touch it...
		for (i = 0; i < 16; i++) {
			PA_MoveSprite(i);  // move the sprites. 
			s16 y = PA_GetSpriteY(0, i);  if (y > 192) y-=256; // if higher than 0...
			PA_SetSpriteExtPrio(0, i, 192-y); // Top priority when at the bottom !
		}

	
		PA_WaitForVBL();	
	}
	return 0;
}
Beispiel #5
0
int main(void)
{

// Initialise the lib...
PA_Init();
PA_InitVBL(); 

PA_InitText(1, 0);

// Load the palettes for the sprites on both screens
PA_DualLoadSpritePal(0, (void*)sprite0_Pal);

// Create the sprite on both screens...
PA_DualCreateSprite(FRISBEE, (void*)frisbee_Sprite, OBJ_SIZE_32X32, 1, 0, 96, 300); // Bottom screen
PA_DualSetSpriteRotEnable(FRISBEE, 0); // Enable rotation/zoom, rotset 0

// Sprite initial position...
frisbee.x = 96+16; 
frisbee.y = 300+16; // on the bottom screen

// Speed of frisbee in both ways
frisbee.vx = 0;
frisbee.vy = 0;

	while(1)
	{
		// Move with the stylus, or move on...
		if (PA_MoveSprite(FRISBEE)){
			frisbee.x = PA_MovedSprite.X;
			frisbee.y = PA_MovedSprite.Y + 192 + SCREENHOLE;
			frisbee.vx = PA_MovedSprite.Vx;		frisbee.vy = PA_MovedSprite.Vy; 
		}
		else{
			// Now, the frisbee's fixed point position will be updated according to the speed...
			frisbee.x += frisbee.vx;
			frisbee.y += frisbee.vy;
		
			// If the sprite touches the left or right border, flip the horizontal speed
			if ((frisbee.x -16 <= 0) && (frisbee.vx < 0)) frisbee.vx = -frisbee.vx; 
			else if ((frisbee.x + 16 >= 256)&&(frisbee.vx > 0)) frisbee.vx = - frisbee.vx;
	
			// Same thing, for top and bottom limits...
			if ((frisbee.y -16 <= 0) && (frisbee.vy < 0)) frisbee.vy = -frisbee.vy;
			else if ((frisbee.y + 16 >= 192 + 192 + SCREENHOLE)&& (frisbee.vy > 0)) frisbee.vy = - frisbee.vy;		
			// The bottom limit is at the bottom of the bottom screen, so that would be 2 screen heights, plus the space in between...
			PA_DualSetSpriteXY(FRISBEE, frisbee.x-16, frisbee.y-16);
	
		}
		
		PA_OutputText(1, 2, 10, "SpeedX : %d    ", frisbee.vx);
		PA_OutputText(1, 2, 11, "SpeedY : %d    ", frisbee.vy);		
		frisbee.angle+=4; // Make the frisbee turn...
		PA_DualSetRotsetNoZoom(0, frisbee.angle);
		
	
	PA_WaitForVBL();  // Synch to the framerate...
	}

return 0;
}
Beispiel #6
0
void draw() {
	PA_InitText(1,0);
	for (u8 i=0; i<numeros.size(); i++) {
		PA_OutputText(1,i,0,"%d ",numeros[i]);
	}
	PA_OutputText(1,0,1,"size: %d   , cap:  %d   ",numeros.size(),numeros.capacity());
}
Beispiel #7
0
//Fonction principale du code
int main(void){

	PA_Init(); //Initialision of PAlib
	PA_InitVBL();
	
	PA_InitText(0,0);
	
	PA_LoadSpritePal(0, // Screen
					0, // Palette number
					(void*)sprite0_Pal);	// Palette name
	
	//Create the sprite
	PA_CreateSprite(0, 0,(void*)vaisseau_Sprite, OBJ_SIZE_32X32,1, 0, 0, 0);
	
	
	while(1){ // Main loop
		
		// Update the position according to the keypad...
		x += Pad.Held.Right - Pad.Held.Left;
		y += Pad.Held.Down - Pad.Held.Up;
		
		// Set the sprite's position
		PA_SetSpriteXY(0, // screen
					   0, // sprite
					   x, // x position
					   y); // y...
		
		PA_WaitForVBL();
	}
	return 0;
}
Beispiel #8
0
int main(void){

	PA_Init();
	PA_InitVBL();
	
	PA_InitText(1,0); // On the top screen

	PA_LoadSpritePal(0, 0, (void*)sprite0_Pal);
	
	// This'll be the movable sprite...
	PA_CreateSprite(0, 0,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 16, 16); 	
	s32 x = 16; s32 y = 16; // Sprite's center position
	
	// This will be the fixed circle
	PA_CreateSprite(0, 1,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 128-16, 96-16); 
	
	while(1)
	{
		if (PA_MoveSprite(0)){
			x = PA_MovedSprite.X;
			y = PA_MovedSprite.Y;
		}
		
		// Collision ?
		if (PA_Distance(x, y, 128, 96) < 32*32) PA_OutputText(1, 2, 10, "Collision !!");
		else PA_OutputText(1, 2, 10, "            ");

		PA_WaitForVBL();
	}
	return 0;
}
Beispiel #9
0
// Function: main()
int main(int argc, char ** argv){
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
		
	PA_InitText(1, 0); // Init text on the top screen, background 0...
	
	// Load Backgrounds and their palettes...
	PA_EasyBgLoad(0, 3, BG3);	
	PA_EasyBgLoad(1, 3, BG3);	
	
	s32 scrollx = 0; // No X scroll by default...
	s32 scrolly = 0; // No Y scroll by default...

	// Infinite loop to keep the program running
	while (1)
	{
		// We'll modify scrollx and scrolly according to the keys pressed
		scrollx += (Pad.Held.Left - Pad.Held.Right) * 4; // Move 4 pixels per press
		scrolly += (Pad.Held.Up - Pad.Held.Down) * 4; // Move 4 pixels per press

		// Scroll the background to scrollx, scrolly...
		PA_BGScrollXY(0, // Screen
					3, // Background number
					scrollx, // X scroll
					scrolly); // Y scroll
		
		// Display the X and Y scrolls :
		PA_OutputText(1, 0, 0, "x : %d   \ny : %d   ", scrollx, scrolly);
		
		PA_WaitForVBL();
	}
	
	return 0;
} // End of main()
Beispiel #10
0
int main(void){

	PA_Init(); //PAlib inits
	PA_InitVBL();
	
	PA_InitText(1, 0);
	
	PA_OutputSimpleText(1, 2, 6, "BinFile example");
	
	PA_LoadSpritePal(0, // Screen
					0, // Palette number
					(void*)sprite0_Pal);	// Palette name
					
	PA_CreateSprite(0, // Screen
					0, // Sprite number
					(void*)vaisseau_Sprite, // Sprite name
					OBJ_SIZE_32X32, // Sprite size
					1, // 256 color mode
					0, // Sprite palette number
					50, 50); // X and Y position on the screen
				

	while (1) // Infinite loop
	{
		PA_WaitForVBL();
	}
	
return 0;
}
Beispiel #11
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_InitText(1, 0);
	
	//PA_LoadSplash();  // PA_Lib splash screen
	
	// Load a large scrolling background converted with PAGfx... InfiniteMap
	PA_DualEasyBgLoad(3, //background number (0-3)
						Town); // Name
	
	// Next we'll scroll, here are the variables...
	s32 scrollx = 0; 
	s32 scrolly = 0;
	

// Infinite loop to keep the program running
while (1)
{

	// We need to change the scroll according to the held keys...
	scrollx += (Pad.Held.Right - Pad.Held.Left)*4; // scroll 4 pixels at a time
	scrolly += (Pad.Held.Down - Pad.Held.Up)*4; // Same thing
	PA_DualEasyBgScrollXY(3, scrollx, scrolly);	

	PA_WaitForVBL();
}
	
	return 0;
} // End of main()
Beispiel #12
0
int main(int argc, char ** argv)
{
  PA_Init();
  PA_InitVBL();

  PA_Init3D(); // Regular init for the 3D sprite system
  PA_Reset3DSprites();

  PA_InitText(0, 1);

  PA_OutputSimpleText(0, 4, 1, "Create texture from FAT");

  fatInitDefault(); // Init for libfat. Automatically sets up DLDI and everything else you need for basic FAT access.

  PA_FatInitAllBuffers(); // Initialize all the memory buffers used by the FAT loading system

  PA_FatSetBasePath("/DemoFiles/data");  // Set a base path from the card root to load your asset files from
                              // Within this base asset folder:
                              //      all background binaries should be in /bg/
                              //      sprite and sprite palette binaries in /sprites/
                              //      and RAW format sound files in /sfx/


// Load a sprite image from FAT to VRAM. It works just like PA_3DCreateTex!
  u16 gfx = PA_FatEasy3DCreateTex("pokekun", // Name of a texture binary created with PAGfx (without "_Texture.bin")
                                  32, // Texture width
                                  64, // Texture height
                                  TEX_256COL); // 256 color texture (see TEX_16COL, TEX_4COL, etc.)


// Create a palette for the 3D sprites that will be created later. It works just like PA_Load3DSpritePal!
  PA_FatEasyLoad3DSpritePal(0, // Sprite palette number
                            "pokekun"); // Name of a palette binary in EFS created by PAGfx (without the "_Pal.bin")


  PA_OutputSimpleText(0, 1, 22, "Press A to create a 3D sprite!");

  u16 nsprites0 = 0; // Number of 3D sprites created

  while(1)
  {

    if (Pad.Newpress.A && nsprites0 < 1024) // You can have 1024 3D sprites!!!
    {
// Since the sprite is already in VRAM you can just use the normal PA_3DCreateSpriteFromTex function
      PA_3DCreateSpriteFromTex(nsprites0, // Next sprite to load...
                               gfx, // texture in VRAM to use, no image copying !
                               32, 64, 0, PA_RandMax(240), PA_RandMax(160)); // The rest is like normal 3D sprites

      ++nsprites0; // Next time, load the next sprite number
    }

    PA_WaitForVBL();
    PA_3DProcess();
  }

  return 0;
}
Beispiel #13
0
int main(int argc, char ** argv)
{
  PA_Init();
  PA_InitVBL();

  PA_InitText(0, 0);

  PA_OutputSimpleText(0, 5, 1, "FAT loading of sounds");

// Init ASlib before you play sounds
  AS_Init(AS_MODE_SURROUND | AS_MODE_16CH);
  AS_SetDefaultSettings(AS_PCM_8BIT, 11025, AS_NO_DELAY);

  fatInitDefault(); // Init for libfat. Automatically sets up DLDI and everything else you need for basic FAt access.

  PA_FatInitAllBuffers(); // Initialize all the memory buffers used by the FAT loading system

  PA_FatSetBasePath("DemoFiles/data");  // Set a base path from the card root to load your asset files from
                              // Within this base asset folder:
                              //      all background binaries should be in /bg/
                              //      2D and 3D sprite and palette binaries in /sprites/
                              //      and RAW format sound files in /sfx/


// Load a couple RAW format sounds from card FAT into memory for playback later.
  PA_FatLoadSfx("SFX_1", // A reference name for the loaded sound
                "saberoff"); // The name of sound effect in EFS to load (minus the ".RAW" extension)
  PA_FatLoadSfx("SFX_2", "sfxb");


  while(1)
  {
    PA_OutputSimpleText(0, 0, 4, "Press A/B to play loaded sounds.");

    PA_OutputSimpleText(0, 0, 6, "Or press R to load other sounds.");

    if(Pad.Newpress.A) PA_FatPlaySfx("SFX_1"); // Play a sound file loaded with PA_FatLoadSfx using its reference name
    if(Pad.Newpress.B) PA_FatPlaySfx("SFX_2");

    if(Pad.Newpress.R)
    {
// You can unload a previously loaded sound file to free its slot in memory.
      PA_FatUnloadSfx("SFX_1"); // Unload a sound file using the reference name assigned with PA_FatLoadSfx
      PA_FatUnloadSfx("SFX_2");

// Now you can load some more.
      PA_FatLoadSfx("SFX_1", "laserpower");
      PA_FatLoadSfx("SFX_2", "boi-oing");
// Actually, since you have 32 sound slots, we didn't need to unload the previous ones, but this is a demo!

    }

    PA_WaitForVBL();
  }

  return 0;
}
Beispiel #14
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_InitText(1, 0);  // Initialise the text system
	
	PA_InitCustomKeyboard(2, keyboardcustom); // Load the keyboard on background 2...
	
	PA_KeyboardIn(20, 95); // This scrolls the keyboard from the bottom, until it's at the right position
	// PA_KeyboardOut() can be used to scroll the Keyboard out
	// PA_ScrollKeyboardXY(x, y) can be used to set the keyboards position
	
	
	PA_OutputSimpleText(1, 7, 10, "Text : "); 

	s32 nletter = 0; // Next letter to right. 0 since no letters are there yet
	char letter = 0; // New letter to write.
	
	// Infinite loop to keep the program running
	while (1)
	{
		// We'll check first for color changes, with A, B, and X
		if (Pad.Newpress.A) PA_SetKeyboardColor(0, 1); // Blue and Red
		if (Pad.Newpress.B) PA_SetKeyboardColor(1, 0); // Red and Blue
		if (Pad.Newpress.X) PA_SetKeyboardColor(2, 1); // Green and Red
		if (Pad.Newpress.Y) PA_SetKeyboardColor(0, 2); // Blue and Green
		
		letter = PA_CheckKeyboard();
		
		if (letter > 31) { // there is a new letter
			text[nletter] = letter;
			nletter++;
		}
		else if(letter == PA_TAB){// TAB Pressed...
			u8 i;
			for (i = 0; i < 4; i++){ // put 4 spaces...
				text[nletter] = ' ';
				nletter++;
			}
	
		}
		else if ((letter == PA_BACKSPACE)&&nletter) { // Backspace pressed
			nletter--;
			text[nletter] = ' '; // Erase the last letter
		}
		else if (letter == '\n'){ // Enter pressed
			text[nletter] = letter;
			nletter++;
		}
		
		PA_OutputSimpleText(1, 8, 11, text); // Write the text
		PA_WaitForVBL();
	}
	
	return 0;
} // End of main()
Beispiel #15
0
// Function: main()
int main(int argc, char ** argv)
{
    PA_Init();    // Initializes PA_Lib
    PA_InitVBL(); // Initializes a standard VBL

    PA_InitText(1, 0);

    PA_EasyBgLoad(0, 1, pasplash); // Load your backgrounds...

    PA_InitBgTrans(0); // Init BgTransition system, uses background 0 but little memory...
    // If you want it to hide your sprites, set your sprites' priorities to 1 or more...

    u8 transtype = 0;

    s8 i;
    u8 vflip;

    // Infinite loop to keep the program running
    while (1)
    {
        vflip = PA_Rand()&1; // random
        transtype = PA_Rand()%5; // random

        PA_OutputText(1, 8, 8, "Transition : %d ", transtype);
        PA_OutputText(1, 10, 9, "Vflip : %d ", vflip);

        // Transition out...
        for (i = 0; i <= TRANS_LENGTH; i++) { // Fade length...
            PA_BgTransUpDown(0, // screen
                             transtype, // fade type, from 0 to 4, test them out !
                             vflip, // vertical flip
                             i); // Time, 0 being the screen completely visible, 32 completely out
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }

        vflip = PA_Rand()&1; // random
        transtype = PA_Rand()%5; // random

        PA_OutputText(1, 8, 8, "Transition : %d ", transtype);
        PA_OutputText(1, 10, 9, "Vflip : %d ", vflip);

        // Transition back in...
        for (i = TRANS_LENGTH; i >= 0; i--) { // Fade length...
            PA_BgTransUpDown(0, // screen
                             transtype, // fade type, from 0 to 4, test them out !
                             vflip, // vertical flip
                             i); // Time, 0 being the screen completely visible, 32 completely out
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }


        PA_WaitForVBL();
    }

    return 0;
} // End of main()
Beispiel #16
0
int main(void) {

    PA_Init();
    PA_InitVBL();

    PA_InitText(1,0); // On the top screen

    PA_DualLoadSpritePal(0, (void*)sprite0_Pal);

    // This'll be the movable sprite...
    PA_CreateSprite(0, 0,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 16, 16);
    s32 x = 16;
    s32 y = 16; // Sprite's center position

    // This will be the hit circle
    PA_DualCreateSprite(1,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 128-16, 96-16);
    puck.x = 128;
    puck.y = 96+192+SCREENHOLE; // central position on bottom screen
    puck.vx = 0;
    puck.vy = 0; // No speed


    while(1)
    {
        if (PA_MoveSprite(0)) {
            x = PA_MovedSprite.X;
            y = PA_MovedSprite.Y;
        }

        // Collision ?
        if (PA_Distance(x, y, puck.x, puck.y-192-SCREENHOLE) < 32*32) {
            // Collision, so we'l change the pucks speed to move it out of our 'raquette'
            u16 angle = PA_GetAngle(x, y, puck.x, puck.y-192-SCREENHOLE); // New direction angle
            u16 speed = (32*32-PA_Distance(x, y, puck.x, puck.y-192-SCREENHOLE))/32; // The closer they are, the harder the hit was...
            puck.vx = (PA_Cos(angle)*speed)>>8;
            puck.vy = -(PA_Sin(angle)*speed)>>8;
        }

        puck.x += puck.vx;
        puck.y += puck.vy;

        // If the sprite touches the left or right border, flip the horizontal speed
        if ((puck.x -16 <= 0) && (puck.vx < 0)) puck.vx = -puck.vx;
        else if ((puck.x + 16 >= 256)&&(puck.vx > 0)) puck.vx = - puck.vx;

        // Same thing, for top and bottom limits...
        if ((puck.y -16 <= 0) && (puck.vy < 0)) puck.vy = -puck.vy;
        else if ((puck.y + 16 >= 192 + 192 + SCREENHOLE)&& (puck.vy > 0)) puck.vy = - puck.vy;
        // The bottom limit is at the bottom of the bottom screen, so that would be 2 screen heights, plus the space in between...
        PA_DualSetSpriteXY(1, puck.x-16, puck.y-16);



        PA_WaitForVBL();
    }
Beispiel #17
0
// 싱글 플레이 초기화
void init_singleplay() {
 PA_LoadBackground(DOWN_SCREEN, BG2, &bg_stage1_init);
 PA_WaitForVBL();
 //UnLoad_Screen();
 //PA_WaitForVBL();
 ret_next(); // next state
 dualback_print(&stage2); // 게임배경화면 출력 (듀얼)

 /* 텍스트 출력 부분 */
 PA_InitText(DOWN_SCREEN, BG0);
 PA_SetTextTileCol(DOWN_SCREEN, TEXT_WHITE); //
}
Beispiel #18
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_Init3D(); // Uses Bg0
	PA_Reset3DSprites();
	
	// Initialise the text system on the top screen
	PA_InitText(0, 1);
	PA_InitText(1, 1);  // Initialise the text system on the top screen	
						
	PA_OutputSimpleText(1, 0, 6, "Move the Sprite with the stylus");	
	
	// First, create the gfx with the corresponding images and sizes. Images converted as 16bit sprites in PAGfx
	gfx[0] = PA_3DCreateTex((void*)mollusk_Texture, 64, 64, TEX_16BITS);	
	
	// Create 4 sprites for the different flips......
	PA_3DCreateSpriteFromTex(0, gfx[0], 64, 64, 	0,		80, 48); // X, Y SPRITE CENTER !
	PA_3DCreateSpriteFromTex(1, gfx[0], 64, 64, 	0,		80+96, 48); // X, Y SPRITE CENTER !	
	PA_3DCreateSpriteFromTex(2, gfx[0], 64, 64, 	0,		80, 80+64); // X, Y SPRITE CENTER !
	PA_3DCreateSpriteFromTex(3, gfx[0], 64, 64, 	0,		80+96, 80+64); // X, Y SPRITE CENTER !
	
	// Set the flips
	PA_3DSetSpriteHflip(0, 0);		PA_3DSetSpriteVflip(0, 0);
	PA_3DSetSpriteHflip(1, 1);		PA_3DSetSpriteVflip(1, 0);	
	PA_3DSetSpriteHflip(2, 0);		PA_3DSetSpriteVflip(2, 1);
	PA_3DSetSpriteHflip(3, 1);		PA_3DSetSpriteVflip(3, 1);	
		
	while(1) {


		PA_WaitForVBL();
		PA_3DProcess();  // Update sprites
	}


	
	return 0;
} // End of main()
Beispiel #19
0
// Function: main()
int main(int argc, char ** argv)
{
    PA_Init();    // Initializes PA_Lib
    PA_InitVBL(); // Initializes a standard VBL
    PA_InitText(1,1);
    Drawable cursor(0,0,0);
    cursor.Load(0, 0, (void*)pal_cursor, (void*)gfx_cursor, OBJ_SIZE_16X16, 1);
    setupRotations();
    u8 c = 0;
    u8 x = 0;
    u8 y = 0;
    for (y = 0; y != 8; ++y) {
        for (x = 0; x != 8; ++x) {
            u16 i = y*8+x;
            if (grid[i] == 1) {
                Tower tower = Tower(SPRITE_TOWER_BASE+c, x*16, y*16);
                tower.Load(0, 1, (void*)pal_tower, (void*)gfx_tower, OBJ_SIZE_16X16, 1);
                tower_list.push_back(tower);
                PA_SetSpriteRotEnable(0, tower.sprite, c);
                ++c;
            }
        }
    }

    s16 angle = 0;

	// Infinite loop to keep the program running
	while (1)
	{
	    u8 i = 0;
        for (tlist_it it = tower_list.begin(); it != tower_list.end(); ++it) {
            angle = (*it).GetAngleTo(cursor);
            PA_SetRotsetNoZoom(0, i, angle);
            ++i;
        }
        PA_OutputText(1, 0, 0, "Angle: %03d", angle);
        PA_OutputText(1, 0, 1, "Angle2: %03d", angle);
        PA_OutputText(1, 0, 2, "Cursor: %03d,%03d", cursor.position.x, cursor.position.y);
        if (Stylus.Held) {
            cursor.position.x = Stylus.X;
            cursor.position.y = Stylus.Y;
        } else {
            cursor.position.x += (Pad.Held.Right - Pad.Held.Left);
            cursor.position.y += (Pad.Held.Down - Pad.Held.Up);
        }
        cursor.Draw();
        PA_WaitForVBL();
	}

	return 0;
} // End of main()
Beispiel #20
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	// Initialise the text system on the top screen
	PA_InitText(0, // Bootom screen
				0);  	// Background number, from 0-3, on which to load the text system
	PA_InitText(1, 0);  // Initialise the text system on the top screen

	PA_SetTextCol(0, // Bottom screen
				0, // No red
				31, // Maximum green
				0); // No blue
	// This'll put a green color on the bottom screen... Color component (red, green, blue) range from 0 to 31

	u32 nletters = 0; // Number of letter to output...
	u32 letter = 0; // Current letter written...
	
	while (letter == nletters){ // Do this until the function outputs all the text
		++nletters; // Next frame, one more letter...	
		// This text function outputs a given number of letters... This way, it can do as if you were typing !
		letter = PA_BoxText(1, 2, 2, 29, 15, "Hi there :p  Cool, the function works perfectly ! So you see the text being typed...", nletters);
		PA_WaitForVBL(); // You can set more WaitForVBL if you want to slow down the text output...
	}

	PA_OutputSimpleText(0, 10, 10, "Finished !"); // Finished...


	// Infinite loop to keep the program running
	while (1){

		PA_WaitForVBL();
		
	}
	
	return 0;
} // End of main()
Beispiel #21
0
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
    PA_InitWifi();
    PA_ConnectWifiWFC();
    
	// Initialise the text system on the top screen
	PA_InitText(0,0);
	PA_InitText(1, 0);

	char *buffer2 = malloc(256*256);

    PA_GetHTTP(buffer2, "http://www.google.be/index.html");
    PA_OutputText(1,0,0,"r: %s",buffer2);
	while (1)
	{
		PA_WaitForVBL();
	}
	
	return 0;
} // End of main()
Beispiel #22
0
// Function: main()
int main(int argc, char ** argv)
{
    PA_Init();    // Initializes PA_Lib
    PA_InitVBL(); // Initializes a standard VBL

    PA_InitText(1, 0);

    PA_EasyBgLoad(0, 1, pasplash); // Load your backgrounds...

    u8 fadetype0 = 0;

    s8 i;

    // Infinite loop to keep the program running
    while (1)
    {


        // First we fade out... to fade out, move the time from 0 to 32, 32 included !
        for (i = 0; i <= 32; i++) {
            PA_WindowFade(0, // screen
                          fadetype0, // fade type, from 0 to 7, test them out !
                          i); // Time, 0 being the screen completely visible, 32 completely out
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }


        fadetype0 = PA_Rand()&7; // Random fade type for screen 0... from 0 to 7
        PA_OutputText(1, 8, 9, "Window Fade : %d  ", fadetype0);


        // To fade in, same thing, but from 32 to 0 included...
        for (i = 32; i >= 0; i--) {
            PA_WindowFade(0, fadetype0, i);
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }

        fadetype0 = PA_Rand()&7; // Random fade type for screen 0...
        PA_OutputText(1, 8, 9, "Window Fade : %d  ", fadetype0);



        PA_WaitForVBL();
    }

    return 0;
} // End of main()
Beispiel #23
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_Init3D(); // Uses Bg0, Init 3D...
	PA_Reset3DSprites(); // Init or Reset 3D Sprites
	
	
	// Initialise the text system on the top screen
	PA_InitText(1, 1);  // Initialise the text system on the top screen	
						
	PA_OutputSimpleText(1, 0, 8, "Move 3DSprite to change priority");	
	
	// First, create the gfx with the corresponding images and sizes. Images converted as 256colors textures in PAGfx
	gfx[0] = PA_3DCreateTex((void*)mollusk_Texture,  // Texture
									64, 64,						// Width, Height
									TEX_256COL );				// Texture Format

	
	// Load the Palettes !
	PA_Load3DSpritePal(0, // Slot
							(void*)mollusk_Pal); // Palette

	// Create a few sprites
	PA_3DCreateSpriteFromTex(0, gfx[0], 	64, 64, 	0, 	128, 96);

	u8 i;
	for(i = 0; i < 24; i++){
	   PA_3DCreateSpriteFromTex(i+1, gfx[0], 	64, 64, 	0, 	32, i*8);
	   PA_3DSetSpritePrio(i+1, 1024 + i*8); // Priority... (default is 1024)
	}   

	while(1) {
		if(Stylus.Held) {
		   PA_3DSetSpriteXY(0, Stylus.X, Stylus.Y);
		   PA_3DSetSpritePrio(0, 1024 + Stylus.Y); // Priority depending on Y position...
		}   

		PA_WaitForVBL();
		PA_3DProcess();  // Update sprites
	}


	
	return 0;
} // End of main()
Beispiel #24
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_InitText(1, 0);
	PA_OutputText(1,3,2, "--- BG Alpha Example ---");
	PA_OutputText(1,3,4, "D-Pad Left :    Alpha1--");
	PA_OutputText(1,3,5, "D-Pad Right:    Alpha1++");
	PA_OutputText(1,3,6, "D-Pad Up   :    Alpha2--");
	PA_OutputText(1,3,7, "D-Pad Down :    Alpha2++");

	//turn on alpha....
	PA_EnableSpecialFx(0, SFX_ALPHA, SFX_BG0 | SFX_BG1 | SFX_BG2 | SFX_BG3 | SFX_OBJ | SFX_BD, SFX_BG0 | SFX_BG1 | SFX_BG2 | SFX_BG3 | SFX_OBJ | SFX_BD);

	// Load the Backgrounds
	PA_EasyBgLoad(0, 0, bg0);	
	PA_EasyBgLoad(0, 1, bg1);	
	
	int alpha1 = 15;
	int alpha2 = 15;
	PA_SetSFXAlpha(0, alpha1, alpha2);
	// Infinite loop to keep the program running
	while (1)
	{
      
		if (Pad.Newpress.Left && alpha1 > 0) alpha1--;
		else if (Pad.Newpress.Right && alpha1 < 31) alpha1++;

		if (Pad.Newpress.Down && alpha2 > 0) alpha2--;
		else if (Pad.Newpress.Up && alpha2 < 31) alpha2++;

		//update the alpha values
		PA_SetSFXAlpha(0, alpha1, alpha2);
		
		PA_OutputText(1,2,9, "Alpha 1: %d   ", alpha1);
		PA_OutputText(1,2,10, "Alpha 2: %d   ", alpha2);

		PA_WaitForVBL();
      
      
      
	}
	
	return 0;
} // End of main()
Beispiel #25
0
// Main function
int main(void)	{
	// PAlib init
	PA_Init();
	PA_InitVBL();
	
	PA_Init3D();
	PA_Reset3DSprites();
	
	PA_InitText(1, 0);

	PA_Load3DSpritePal(0, (void*)som_Pal);	// Palette....	

	s32 x = 128; s32 y = 96;

	PA_3DCreateSprite(0,(void*)som_Texture, 32, 32, TEX_256COL, 0, x, y); // Sprite
	
	while(1)
	{
		// Animation code...
		if(Pad.Newpress.Up) PA_3DStartSpriteAnim(0, 0, 3, 6);
		if(Pad.Newpress.Down) PA_3DStartSpriteAnim(0, 8, 11, 6);		
		
		if(Pad.Newpress.Right) {
			PA_3DStartSpriteAnim(0, 4, 7, 6);	
			PA_3DSetSpriteHflip(0, 0);
		}
		if(Pad.Newpress.Left) {
			PA_3DStartSpriteAnim(0, 4, 7, 6);	
			PA_3DSetSpriteHflip(0, 1);
		}

		
		if(!((Pad.Held.Left)||(Pad.Held.Up)||(Pad.Held.Down)||(Pad.Held.Right))) PA_3DSpriteAnimPause(0, 1);
	
	
		// Moving Code
		y += Pad.Held.Down - Pad.Held.Up;
		x += Pad.Held.Right - Pad.Held.Left;		
		PA_3DSetSpriteXY(0, x, y);
	
		PA_WaitForVBL();
		PA_3DProcess(); // Update 3D...
	}
	
	return 0;
}
Beispiel #26
0
// Function: main()
int main(int argc, char ** argv) {
    PA_Init();    // Initializes PA_Lib
    PA_InitVBL(); // Initializes a standard VBL

    PA_SetVideoMode(0, 2);  //screen, mode

    PA_LoadPAGfxRotBg(0, //screen
                      3, // background number
                      Rot, // background name in PAGfx
                      1); // wraparound !

    PA_InitText(1, 0);

    // Infinite loop to keep the program running
    s32 scrollx = 0;
    s32 scrolly = 0;
    s32 rotcenterx = 0;
    s32 rotcentery = 0;
    s16 angle = 0;
    s32 zoom = 256;

    PA_OutputSimpleText(1, 2, 2, "Zoom       : Start/Select");
    PA_OutputSimpleText(1, 2, 3, "ScrollX    : Left/Right");
    PA_OutputSimpleText(1, 2, 4, "Scrolly    : Up/Down");
    PA_OutputSimpleText(1, 2, 5, "RotCenterX : A/Y");
    PA_OutputSimpleText(1, 2, 6, "RotCenterY : B/X");
    PA_OutputSimpleText(1, 2, 7, "Angle      : R/L");


    while (1)
    {
        zoom += Pad.Held.Start - Pad.Held.Select;
        scrollx += Pad.Held.Right - Pad.Held.Left;
        scrolly += Pad.Held.Down - Pad.Held.Up;
        rotcenterx += Pad.Held.A - Pad.Held.Y;
        rotcentery += Pad.Held.B - Pad.Held.X;
        angle += Pad.Held.R - Pad.Held.L;

        PA_SetBgRot(0, 3, scrollx, scrolly, rotcenterx, rotcentery, angle, zoom);

        PA_WaitForVBL();
    }

    return 0;
} // End of main()
Beispiel #27
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;
}
Beispiel #28
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_InitText(1, 0);
	
	PA_SetBrightness(0, 31);
	
	PA_Init8bitBg(0, 3);
	PA_LoadGif(0, (void*)test);
	


	irqSet(IRQ_HBLANK, HBL_function);
	irqEnable(IRQ_HBLANK);
	
	u8 i;
	level = 0; 
	while(1){
	   PA_OutputText(1, 8, 10, "Fading in, white  ");
		for(level = 0; level < 80; level++) PA_WaitForVBL();
		for(i = 0; i < 60; i++) PA_WaitForVBL(); // Wait 1 second
		
		black = 1;
		PA_OutputText(1, 8, 10, "Fading out, black ");
		for(level = 80; level > 0; level--) PA_WaitForVBL();	
		for(i = 0; i < 60; i++) PA_WaitForVBL(); // Wait 1 second
		
	   PA_OutputText(1, 8, 10, "Fading in, black  ");
		for(level = 0; level < 80; level++) PA_WaitForVBL();
		for(i = 0; i < 60; i++) PA_WaitForVBL(); // Wait 1 second				
		
		black = 0;		
		PA_OutputText(1, 8, 10, "Fading out, white ");
		for(level = 80; level > 0; level--) PA_WaitForVBL();
		for(i = 0; i < 60; i++) PA_WaitForVBL(); // Wait 1 second		
	}		

	return 0;
} // End of main()
Beispiel #29
0
///Main function...
int main(void){


	//PAlib Init
	PA_Init();
	PA_InitVBL();
	
	PA_InitText(0,0); // On the bottom screen
		
	PA_VBLFunctionInit(MyVBLFunction); // Init the function to be executed every frame... You can remove it by using PA_VBLFunctionReset();
	
	while(1){  // No code beside the text output in the main loop, everything will be done in the VBL for once :)
	
		PA_OutputText(0, 2, 10, "Counter : %d", MyCounter); //    /60 to get seconds

	
		PA_WaitForVBL();
		//La boucle infinie du programme
	}
	return 0;
}
Beispiel #30
0
// Function: main()
int main(int argc, char ** argv)
{
  PA_Init();    // Initializes PA_Lib
  PA_InitVBL(); // Initializes a standard VBL

// Initialise the text system on the top screen
  PA_InitText(1, 0);

// This'll put a green color on the bottom screen... Color component (red, green, blue) range from 0 to 31
  PA_SetTextCol(0, 0, 31, 0);

// The same old PA_OutputSimpleText, but now with newline support
  PA_OutputSimpleText(1, 1, 1, "          ATTENTION:\n\nPA_OutputSimpleText now has\nsupport for line breaking in\nthe body of the text. So it's\nmuch easier to place a lot of\ntext on the screen.\n\nThis should be really useful\nif you need to parse a text\nfile loaded from FAT!");

// It works with PA_OutputText, as well
  PA_OutputText(1, 1, 13, "But wait, that's not all! It\nalso works with variables in\nPA_OutputText.\n\nWhat do you think of that,\n%s?\n\nIt's %d:%02d, do you know\nwhere your text is?", PA_UserInfo.Name, PA_RTC.Hour, PA_RTC.Minutes);

  while (1) {PA_WaitForVBL();}

  return 0;
} // End of main()