Пример #1
0
void SoloPong::OnPaint()
{
  Joypad pad;
  GetJoypad(pad);
  const sF32 sb = 0.02f;
  const sF32 sx = 0.04f;
  const sF32 sy = PaddleSize;

  PaddleA = sClamp<sF32>(pad.Analog[1]*1.1f,-1,1)*(1-PaddleSize);
  PaddleB = sClamp<sF32>(pad.Analog[3]*1.1f,-1,1)*(1-PaddleSize);

  sU32 col = 0xff000000;
  col |= sClamp(DeathTimer,0,255)<<16;

  DrawRect(-1,-1,1,1,col);
  DrawRect(-0.9f-sx,PaddleA-sy,-0.9f+sx,PaddleA+sy,0xffffffff);
  DrawRect( 0.9f-sx,PaddleB-sy, 0.9f+sx,PaddleB+sy,0xffffffff);

  DrawRect(BallX-sb,BallY-sb,BallX+sb,BallY+sb,0xffffffff);
  
  ScoreString.PrintF(L"SCORE: %03d  [%c] [%c] [%c]",Score
    ,Lives>=1?'X':' '
    ,Lives>=2?'X':' '
    ,Lives>=3?'X':' '
    );
}
Пример #2
0
 void _Defaults()
 {
   Scan->Match('{');
   while (!Scan->Errors && !Scan->IfToken('}'))
   {
     if (Scan->IfName(L"resolution"))
       _Resolution(DefaultResolution);
     else if (Scan->IfName(L"fullscreen"))
       DefaultFullscreen = Scan->ScanInt();
     else if (Scan->IfName(L"port"))
       Port = Scan->ScanInt();
     else if (Scan->IfName(L"httpport"))
       HttpPort = Scan->ScanInt();
     else if (Scan->IfName(L"bartime"))
       BarAnimTime = sClamp(Scan->ScanFloat(),0.1f,100.0f);
     else if (Scan->IfName(L"barspread"))
       BarAnimSpread = sClamp(Scan->ScanFloat(),0.0f,1.0f);
     else if (Scan->IfName(L"movievolume"))
       MovieVolume = sFPow(10.0f,sClamp(Scan->ScanFloat(),-100.0f,12.0f)/20.0f);
     else
       Scan->Error(L"syntax error");
   }
 }
Пример #3
0
void RNFR067_IsoSplash::Render(Wz4RenderContext *ctx)
{
//  if(!ctx->IsCommonRendermode()) return;

  sMatrix34CM *model;
  sFORALL(Matrices,model)
  {
    for(sInt i=0;i<4;i++)
    {
      if(Mtrl[i] && !Mtrl[i]->SkipPhase(ctx->RenderMode,Para.LightEnv))
      {
        sInt n = sClamp(Para.Shells[i],1,256);
        for(sInt j=0;j<n;j++)
        {
          Mtrl[i]->ShellExtrude = j/sF32(n);
          Mtrl[i]->Set(ctx->RenderMode|sRF_MATRIX_ONE,Para.LightEnv,model,0,0,0);
          MC.Draw();
        }
      }
    }
  }
}
Пример #4
0
MyApp::MyApp()
{
  sImage *img;

  Painter = new sPainter;

  // perlin texture

  sInt xs = 256;
  sInt ys = 256;
  img = new sImage;
  img->Init(xs,ys);
  for(sInt y=0;y<ys;y++)
  {
    for(sInt x=0;x<xs;x++)
    {
      sF32 p = sPerlin2D(x*(0x100000/xs),y*(0x100000/ys),3,0)*2.0f
             + sPerlin2D(x*(0x200000/xs),y*(0x200000/ys),7,0)*1.5f
             + sPerlin2D(x*(0x400000/xs),y*(0x400000/ys),15,0)*1.0f
             ;
      sInt c = sInt(128+127*sClamp(p,-1.0f,1.0f));
      img->Data[y*xs+x] = c|(c<<8)|(c<<16)|0xff000000;
    }
  }
  Tex = sLoadTexture2D(img,sTEX_ARGB8888);
  delete img;

  CreateTorus();

  // materials

  TorusMtrl = new TorusShader;
  TorusMtrl->Texture[0] = Tex;
  TorusMtrl->Texture[1] = Tex;
  TorusMtrl->TBind[1] = sMTB_VS|0;
  TorusMtrl->Flags = sMTRL_ZON|sMTRL_CULLOFF;
  TorusMtrl->Prepare(TorusFormat);
}
Пример #5
0
sArray<sPerfMonThread::Record> *sPerfMonThread::GetFrame(int n,uint64 &freq)
{
    freq = Frames[(DoubleBuffer+History-n)%History]->Frequency;
    n = sClamp(n,1,History-1);
    return &Frames[(DoubleBuffer+History-n)%History]->Records;
}
Пример #6
0
void s3DWindow::CmdGearShift(sDInt n)
{
  GearShift = sClamp(GearShift+sInt(n),-40,40);
  GearShiftDisplay = sGetTime()+500;
}
Пример #7
0
void sTabBorderBase::OnPaint2D()
{
  // get total width

  sFont2D *font = sGui->PropFont;
  font->SetColor(sGC_TEXT,sGC_BACK);
  sInt max = GetTabCount();
  sInt space = (font->GetWidth(L" ")/2+1)*2;
  sInt kill = (Height/4)*2+1;
  if(max==1)
    kill = -2*space;
  Rects.Resize(max);
  sInt arrow = font->GetWidth(L"\x25c4  ");

  // layout rects

  sInt xs=0;
  for(sInt i=0;i<max;i++)
  {
    xs+=space;
    const sChar *text = GetTabName(i);
    sInt xw = font->GetWidth(text);

    Rects[i].Client.Init(Rect.x0+xs,Rect.y0+2,Rect.x0+xs+space*4+xw+kill,Rect.y1-1);
    xs+= space*4 + xw + kill;
    sRect r=Rects[i].Client;
    r.x0++;
    r.x1--;
    r.y0++;
    Rects[i].Kill.Init(r.x1-kill-space,r.CenterY()-kill/2,r.x1-space,r.CenterY()-kill/2+kill);
  }
  xs+=space;

  // prepare scrolling

  if(xs<=Client.SizeX())
  {
    ScrollWidth = 0;
  }
  else
  {
    ScrollWidth = xs - (Client.SizeX()-2*arrow);
    if(ScrollWidth<0)
      ScrollWidth = 0;

    if(ScrollTo>=0 && ScrollTo<max)
    {
      sInt over = 2*arrow;
      if(Rects[ScrollTo].Client.x0-Scroll < Client.x0+over)
        Scroll = (Rects[ScrollTo].Client.x0)-(Client.x0+over);
      if(Rects[ScrollTo].Client.x1-Scroll > Client.x1-2*arrow-over)
        Scroll = (Rects[ScrollTo].Client.x1)-(Client.x1-2*arrow-over);
      Scroll = sClamp(Scroll,0,ScrollWidth);
      ScrollTo = -1;
    }

    sInt xo = arrow-sMin(Scroll,ScrollWidth);

    Info *info;
    sFORALL(Rects,info)
    {
      info->Client.x0 += xo;
      info->Client.x1 += xo;
      info->Kill.x0 += xo;
      info->Kill.x1 += xo;
    }
  }