- SFML Game Development By Example
- Raimondas Pupius
- 241字
- 2021-07-23 14:55:05
Graduating to ravioli
Let's start small. Every game needs to have a window, and as you already know from of our window class will predictably look something like this:
class Window{ public: Window(); Window(const std::string& l_title,const sf::Vector2u& l_size); ~Window(); void BeginDraw(); // Clear the window. void EndDraw(); // Display the changes. void Update(); bool IsDone(); bool IsFullscreen(); sf::Vector2u GetWindowSize(); void ToggleFullscreen(); void Draw(sf::Drawable& l_drawable); private: void Setup(const std::string& l_title, const sf::Vector2u& l_size); void Destroy(); void Create(); sf::RenderWindow m_window; sf::Vector2u m_windowSize; std::string m_windowTitle; bool m_isDone; bool m_isFullscreen; };
Because we want to handle setting up our window internally, the setup method is made private, as well as the destroy and create methods. Think of these as just helper methods that the user of this class doesn't need to know about. It's a good idea to keep certain information around after the setup is done, such as the window size or the title that's being displayed above it. Lastly, we keep around two Boolean variables to keep track of the window being closed and its state regarding full screen.
Tip
The naming convention that's being employed in our window class is referred to as the Hungarian notation. Using it is, of course, not required, but it can prove useful when dealing with lots of code, trying to track down bugs, and working in larger groups of people. We'll be utilizing it throughout this book. More information about it can be found here: http://en.wikipedia.org/wiki/Hungarian_notation
- SPSS數據挖掘與案例分析應用實踐
- ASP.NET Web API:Build RESTful web applications and services on the .NET framework
- Podman實戰
- Python完全自學教程
- Advanced Oracle PL/SQL Developer's Guide(Second Edition)
- C#實踐教程(第2版)
- C#程序設計(項目教學版)
- 編寫高質量代碼:改善Objective-C程序的61個建議
- HTML+CSS+JavaScript編程入門指南(全2冊)
- Swift語言實戰晉級
- Python期貨量化交易實戰
- Mudbox 2013 Cookbook
- Python預測分析與機器學習
- Java與Android移動應用開發:技術、方法與實踐
- Android Application Programming with OpenCV 3