Esempio n. 1
0
	void CSLevel::postFrame(const float &elapsedtime)
	{
		// let the physx world do it's thing
		CS_SAFE(getPhysXWorld(), postFrame(elapsedtime));

		// let the objects do their thing
		CS_SAFE(m_ObjectFactory, postFrame(elapsedtime));
	}
	void ANativeWindowDisplayAdapter::frameCallback(CameraFrame* cameraFrame)
	{
		LOG_FUNCTION_NAME;

		DisplayFrame df;
		df.mBuffer = cameraFrame->mBuffer;
		df.mType = (CameraFrame::FrameType) cameraFrame->mFrameType;
		df.mOffset = cameraFrame->mOffset;
		df.mWidthStride = cameraFrame->mAlignment;
		df.mLength = cameraFrame->mLength;
		df.mWidth = cameraFrame->mWidth;
		df.mHeight = cameraFrame->mHeight;
		postFrame(df);

		LOG_FUNCTION_NAME_EXIT;
	}
Esempio n. 3
0
int main()
{
  init();

  double ballVelX = BALL_VEL;
  double ballVelY = BALL_VEL;

  int topPaddleX;
  int bottomPaddleX;

  double ballX;
  double ballY;

  unsigned int topPlayerScore = 0;
  unsigned int bottomPlayerScore = 0;

  reset(topPaddleX, bottomPaddleX, ballX, ballY);

  bool quit = false;

  int key;
  while(!quit)
  {
    preFrame();
    
    key = getKey();
    if(key == 's')
      --topPaddleX;
    else if(key == 'd')
      ++topPaddleX;
    else if(key == 'k')
      --bottomPaddleX;
    else if(key == 'l')
      ++bottomPaddleX;
    else if(key == '`')
      quit = true;

    ballX += ballVelX;
    ballY += ballVelY;

    if(ballX >= XMAX)
      ballVelX = -ballVelX;
    else if(ballX <= 0)
      ballVelX = -ballVelX;
    if(ballY >= YMAX)
    {
      ballVelY = -ballVelY;

      if(ballX < (bottomPaddleX - PADDLE_HALF_SIZE) ||
         ballX > (bottomPaddleX + PADDLE_HALF_SIZE))
      {
        reset(topPaddleX, bottomPaddleX, ballX, ballY);
        ++topPlayerScore;
      }
    }
    else if(ballY <= 0)
    {
      ballVelY = -ballVelY;

      if(ballX < (topPaddleX - PADDLE_HALF_SIZE) ||
         ballX > (topPaddleX + PADDLE_HALF_SIZE))
      {
        ++bottomPlayerScore; 
        reset(topPaddleX, bottomPaddleX, ballX, ballY);
      }
    }


    postFrame();

    drawPaddle(topPaddleX, 0);
    drawPaddle(bottomPaddleX, YMAX);
    drawBall((int)ballX, (int)ballY);
    drawScore(topPlayerScore, bottomPlayerScore);
  }

  cleanUp();

  return 0;
}