示例#1
0
// creates the block and all associated BOBs
void Block::CreateBlock(BlockType type, BOB_PTR block, int x, int y)
{
	m_type = type;
	// load square bitmap
		
	// clone the squares

	for( int i=0; i<MAX_SQUARES_PER_BLOCK; ++i )
		Clone_BOB( block, &(m_squares[i].m_bob));


    //edit location of main block
	m_x = x;
	m_y = y;
	m_squares[0].m_rotIndex = CENTER;
	for( int i=0; i<MAX_SQUARES_PER_BLOCK; ++i )
	{
		m_squares[i].m_bob.x = (float)x;
		m_squares[i].m_bob.y = (float)y;
	}


	// organize the remaining squares to their proper locations
	// according to the passed in 'type'

	FillToType( m_type );
    
	//keep track of their row and column
	TrackRowColumn();
}
示例#2
0
Block::Block( const Block& block) :
   m_logger(block.m_logger)
{
	m_type = block.m_type;
	m_x = block.m_x;
	m_y = block.m_y;
	for( int i=0; i<MAX_SQUARES_PER_BLOCK; ++i )
	{	
		m_squares[i].m_rotIndex = block.m_squares[i].m_rotIndex;
		m_squares[i].m_col = block.m_squares[i].m_col;
		m_squares[i].m_row = block.m_squares[i].m_row;

      // HAUKAP - something needs to be done about this....
      Block* non_const_block = const_cast<Block*>(&block);
		Clone_BOB( &(non_const_block->m_squares[i].m_bob), &(m_squares[i].m_bob) );
	}
}
int Game_Init(void *parms,  int num_parms)
{
// this function is where you do all the initialization 
// for your game

int index;         // looping var
char filename[80]; // used to build up files names

// seed random number generator
srand(Get_Clock());

// initialize directdraw, very important that in the call
// to setcooperativelevel that the flag DDSCL_MULTITHREADED is used
// which increases the response of directX graphics to
// take the global critical section more frequently
DDraw_Init(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP);

// load in the alien bob image
Load_Bitmap_File(&bitmap8bit, "ALIENSGLOW.BMP");

// set the palette to the palette of the aliens
Set_Palette(bitmap8bit.palette);

// create the master alien bob
if (!Create_BOB(&aliens[0],0,0,48,47,1, 
                BOB_ATTR_VISIBLE | BOB_ATTR_SINGLE_FRAME | BOB_ATTR_BOUNCE,DDSCAPS_SYSTEMMEMORY ))
   return(0);

// load the bitmap for alien -- only 1
Load_Frame_BOB(&aliens[0],&bitmap8bit,0,0,0,BITMAP_EXTRACT_MODE_CELL); 

// unload the map bitmap
Unload_Bitmap_File(&bitmap8bit);

// now create all the alien clones :)
for (index = 1; index < NUM_ALIENS; index++)
    Clone_BOB(&aliens[0],&aliens[index]);

// at this point everything has been cloned, now set up aliens at
// random positions
for (index = 0; index < NUM_ALIENS; index++)
    {
    // set position
    Set_Pos_BOB(&aliens[index], rand()%screen_width, rand()%screen_height);

    // set motion velocities
    Set_Vel_BOB(&aliens[index],-4+rand()%8, -4+rand()%8);

    } // end for index

// set clipping rectangle to screen extents so mouse cursor
// doens't mess up at edges
RECT screen_rect = {0,0,screen_width,screen_height}; 
lpddclipper = DDraw_Attach_Clipper(lpddsback,1,&screen_rect);

// hide the mouse
ShowCursor(FALSE);

#ifdef USE_MULTITHREADING
// create the animation thread for color rotation
thread_handle = CreateThread(NULL,               // default security
			                    0,				    // default stack 
								Alien_Color_Thread,// use this thread function
								(LPVOID)index,      // user data sent to thread
								0,				    // creation flags, 0=start now.
								&thread_id);	// send id back in this var

    // increment number of active threads
    active_threads++;

#endif
 
// return success
return(1);

} // end Game_Init
int Game_Init(void *parms)
{
// this function is where you do all the initialization 
// for your game

int index; // looping varsIable

char filename[80]; // used to build up filenames

// seed random number generate
srand(Start_Clock());

// initialize directdraw, very important that in the call
// to setcooperativelevel that the flag DDSCL_MULTITHREADED is used
// which increases the response of directX graphics to
// take the global critical section more frequently
DDraw_Init(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP, WINDOWED_APP);

// load background image
Load_Bitmap_File(&bitmap8bit, "GREENGRID24.BMP");
Create_Bitmap(&background_bmp,0,0,640,480,16);
Load_Image_Bitmap16(&background_bmp, &bitmap8bit,0,0,BITMAP_EXTRACT_MODE_ABS);
Unload_Bitmap_File(&bitmap8bit);

// load the bitmaps
Load_Bitmap_File(&bitmap8bit, "POOLBALLS24.BMP");

// create master ball
Create_BOB(&balls[0],0,0,24,24,6,BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY,0,16);

// load the imagery in
for (index=0; index < 6; index++)
    Load_Frame_BOB16(&balls[0], &bitmap8bit, index, index,0,BITMAP_EXTRACT_MODE_CELL);

// create all the clones
for (index=1; index < NUM_BALLS; index++)
    Clone_BOB(&balls[0], &balls[index]);

// now set the initial conditions of all the balls
for (index=0; index < NUM_BALLS; index++)
    {
    // set position randomly
    balls[index].varsF[INDEX_X] = RAND_RANGE(TABLE_MIN_X+20,TABLE_MAX_X-20);
    balls[index].varsF[INDEX_Y] = RAND_RANGE(TABLE_MIN_Y+20,TABLE_MAX_Y-20);

    // set initial velocity
    balls[index].varsF[INDEX_XV] = RAND_RANGE(-100, 100)/15;
    balls[index].varsF[INDEX_YV] = RAND_RANGE(-100, 100)/15;

    // set mass of ball in virtual kgs :)
    balls[index].varsF[INDEX_MASS] = 1; // 1 for now

    // set ball color
    balls[index].curr_frame = rand()%6;

    } // end for index

// unload bitmap image
Unload_Bitmap_File(&bitmap8bit);

// hide the mouse
if (!WINDOWED_APP)
   ShowCursor(FALSE);

// initialize directinput
DInput_Init();

// acquire the keyboard only
DInput_Init_Keyboard();

// initilize DirectSound
DSound_Init();

// load background sounds
ball_ids[0] = DSound_Load_WAV("PBALL.WAV");

// clone sounds
for (index=1; index<8; index++)
    ball_ids[index] = DSound_Replicate_Sound(ball_ids[0]);


// set clipping region
min_clip_x = TABLE_MIN_X;
min_clip_y = TABLE_MIN_Y;
max_clip_x = TABLE_MAX_X;
max_clip_y = TABLE_MAX_Y;

// return success
return(1);

} // end Game_Init
int Game_Init(void *parms)
{
// this function is where you do all the initialization 
// for your game

int index; // looping varsIable

char filename[80]; // used to build up filenames

// seed random number generate
srand(Start_Clock());

// initialize directdraw, very important that in the call
// to setcooperativelevel that the flag DDSCL_MULTITHREADED is used
// which increases the response of directX graphics to
// take the global critical section more frequently
DDraw_Init(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP, WINDOWED_APP);

// load background image
Load_Bitmap_File(&bitmap8bit, "GREENGRID24.BMP");
Create_Bitmap(&background_bmp,0,0,640,480,16);
Load_Image_Bitmap16(&background_bmp, &bitmap8bit,0,0,BITMAP_EXTRACT_MODE_ABS);
Unload_Bitmap_File(&bitmap8bit);

// load the bitmaps
Load_Bitmap_File(&bitmap8bit, "POOLBALLS24.BMP");

// create master ball
Create_BOB(&balls[0],0,0,24,24,6,BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY,0,16);

// load the imagery in
for (index=0; index < 6; index++)
    Load_Frame_BOB16(&balls[0], &bitmap8bit, index, index,0,BITMAP_EXTRACT_MODE_CELL);

// create all the clones
for (index=1; index < NUM_BALLS; index++)
    Clone_BOB(&balls[0], &balls[index]);

// now set the initial conditions of all the balls
for (index=0; index < NUM_BALLS; index++)
    {
    // set position in center of object
    balls[index].varsF[INDEX_X] = RAND_RANGE( SHAPE_CENTER_X-50,  SHAPE_CENTER_X+50);
    balls[index].varsF[INDEX_Y] = RAND_RANGE( SHAPE_CENTER_Y-50,  SHAPE_CENTER_Y+50);

   do
    {
    // set initial velocity
    balls[index].varsF[INDEX_XV] = RAND_RANGE(-100, 100)/30;
    balls[index].varsF[INDEX_YV] = RAND_RANGE(-100, 100)/30;
    }
    while (balls[index].varsF[INDEX_XV]==0 && balls[index].varsF[INDEX_XV]==0);

    // set ball color
    balls[index].curr_frame = rand()%6;

    } // end for index

// unload bitmap image
Unload_Bitmap_File(&bitmap8bit);

// define points of shape
VERTEX2DF shape_vertices[10] =  
{ 328-SHAPE_CENTER_X,60-SHAPE_CENTER_Y,
  574-SHAPE_CENTER_X,162-SHAPE_CENTER_Y,
  493-SHAPE_CENTER_X,278-SHAPE_CENTER_Y,
  605-SHAPE_CENTER_X,384-SHAPE_CENTER_Y,
  484-SHAPE_CENTER_X,433-SHAPE_CENTER_Y,
  306-SHAPE_CENTER_X,349-SHAPE_CENTER_Y,
  150-SHAPE_CENTER_X,413-SHAPE_CENTER_Y,
  28-SHAPE_CENTER_X,326-SHAPE_CENTER_Y,
  152-SHAPE_CENTER_X,281-SHAPE_CENTER_Y,
  73-SHAPE_CENTER_X,138-SHAPE_CENTER_Y };
 

// initialize shape
shape.state       = 1;   // turn it on
shape.num_verts   = 10;  
shape.x0          = SHAPE_CENTER_X;
shape.y0          = SHAPE_CENTER_Y;
shape.xv          = 0;
shape.yv          = 0;
shape.color       = RGB16Bit(0,255,0); // green
shape.vlist       = new VERTEX2DF [shape.num_verts];
 
for (index = 0; index < shape.num_verts; index++)
    shape.vlist[index] = shape_vertices[index];

// hide the mouse
if (!WINDOWED_APP)
   ShowCursor(FALSE);

// initialize directinput
DInput_Init();

// acquire the keyboard only
DInput_Init_Keyboard();

// build the 360 degree look ups
Build_Sin_Cos_Tables();

// initilize DirectSound
DSound_Init();

// load background sounds
ball_ids[0] = DSound_Load_WAV("PBALL.WAV");

// clone sounds
for (index=1; index<8; index++)
    ball_ids[index] = DSound_Replicate_Sound(ball_ids[0]);

// return success
return(1);

} // end Game_Init
int Game_Init(void *parms)
{
// this function is where you do all the initialization 
// for your game

int index; // looping variable

// initialize directdraw, very important that in the call
// to setcooperativelevel that the flag DDSCL_MULTITHREADED is used
// which increases the response of directX graphics to
// take the global critical section more frequently
DDraw_Init(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP, WINDOWED_APP);

// load background image
Load_Bitmap_File(&bitmap16bit, "FLYBACK_24.BMP");
Create_Bitmap(&background_bmp,0,0,640,480,16);
Load_Image_Bitmap16(&background_bmp, &bitmap16bit,0,0,BITMAP_EXTRACT_MODE_ABS);
Unload_Bitmap_File(&bitmap16bit);

// load the fly bitmaps
Load_Bitmap_File(&bitmap16bit, "FLYS8_24.BMP");

// create master fly bob
Create_BOB(&flys[0],320,200, 8,8, 4, BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY, 0, 16);
Set_Anim_Speed_BOB(&flys[0], 1);

// load the fly in 
for (index=0; index<4; index++)
    Load_Frame_BOB16(&flys[0], &bitmap16bit, index, index, 0, BITMAP_EXTRACT_MODE_CELL);

// unload flys
Unload_Bitmap_File(&bitmap16bit);

// now replicate flys
for (index = 1; index < MAX_FLYS; index++)
    Clone_BOB(&flys[0], &flys[index]);

// now set all of their values
for (index=0; index<MAX_FLYS; index++)
    {
    // set positions
    Set_Pos_BOB(&flys[index], 320-32+rand()%64, 450-rand()%32);

    // set start frame randomly
    flys[index].curr_frame = 0;

    } // end for index

// initilize DirectSound
DSound_Init();

// load fly sound
fly_sound_id = DSound_Load_WAV("FLYS.WAV");

// start the sound
DSound_Play(fly_sound_id, DSBPLAY_LOOPING);

// return success
return(1);

} // end Game_Init