Sfoglia il codice sorgente

Added method Game::getAspectRatio().

Darryl Gough 13 anni fa
parent
commit
b2781292b6
2 ha cambiato i file con 13 aggiunte e 1 eliminazioni
  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.
      */
     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.
@@ -183,7 +190,7 @@ public:
     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.
      *

+ 5 - 0
gameplay/src/Game.inl

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