int Game_Main(void *parms, int num_parms)
{
// this is the workhorse of your game it will be called
// continuously in real-time this is like main() in C
// all the calls for you game go here!

int          index;             // looping var
int          dx,dy;             // general deltas used in collision detection


// check of user is trying to exit
if (KEY_DOWN(VK_ESCAPE) || KEY_DOWN(VK_SPACE))
    PostMessage(main_window_handle, WM_DESTROY,0,0);

// start the timing clock
Start_Clock();

// clear the drawing surface
DDraw_Fill_Surface(lpddsback, 0);

// get joystick data
lpdijoy->Poll(); // this is needed for joysticks only
lpdijoy->GetDeviceState(sizeof(DIJOYSTATE2), (LPVOID)&joy_state);

// lock the back buffer
DDraw_Lock_Back_Surface();

// draw the background reactor image
Draw_Bitmap16(&playfield, back_buffer, back_lpitch, 0);

// unlock the back buffer
DDraw_Unlock_Back_Surface();

// is the player moving?
blaster.x+=joy_state.lX;
blaster.y+=joy_state.lY;

// test bounds
if (blaster.x > SCREEN_WIDTH-32)
    blaster.x = SCREEN_WIDTH-32;
else
if (blaster.x < 0)
    blaster.x = 0;

if (blaster.y > SCREEN_HEIGHT-32)
    blaster.y = SCREEN_HEIGHT-32;
else
if (blaster.y < SCREEN_HEIGHT-128)
    blaster.y = SCREEN_HEIGHT-128;

// is player firing?
if (joy_state.rgbButtons[0])
   Start_Missile();

// move and draw missle
Move_Missile();
Draw_Missile();

// is it time to blink eyes
if ((rand()%100)==50)
   Set_Animation_BOB(&blaster,0);

// draw blaster
Animate_BOB(&blaster);
Draw_BOB16(&blaster,lpddsback);

// draw some text
Draw_Text_GDI("(16-Bit Version) Let's Rock!!!",0,0,RGB(255,255,255),lpddsback);

// display joystick and buttons 0-7
sprintf(buffer,"Joystick Stats: X-Axis=%d, Y-Axis=%d, buttons(%d,%d,%d,%d,%d,%d,%d,%d)",
                                                                      joy_state.lX,joy_state.lY,
                                                                      joy_state.rgbButtons[0],
                                                                      joy_state.rgbButtons[1],
                                                                      joy_state.rgbButtons[2],
                                                                      joy_state.rgbButtons[3],
                                                                      joy_state.rgbButtons[4],
                                                                      joy_state.rgbButtons[5],
                                                                      joy_state.rgbButtons[6],
                                                                      joy_state.rgbButtons[7]);

Draw_Text_GDI(buffer,0,SCREEN_HEIGHT-20,RGB(255,255,50),lpddsback);

// print out name of joystick
sprintf(buffer, "Joystick Name & Vendor: %s",joyname);
Draw_Text_GDI(buffer,0,SCREEN_HEIGHT-40,RGB(255,255,50),lpddsback);


// flip the surfaces
DDraw_Flip();

// sync to 30 fps
Wait_Clock(30);

// return success
return(1);

} // end Game_Main
Exemplo n.º 2
0
void update_drawing(cairo_t *cr)
{

	// if(Explosion_Flag)
	// {
	// 	// This actually does nothing the first time around
	// 	// explosion_step2 is sort of the inner, yellow circle, one step behind step1
	// 	for(int i = 0; i < Explosion_Step+1; i++)
	// 	{
	// 		explosion_step2(cr, ExpX, ExpY, i);
	// 	}
	// 	explosion_step1(cr, ExpX, ExpY, Explosion_Step);
	//
	// 	if((Explosion_Step * 10) >= ExpRadius)
	// 	{
	// 		Terminal_State = Terminal_State_Flag;
	// 		Explosion_Step = 0;
	// 		Explosion_Flag = 0;
	// 		set_initial_vals();
	// 	}
	// }
	// else if(Jitter_Flag)
	// {
	//
	// 	if(jitter_switch)
	// 	{
	// 		jitter_step1(cr, Jitter_Step);
	// 	}
	// 	else
	// 	{
	// 		jitter_step2(cr, Jitter_Step);
	// 	}
	//
	// 	if(Jitter_Step < 1)
	// 	{
	// 		Jitter_Step = 8;
	// 		Jitter_Flag = 0;
	// 	}
	// }

	Draw_Ship(cr, Ship_X_Pos,Ship_Y_Pos,Ship_Headings,SHIP_SIZE_FACTOR*MaxX);
	cairo_stroke(cr);
	Draw_Ship_Nose(cr, Ship_X_Pos,Ship_Y_Pos,Ship_Headings,SHIP_SIZE_FACTOR*MaxX);
	cairo_stroke(cr);

	Draw_Fort(cr, MaxX/2,MaxY/2,Fort_Headings,FORT_SIZE_FACTOR*MaxX);
	cairo_stroke(cr);

	for(int i=0;i<MAX_NO_OF_MISSILES;i++)
	{
		if (Missile_Flag[i]==ALIVE)
		{
			Draw_Missile(cr, Missile_X_Pos[i], Missile_Y_Pos[i], Missile_Headings[i], MISSILE_SIZE_FACTOR*MaxX, i);
			cairo_stroke(cr);
		}
	}
	if (Mine_Flag==ALIVE)
	{
		Draw_Mine(cr, Mine_X_Pos,Mine_Y_Pos,MINE_SIZE_FACTOR*MaxX);
		cairo_stroke(cr);
	}

	if(Shell_Flag==ALIVE)
	{
		Draw_Shell(cr, Shell_X_Pos,Shell_Y_Pos,Shell_Headings,SHELL_SIZE_FACTOR*MaxX);
		cairo_stroke(cr);
	}

//	Update_Points(cr);
//	Update_Velocity(cr);
//	Update_Speed(cr);
//	Update_Vulner(cr);
//	Update_Interval(cr);
//	Update_Shots(cr);
//	Update_Control(cr);

//	if(Mine_Flag==ALIVE)
//	{
//
//		Draw_Mine_Type(cr);
////		Mine_Type_Should_Update = 0;
//	}
//	if(Bonus_Char_Should_Update) // Set to always update (i.e. change nothing)
//	{
//		Draw_Bonus_Char(cr);
//		cairo_reset_clip(cr);
//	}

}