示例#1
0
文件: main.c 项目: troy56/palibds
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;
}
示例#2
0
文件: main.c 项目: troy56/palibds
// 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()
示例#3
0
文件: main.c 项目: troy56/palibds
// 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;
}
示例#4
0
文件: main.c 项目: troy56/palibds
// 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()
示例#5
0
文件: main.c 项目: troy56/palibds
// Main function
int main(void)	{
	// PAlib init
	PA_Init();
	PA_InitVBL();
	
	PA_Init3D(); // Uses Bg0, Init 3D...
	PA_Reset3DSprites(); // Init or Reset 3D Sprites
	
		
	
	PA_InitText(1, 0);
	
	PA_OutputText(1, 0, 10, "Press Pad to change frame");
	
	// Load the sprite palette, 
	PA_Load3DSpritePal(0, // Palette number
					(void*)frames_Pal);	// Palette name
	
	gfx[0] = PA_3DCreateTex((void*)frames_Texture, 32, 32, TEX_256COL);
	
	PA_3DCreateSpriteFromTex(0, gfx[0], 	32, 32, 	0, 	128, 96);
	
	
	while(1)
	{
		if (Pad.Held.Up) PA_3DSetSpriteFrame(0, 0); // screen, sprite, frame
		if (Pad.Held.Down) PA_3DSetSpriteFrame(0, 2); // screen, sprite, frame
		if (Pad.Held.Left) PA_3DSetSpriteFrame(0, 3); // screen, sprite, frame
		if (Pad.Held.Right) PA_3DSetSpriteFrame(0, 1); // screen, sprite, frame		
	
		PA_WaitForVBL();
		PA_3DProcess();
	}
	
	return 0;
}
示例#6
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);  
}