当前位置: 首页>>代码示例>>C++>>正文


C++ Graphics::Draw2DTextValue方法代码示例

本文整理汇总了C++中Graphics::Draw2DTextValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::Draw2DTextValue方法的具体用法?C++ Graphics::Draw2DTextValue怎么用?C++ Graphics::Draw2DTextValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graphics的用法示例。


在下文中一共展示了Graphics::Draw2DTextValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: render

void cGameStateFireControl::render(Graphics &con){
 
  //Clear buffer and draw graphics
  con.ClearBuffer(0, 0, 0, 0);
  con.BeginDrawing();
  GRAPHIC_IMAGE gi;
  
  //display ship and sub data
  CGameData *pData = CGameData::Instance();

  //display short cuts
  gi = g_Sprite.GetSpriteData(36);//sonar
  con.RenderGraphicModulate(10,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(37);//radar
  con.RenderGraphicModulate(120,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(38);//conn selected
  con.RenderGraphicModulate(230,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(45);//fire control
  con.RenderGraphicModulate(694,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(40);//damage control
  con.RenderGraphicModulate(804,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(41);//chart
  con.RenderGraphicModulate(914,10,gi,m_red, m_green, m_blue);

  //draw tool tips for short cuts
  if(g_Global.g_mouse.y > 10 && g_Global.g_mouse.y < 130){
    if(g_Global.g_mouse.x > 10 & g_Global.g_mouse.x < 104)
      con.Draw2DText("Sonar", F_V20, 20, 10, 0,255,255);
    else if(g_Global.g_mouse.x > 120 & g_Global.g_mouse.x < 207)
      con.Draw2DText("Radar", F_V20, 130, 10, 0,255,255);
    else if(g_Global.g_mouse.x > 230 & g_Global.g_mouse.x < 310)
      con.Draw2DText("Conn", F_V20, 240, 10, 0,255,255);
    //else if(g_Global.g_mouse.x > 694 & g_Global.g_mouse.x < 794)
    //  con.Draw2DText("Torpedos", F_V20, 704, 10, 0,255,255);
    else if(g_Global.g_mouse.x > 804 & g_Global.g_mouse.x < 904)
      con.Draw2DText("Damage", F_V20, 814, 10, 0,255,255);
    else if(g_Global.g_mouse.x > 914 & g_Global.g_mouse.x < 1014)
      con.Draw2DText("Chart", F_V20, 924, 10, 0,255,255);
  }

  con.Draw2DText("Torpedo Fire Control state", F_V20, con.GetScreenCenterX() - 150, con.GetScreenCenterY() - 10, 0,255,255);

  // SMJ - 11/13/2007 Draw FPS on screen
  //if(g_Global.g_bDisplayFramerate == true)
  con.Draw2DText(g_Global.g_strFPS, F_V20, 0, 180, 0,0,255);
  con.Draw2DTextValue("X", (float)g_Global.g_mouse.x, F_V20, 0, 140, 255, 0, 0);
  con.Draw2DTextValue("Y", (float)g_Global.g_mouse.y, F_V20, 0, 160, 255, 0, 0);
  con.Draw2DTextValue("T", (float)pData->m_torpedos.size(), F_V20, 0, 200, 255, 0, 0);

  for(int i = 0; i < pData->m_torpedos.size(); ++i){
    con.Draw2DTextValue("X", (float)pData->m_torpedos[i].GetPositionX(), F_V20, 0, 220 + i * 20, 255, 0, 0);
    con.Draw2DTextValue("Y", (float)pData->m_torpedos[i].GetPositionY(), F_V20, 220, 220 + i * 20, 255, 0, 0);
    con.Draw2DTextValue("S", (float)pData->m_torpedos[i].GetSpeed(), F_V20, 440, 220 + i * 20, 255, 0, 0);
    con.Draw2DTextValue("H", (float)pData->m_torpedos[i].GetHeading(), F_V20, 660, 220 + i * 20, 255, 0, 0);
  }
  con.EndDrawing ();
  con.Present();
}
开发者ID:ChuckBolin,项目名称:Sinking,代码行数:58,代码来源:CGameStateFireControl.cpp

示例2: render

void cGameStateSonar::render(Graphics &con){
 
  //Clear buffer and draw graphics
  con.ClearBuffer(0, 0, 0, 0);
  con.BeginDrawing();
  GRAPHIC_IMAGE gi;

  //display short cuts
  gi = g_Sprite.GetSpriteData(42);//sonar
  con.RenderGraphicModulate(10,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(37);//radar
  con.RenderGraphicModulate(120,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(38);//conn selected
  con.RenderGraphicModulate(230,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(39);//fire control
  con.RenderGraphicModulate(694,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(40);//damage control
  con.RenderGraphicModulate(804,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(41);//chart
  con.RenderGraphicModulate(914,10,gi,m_red, m_green, m_blue);

  //draw tool tips for short cuts
  if(g_Global.g_mouse.y > 10 && g_Global.g_mouse.y < 130){
   // if(g_Global.g_mouse.x > 10 & g_Global.g_mouse.x < 104)
   //   con.Draw2DText("Sonar", F_V20, 20, 10, 0,255,255);
    if(g_Global.g_mouse.x > 120 & g_Global.g_mouse.x < 207)
      con.Draw2DText("Radar", F_V20, 130, 10, 0,255,255);
    else if(g_Global.g_mouse.x > 230 & g_Global.g_mouse.x < 310)
      con.Draw2DText("Conn", F_V20, 240, 10, 0,255,255);
    else if(g_Global.g_mouse.x > 694 & g_Global.g_mouse.x < 794)
      con.Draw2DText("Torpedos", F_V20, 704, 10, 0,255,255);
    else if(g_Global.g_mouse.x > 804 & g_Global.g_mouse.x < 904)
      con.Draw2DText("Damage", F_V20, 814, 10, 0,255,255);
    else if(g_Global.g_mouse.x > 914 & g_Global.g_mouse.x < 1014)
      con.Draw2DText("Chart", F_V20, 924, 10, 0,255,255);
  }


  con.Draw2DText("Sonar state", F_V20, con.GetScreenCenterX() - 150, con.GetScreenCenterY() - 10, 0,255,255);


  // SMJ - 11/13/2007 Draw FPS on screen
  //if(g_Global.g_bDisplayFramerate == true)
  con.Draw2DText(g_Global.g_strFPS, F_V20, 0, 180, 0,0,255);
  con.Draw2DTextValue("X", (float)g_Global.g_mouse.x, F_V20, 0, 140, 255, 0, 0);
  con.Draw2DTextValue("Y", (float)g_Global.g_mouse.y, F_V20, 0, 160, 255, 0, 0);

  con.EndDrawing ();
  con.Present();
}
开发者ID:ChuckBolin,项目名称:Sinking,代码行数:50,代码来源:CGameStateSonar.cpp

示例3: render

void cGameStateChart::render(Graphics &con){
 
  //Clear buffer and draw graphics
  con.ClearBuffer(0, 0, 0, 0);
  con.BeginDrawing();
  GRAPHIC_IMAGE gi;

  CGameData *pData = CGameData::Instance();

  //draw chart stuff
  gi = g_Sprite.GetSpriteData(48);//white square for chart background
  gi.scale = 5.05;
  con.RenderGraphicModulate(262 + pData->m_shockX, 134 + pData->m_shockX, gi, m_red, m_green, m_blue);

  //chart highlights and reference lines
  con.DrawRect(262, 134, 762, 634,255, 0, 0);
  con.DrawLine(512, 134, 512, 634, 0, 0, 120);
  con.DrawLine(262, 384, 762, 384, 0, 0, 120);
  
  //draw user interface on right side of chart
  con.DrawLine(780, 134, 800, 134, 0, 255, 0);//horizontal tick marks
  con.DrawLine(780, 249, 800, 249, 0, 255, 0);
  con.DrawLine(780, 269, 800, 269, 0, 255, 0);
  con.DrawLine(780, 384, 800, 384, 0, 255, 0);
  con.DrawLine(790, 134, 790, 249, 0, 255, 0);//vertical lines
  con.DrawLine(790, 269, 790, 384, 0, 255, 0);

  //draw range
  con.Draw2DTextValue("SCALE", (float)m_chartScale[m_chartScaleIndex], F_V20, 780, 249, 0, 255, 0);

  //zoom in and zoom out
  if(g_Global.g_mouse.x > 806 && g_Global.g_mouse.x < 1006 
    && ::GetActiveWindow() == g_hWnd){
    if(g_Global.g_mouse.y > 134 && g_Global.g_mouse.y < 249 && m_chartScaleIndex < 4){//zoom in
      gi = g_Sprite.GetSpriteData(30);
      con.RenderGraphicModulate(811,139,gi,m_red, m_green, m_blue);
    }
    else if(g_Global.g_mouse.y > 269 && g_Global.g_mouse.y < 384 && m_chartScaleIndex > 0){//zoom out
      gi = g_Sprite.GetSpriteData(29);
      con.RenderGraphicModulate(811,274,gi,m_red, m_green, m_blue);
    }
  }

  //display ship and sub data
//  CGameData *pData = CGameData::Instance();
  float posX = 0, posY = 0;
  float range = (float)m_chartScale[m_chartScaleIndex];

  //ships
  for(int i = 0; i < pData->m_targets.size(); ++i){
    posX = (pData->m_targets[i].m_posX - pData->m_Player.m_posX) * 250/range;
    posY = (pData->m_targets[i].m_posY - pData->m_Player.m_posY) * 250/range;

    if(pData->m_targets[i].m_bAlive == true &&  posX >= -250 && posX <= 250 && posY >= -250 && posY <= 250)//{
      con.DrawCircle(512 + posX,384 - posY, 255,0,0,(pData->m_targets[i].m_length/500) * (20000/(range * 2) ));
  }

  //torpedo
  for(int i = 0; i < pData->m_torpedos.size(); ++i){
    posX = (pData->m_torpedos[i].GetPositionX()- pData->m_Player.m_posX) * 250/range;
    posY = (pData->m_torpedos[i].GetPositionY() - pData->m_Player.m_posY) * 250/range;

    if(pData->m_torpedos[i].IsRunning() == true &&  posX >= -250 && posX <= 250 && posY >= -250 && posY <= 250)//{
      con.DrawCircle(512 + posX,384 - posY, 0, 0, 0,2 * (20000/(range * 8)));
  }

  //draw scope bearing line to indicate which target is being viewed
  float s = 0, t = 0;
  s = 512 + 250 * cos(pData->ConvertDegreesToRadians( pData->m_Player.m_heading + pData->m_scopeRotateAngle/5.689));
  t = 384 - 250 * sin(pData->ConvertDegreesToRadians( pData->m_Player.m_heading + pData->m_scopeRotateAngle/ 5.689));
  con.DrawLine(512,384,s,t, 0, 255,0);

  //draw sub in center of chart
  gi = g_Sprite.GetSpriteData(57);
  gi.rotationAngle =  pData->m_Player.m_heading * 3.141592654/180;
  gi.scale = 1;// (1000/range);
  con.RenderGraphicModulate(512 - (gi.width/2)* gi.scale, 384 - (gi.height/2) * gi.scale, gi, m_red, m_green, m_blue);

  //display short cuts
  gi = g_Sprite.GetSpriteData(36);//sonar
  con.RenderGraphicModulate(10,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(37);//radar
  con.RenderGraphicModulate(120,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(38);//conn selected
  con.RenderGraphicModulate(230,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(39);//fire control
  con.RenderGraphicModulate(694,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(40);//damage control
  con.RenderGraphicModulate(804,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(47);//chart
  con.RenderGraphicModulate(914,10,gi,m_red, m_green, m_blue);

  //draw tool tips for short cuts
  if(g_Global.g_mouse.y > 10 && g_Global.g_mouse.y < 130){
    //if(g_Global.g_mouse.x > 10 & g_Global.g_mouse.x < 104)
    //  con.Draw2DText("Sonar", F_V20, 20, 10, 0,255,255);
    //else if(g_Global.g_mouse.x > 120 & g_Global.g_mouse.x < 207)
    //  con.Draw2DText("Radar", F_V20, 130, 10, 0,255,255);
    if(g_Global.g_mouse.x > 230 & g_Global.g_mouse.x < 310)
      con.Draw2DText("Conn", F_V20, 240, 10, 0,255,255);
//.........这里部分代码省略.........
开发者ID:ChuckBolin,项目名称:Sinking,代码行数:101,代码来源:cGameStateChart.cpp


注:本文中的Graphics::Draw2DTextValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。