Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. void CGameWorld::Init()
  2. {
  3. HINSTANCE hInstance = GetModuleHandle(nullptr);
  4. HWND hWnd = GetActiveWindow();
  5. myInputWrapper.Initialize(hInstance, hWnd, 800, 600);
  6. myTimerManager.CreateTimer();
  7.  
  8. myBalls.Init(10);
  9. AddBalls();
  10. mySprite = new DX2D::CSprite("Sprites/Ball.png");
  11. myGravity = DX2D::Vector2f(0, 0.5f);
  12. myDeltaTime = 0;
  13. }
  14.  
  15. ////////////////////////////////////////////////////////////////////////////////////////
  16.  
  17. void CGameWorld::AddBalls()
  18. {
  19. myBalls.Add(Ball(Vector2f(0.5f, 0.5f), Vector2f(static_cast<float>((rand() % 101)) / 10000 * ((rand() % 2 * 2) - 1),
  20. static_cast<float>((rand() % 101)) / 10000 * ((rand() % 2 * 2) - 1))));
  21. }
  22.  
  23. ////////////////////////////////////////////////////////////////////////////////////////
  24.  
  25. DX2D::Vector2f myPosition;
  26. DX2D::Vector2f myForce;
  27.  
  28. //Ball::Update(float aDeltaTime, Vector2f aGravity)
  29. {
  30. myForce += (aGravity * aDeltaTime * 0.1f);
  31. myPosition += myForce;
  32. }
  33.  
  34. ////////////////////////////////////////////////////////////////////////////////////////
  35.  
  36. for (unsigned short i = 0; i < myBalls.Size(); i++)
  37. {
  38. myBalls[i].Update(aTimeDelta, myGravity);
  39. mySprite->SetPosition(DX2D::Vector2f(myBalls[i].GetPosition().x, myBalls[i].GetPosition().y));
  40. mySprite->Render();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement