Explorar o código

Added method Game::getAspectRatio().

Darryl Gough %!s(int64=13) %!d(string=hai) anos
pai
achega
b2781292b6
Modificáronse 2 ficheiros con 13 adicións e 1 borrados
  1. 8 1
      gameplay/src/Game.h
  2. 5 0
      gameplay/src/Game.inl

+ 8 - 1
gameplay/src/Game.h

@@ -174,6 +174,13 @@ public:
      * @return The game window height.
      * @return The game window height.
      */
      */
     inline unsigned int getHeight() const;
     inline unsigned int getHeight() const;
+    
+    /**
+     * Gets the aspect ratio of the window. (width / height)
+     * 
+     * @return The aspect ratio of the window.
+     */
+    inline float getAspectRatio() const;
 
 
     /**
     /**
      * Gets the game current viewport.
      * Gets the game current viewport.
@@ -183,7 +190,7 @@ public:
     inline const Rectangle& getViewport() const;
     inline const Rectangle& getViewport() const;
 
 
     /**
     /**
-     * Set the game current viewport.
+     * Sets the game current viewport.
      *
      *
      * The x, y, width and height of the viewport must all be positive.
      * The x, y, width and height of the viewport must all be positive.
      *
      *

+ 5 - 0
gameplay/src/Game.inl

@@ -29,6 +29,11 @@ inline unsigned int Game::getHeight() const
     return _height;
     return _height;
 }
 }
 
 
+inline float Game::getAspectRatio() const
+{
+    return (float)_width / (float)_height;
+}
+
 inline const Rectangle& Game::getViewport() const
 inline const Rectangle& Game::getViewport() const
 {
 {
     return _viewport;
     return _viewport;