羅林 李俊琴
摘要:2D游戲具有很大的應用前景。游戲軟件是一種復雜度較高的軟件,利用游戲框架可以降低游戲開發難度,提高游戲開發效率,因此設計2D游戲框架具有現實的意義。該文探討了框架的概念,分析了2D游戲軟件開發的特征,從中總結出2D游戲框架需要實現的功能,結合Windows的圖形設備接口(GDI),提供了一個2D游戲框架的設計,其中實現了精靈創建、釋放、渲染、資源管理、幀頻鎖定、事件傳遞等2D游戲中必需的功能,并留出了可擴展的接口。該文最后給出了框架的使用方法。
關鍵詞:2D游戲;GDI;框架設計
中圖分類號:TP311 文獻標識碼:A 文章編號:1009-3044(2014)27-6480-03
Abstract: 2D Game has great application prospect. Game software is a higher complexity software, and the use of game framework can reduce the difficulty of game development, improve the efficiency of game development, so design a 2D game framework has practical significance. This paper discusses the concept of a framework, analyze the characteristics of 2D game software development, summed up the 2D game framework needed to achieve the functionality, provides the framework for the design of a 2D game with Windows Graphics Device Interface (GDI), realize the sprite to create, release, render, resource management, frame frequency locking, events dispatcher and other necessary function in 2D game, and set aside a scalable interface. Lastly, the paper proposes the framework of the method of use.
Key word: 2D Game;GDI; Framework Design
在軟件開發中,利用框架可以在保證質量的情況下提高軟件開發效率,降低軟件開發難度,是目前開發軟件的一種主流方法。游戲軟件一般要求響應快速精確,需要同時處理聲音、圖像等很多資源,開發難度較高。現實開發中,通常利用各種框架或者引擎來降低開發難度,提高效率。因此,研究游戲開發中的框架設計具有實際意義。
1 框架的概念
框架(Framework)是整個或部分系統的可重用設計,表現為一組抽象構件及構件實例間交互的方法。另一種定義認為,框架是可被應用開發者定制的應用骨架。
從軟件設計的角度來看,框架首先是解決一類問題的規范。框架有特定的應用領域,不同的框架用于解決不同的軟件開發需求。框架也是一種規范,它向使用者承諾,使用框架可以正確完成某些特定的功能,幫助軟件開發者快速準確地完成軟件開發任務。……