Ejemplo n.º 1
0
/*
 * DrawMountainSlope
 *
 * Draw the mountains in the background of the game.
 */
void DrawMountainSlope (GdkPixmap *pixmap, 
                        typPoint *lastPt, 
                        typPoint *pt, 
                        int nTop, 
                        int nBottom)
{
    int x1;
    int x2;
    int nStart;
    int nEnd;
    int nHeight;

    nHeight = nBottom - nTop;
    nStart = hero->x - (nScreenWidth / 2);
    nEnd = hero->x + (nScreenWidth / 2);

    x1 = ScreenX (lastPt->x);
    x2 = ScreenX (pt->x);

    if ((x2 < 0) || 
        (x1 > nScreenWidth)) {

        /* ---  Do nothing --- */

    } else {

        /* --- Draw point --- */
        gdk_draw_line (pixmap, penWhite,
                   ScreenX (lastPt->x),
                   (int) (nBottom - ((lastPt->y * nHeight) / MAX_PEAK)),
                   ScreenX (pt->x),
                   (int) (nBottom - ((pt->y * nHeight) / MAX_PEAK)));
    }
}
Ejemplo n.º 2
0
NS_IMETHODIMP
MouseEvent::GetScreenX(int32_t* aScreenX)
{
  NS_ENSURE_ARG_POINTER(aScreenX);
  *aScreenX = ScreenX();
  return NS_OK;
}
Ejemplo n.º 3
0
void
ChartRenderer::DrawXGrid(double tic_step, const Pen &pen,
                         double unit_step, bool draw_units)
{
  assert(tic_step > 0);

  canvas.Select(pen);
  canvas.Select(look.axis_value_font);
  canvas.SetBackgroundTransparent();

  RasterPoint line[2];

  /** the minimum next position of the text, to avoid overlapping */
  int next_text = rc.left;

  /* increase tic step so graph not too crowded */
  while ((x.max - x.min) / tic_step > 10) {
    tic_step *= 2;
    unit_step *= 2;
  }
  //  bool do_units = ((x.max-zero)/tic_step)<10;

  line[0].y = rc.top;
  line[1].y = rc.bottom - padding_bottom;

  const int y = line[1].y - canvas.GetFontHeight();

  auto start = (int)(x.min / tic_step) * tic_step;

  for (auto xval = start; xval <= x.max; xval += tic_step) {
    const int xmin = ScreenX(xval);
    line[0].x = line[1].x = xmin;

    // STYLE_THINDASHPAPER
    if (xmin >= rc.left + padding_left && xmin <= rc.right) {
      canvas.DrawLine(line[0], line[1]);

      if (draw_units && xmin >= next_text) {
        TCHAR unit_text[MAX_PATH];
        FormatTicText(unit_text, xval * unit_step / tic_step, unit_step);

        canvas.DrawText(xmin, y, unit_text);

        next_text = xmin + canvas.CalcTextSize(unit_text).cx
          + Layout::GetTextPadding();
      }
    }
  }
}
Ejemplo n.º 4
0
/*
 * DisplayOtherUnits
 *
 * Display all the units on the screen. First, we need 
 * to move each of the units to their new positions. 
 * Some of this is done in the AI module. 
 * 
 */
void DisplayOtherUnits (GdkPixmap *pixmap, GtkWidget *drawing_area)
{
    typUnit *unit;
    typUnit *unitHit;
    GList *node;
    int xPos;
    int xPosEnd;
    typSprite *sprite;

    /* --- Each unit in the list --- */
    for (node = unitList; node; node = node->next) {
 
        /* --- Get the unit --- */
        unit = (typUnit *) node->data;

        /*  
         * --- Run the AI module on it to move it --- 
         */
        AIModule (unit);

        /* 
         * If the unit was destroyed by the AI, 
         * don't draw the unit.
         */
        if (unit->bDestroy) {
            continue;
        }

        /* 
         * If there's no sprite for the unit, 
         * we can't draw it now, can we?
         */
        sprite = GetSprite (unit);
        if (sprite == NULL) continue;
 
        /* --- Where on the screen is it going? --- */
        xPos = UnitScreenX (unit);

        /* --- Make sure unit doesn't go out of bounds --- */
        AdjustSpriteHeight (unit);

        /* --- Finally draw unit --- */
        DisplaySprite (drawing_area, sprite, 
                   (int) (xPos - sprite[0].width / 2), 
                   (int) (unit->y - sprite[0].height / 2));
    }

    /* 
     * --- once everyone is painted, fire the lasers.
     */

    for (node = unitList; node; node = node->next) {

        unit = (typUnit *) node->data;

        /* --- If this is a laser --- */
        if (unit->type == LASER) {
 
            /* --- Get starting and ending positions --- */
            xPos = ScreenX ((int) unit->x);
            xPosEnd = xPos + LASER_LENGTH * unit->direction;

            /* --- See if anything was hit --- */
            unitHit = AnyoneBetween ((int) xPos, (int) unit->y, 
                                     (int) xPosEnd, (int) unit->y);
            if (unitHit) {

                /* --- Something was hit --- */

                /* --- Laser shot only goes this far --- */
                xPosEnd = UnitScreenX (unitHit);

                /* --- Destroy the unit --- */
                unitHit->bDestroy = TRUE;
                unit->bDestroy = TRUE;

                /* --- Special effects of destruction --- */
                AddExplosion (unitHit);
            }

            /* --- Draw the laser --- */
            gdk_draw_line (pixmap, penWhite,
                           xPos, unit->y, 
                           xPosEnd,
                           unit->y);
            
            /* --- Get real coordinates of laser --- */
            unit->x = GameX (xPosEnd);

            /* --- If laser has gone too far... --- */
            if (DistanceBetween (unit, hero) > nScreenWidth / 2) {

                /* --- destroy it --- */
                unit->bDestroy = TRUE;
            }
        }
    }
}
Ejemplo n.º 5
0
NS_IMETHODIMP
Touch::GetScreenX(int32_t* aScreenX)
{
  *aScreenX = ScreenX();
  return NS_OK;
}
Ejemplo n.º 6
0
 gcc_pure
 RasterPoint ToScreen(fixed x, fixed y) const {
   return RasterPoint{ ScreenX(x), ScreenY(y) };
 }
Ejemplo n.º 7
0
 gcc_pure
 PixelPoint ToScreen(double x, double y) const {
   return PixelPoint{ ScreenX(x), ScreenY(y) };
 }