Пример #1
0
void setupRound()
{
	// Clear Screen
	PA_ClearTextBg(SCREEN_TOP);
	
	// Reset paddles and ball
	PA_SetSpriteXY(SCREEN_BOTTOM,	BALL_BOTTOM,	-BALL_WIDTH, -BALL_HEIGHT);
	PA_SetSpriteXY(SCREEN_TOP,		BALL_TOP,		-BALL_WIDTH, -BALL_HEIGHT);
	
	ball.x 	= SCREEN_WIDTH/2-BALL_WIDTH/2;
	ball.y	= SCREEN_HEIGHT-BALL_HEIGHT/2;
	ball.vx = 1+((float)PA_RandMax(10)/10);
	ball.vy = -2-((float)PA_RandMax(5*game.score)/10);
	ball.ax = 0;
	ball.ay = 0;
	
	game.smartAI = 0;
	testBall.x = 0;
	testBall.y = 0;
	testBall.vx = 0;
	testBall.vy = 0;
	testBall.ax = 0;
	testBall.ay = 0;
	
	if(PA_RandMax(1)) ball.vx = -ball.vx;
	
	theirPaddle.x = SCREEN_WIDTH/2-PADDLE_WIDTH/2;
	theirPaddle.y = 0;
	
	myPaddle.x = SCREEN_WIDTH/2-PADDLE_WIDTH/2;
	myPaddle.y = SCREEN_HEIGHT-PADDLE_HEIGHT;
	
	game.gameover = false;
}
Пример #2
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;
}
Пример #3
0
void CDeck::pickCard(typecard* p_card, int p_playerID) {
  // Randomly pick a card in the deck
  p_card->first =  PA_RandMax(2);
  p_card->second = PA_RandMax(9);
  while (m_cardfrequency[*p_card] <= 0) {
    p_card->first  = PA_RandMax(2);
    p_card->second = PA_RandMax(9);
  }
  if (p_playerID == HUMAN_GET) {  // Receive the information
    p_card->first  = l_wifi.getIntInfo();
    p_card->second = l_wifi.getIntInfo();
  }
  if (p_playerID == HUMAN_SEND) {  // Send the information
    l_wifi.sendIntInfo(p_card->first);
    l_wifi.sendIntInfo(p_card->second);
  }
  m_cardfrequency[*p_card]--;
}
Пример #4
0
int _ds_objects_b11o06_manage(void *objp) {
   ds_t_object *object = objp;
   ds_t_object *particle;
   int res;

	res = ds_objects_lib_beh_disk(object, 1,
									 79, // 1.27 / 1.6
									 5, 2, 4,
									 -1, // ...
									 3, 4, 4);

	if (res) {
	   // Particle creation!
	   ds_music_playSound("DiscBullet", 0, 0);
	   int i,s,sx,sy;
	   for (i=0; i<17; i++) {
	      s = PA_RandMax(35) + 20; // Speed - RAND(35)+20
		   particle = ds_objects_createParticle(object->x + 8, object->y - 4, object->layer, 40);
		   if (i == 0) {
		      sy = 0;
		   } else if (i < 8) {
		      sy = 0 - ((s / 7) * i);
			} else if (i == 8) {
			   sy = -s;
			} else if (i < 16) {
			   sy = 0 - ((s / 7) * (16 - i));
			} else {
			   sy = 0;
			}       
			sx = (90 - (11.25 * i));        
		   if (sx > 0)
		   	sx = sqrt((s*s) - (sy*sy));
		   else
				sx = 0 - sqrt((s*s) - (sy*sy));
		   ds_objects_lib_beh_particleMMF2_Init(particle, 
						sx, 
						sy, 
				 		0, 20, 3);
	   }   
	   ds_objects_setBlink(object, DS_C_GAMESTATUS_BLINK);
	}   
      
   return 1;
}
Пример #5
0
int main(int argc, char ** argv)
{
  PA_Init();
  PA_InitVBL();

  PA_InitText(0, 0);

  PA_OutputSimpleText(0, 6, 1, "Create GFX 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/


  u16 gfx[2];

// Load a sprite image from FAT to VRAM. It works just like PA_CreateGfx!
  gfx[0] = PA_FatEasyCreateGfx(0, // Screen
                               "pokekun", // Name of a sprite binary created with PAGfx (without the "_Sprite.bin")
                               OBJ_SIZE_32X64, // Sprite size macro
                               1); // 256 color sprite

// Let's make another one for the top screen 
  gfx[1] = PA_FatEasyCreateGfx(1, "pokekun", OBJ_SIZE_32X64, 1);


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

// for the top screen, too
  PA_FatEasyLoadSpritePal(1, 0, "pokekun");


  PA_OutputSimpleText(0, 0, 20, "Press A to create a sprite on\nthe bottom screen, B for one on\nthe top screen");

  u8 nsprites0 = 0; // Number of sprites on the bottom screen
  u8 nsprites1 = 0; // Top screen

  while(1)
  {

    if (Pad.Newpress.A && nsprites0 < 128)
    {
// Since the sprite is already in VRAM you can just the normal PA_CreateSpriteFromGfx
      PA_CreateSpriteFromGfx(0, // screen
                             nsprites0, // Next sprite to load...
                             gfx[0], // image to use in memory, no image copying !
                             OBJ_SIZE_32X64, 1, 0, PA_RandMax(224), PA_RandMax(128)); // The rest is like normal sprites

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

    if (Pad.Newpress.B && nsprites1 < 128)
    {
      PA_CreateSpriteFromGfx(1, nsprites1, gfx[1], OBJ_SIZE_32X64, 1, 0, PA_RandMax(224), PA_RandMax(128));
      ++nsprites1;
    }

    PA_WaitForVBL();

  }

  return 0;
}