Ejemplo n.º 1
0
void uav2D_init(void) {
  // initialize uav2d
  uav2D.state       = 1;         // turn it on
  uav2D.num_verts   = 38;
  uav2D.x0          = eeprom_buffer.params.Atti_mp_posX;       // position it
  uav2D.y0          = eeprom_buffer.params.Atti_mp_posY;

  int index = 0, i = 0;
  const int lX = 5;
  const int stepY = 11;
  const int hX = 22;
  for (index = 0; index < uav2D.num_verts / 2 - 1; )
  {
    VECTOR2D_INITXYZ(&(uav2D.vlist_local[index]), -lX, stepY * (i + 1));
    VECTOR2D_INITXYZ(&(uav2D.vlist_local[index + 1]), lX, stepY * (i + 1));
    index += 2;
    i++;
  }
  VECTOR2D_INITXYZ(&(uav2D.vlist_local[index]), -hX, 0);
  VECTOR2D_INITXYZ(&(uav2D.vlist_local[index + 1]), hX, 0);
  index += 2;

  i = 0;
  for (; index < uav2D.num_verts; )
  {
    VECTOR2D_INITXYZ(&(uav2D.vlist_local[index]), -lX, -stepY * (i + 1));
    VECTOR2D_INITXYZ(&(uav2D.vlist_local[index + 1]), lX, -stepY * (i + 1));
    index += 2;
    i++;
  }


  // do a quick scale on the vertices
  Scale_Polygon2D(&uav2D, atti_mp_scale, atti_mp_scale);

  // initialize roll scale
  rollscale2D.state       = 1;         // turn it on
  rollscale2D.num_verts   = 13;
  rollscale2D.x0          = eeprom_buffer.params.Atti_mp_posX;       // position it
  rollscale2D.y0          = eeprom_buffer.params.Atti_mp_posY;


  int x, y, theta;
  int mp = (rollscale2D.num_verts - 1) / 2;
  i = mp;
  int radio = 38;
  int arcStep = (mp * 10) / 6;
  for (index = 0; index < mp; index++)
  {
    theta = i * arcStep;
    x = radio * Fast_Sin(theta);
    y = radio * Fast_Cos(theta);
    VECTOR2D_INITXYZ(&(rollscale2D.vlist_local[index]), -x, -y);
    VECTOR2D_INITXYZ(&(rollscale2D.vlist_local[rollscale2D.num_verts - 1 - index]), x, -y);
    i--;
  }

  VECTOR2D_INITXYZ(&(rollscale2D.vlist_local[index]), 0, -radio);
  Scale_Polygon2D(&rollscale2D, atti_mp_scale, atti_mp_scale);
}
Ejemplo n.º 2
0
int Game_Main(void *parms = NULL, int num_parms = 0)
{
// this is the main loop of the game, do all your processing
// here

// make sure this isn't executed again
if (window_closed)
   return(0);

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
   {
   PostMessage(main_window_handle,WM_CLOSE,0,0);
   window_closed = 1;
   } // end if

// clear out the back buffer
DDraw_Fill_Surface(lpddsback, 0);

// lock primary buffer
DDRAW_INIT_STRUCT(ddsd);

if (FAILED(lpddsback->Lock(NULL,&ddsd,
                           DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                           NULL)))
return(0);

// do the graphics
Draw_Polygon2D(&asteroid, (UCHAR *)ddsd.lpSurface, ddsd.lPitch);

// test for scale
if (KEYDOWN('A')) // scale up
   Scale_Polygon2D(&asteroid, 1.1, 1.1);
else
if (KEYDOWN('S')) // scale down
   Scale_Polygon2D(&asteroid, 0.9, 0.9);

// rotate the polygon by 5 degrees
Rotate_Polygon2D(&asteroid, 5);

// unlock primary buffer
if (FAILED(lpddsback->Unlock(NULL)))
   return(0);

// perform the flip
while (FAILED(lpddsprimary->Flip(NULL, DDFLIP_WAIT)));

// wait a sec
Sleep(33);

// return success or failure or your own return code here
return(1);

} // end Game_Main
Ejemplo n.º 3
0
void simple_attitude_init(void) {
  simple_attitude.state     = 1;
  simple_attitude.num_verts = 16;
  simple_attitude.x0        = eeprom_buffer.params.Atti_mp_posX;
  simple_attitude.y0        = eeprom_buffer.params.Atti_mp_posY;
  const int line_length = 10;
  const int line_spacing = 10;
  int x = 0;
  int i = 0;
  for (int index = 0; index < simple_attitude.num_verts; index += 4) {
    x = 12 + i * line_length + i * line_spacing + line_spacing;
    VECTOR2D_INITXYZ(&(simple_attitude.vlist_local[index]), -x, 0);
    VECTOR2D_INITXYZ(&(simple_attitude.vlist_local[index + 1]), -x - line_length, 0);
    VECTOR2D_INITXYZ(&(simple_attitude.vlist_local[index + 2]), x, 0);
    VECTOR2D_INITXYZ(&(simple_attitude.vlist_local[index + 3]), x + line_length, 0);
    i++;
  }
  Scale_Polygon2D(&simple_attitude, atti_mp_scale, atti_mp_scale);
}