Last update: 2020-3-8
Game: A Framework for Developing 2D Computer Games
-
Introduction
- Game is an application framework for developing 2D games
- Game framework was created in 1998 as an object library that provides
ready-to-use graphics and sound objects for
CSIE OOP lab class. Over the
years, Game has undergone several revisions and evolved into an application
framework.
- The Windows version of Game framework is implemented with the Microsoft
VC++ based on
MFC
and DirectX. Starting
from 2011, an Android version Game framework is also offered.
- Game framework is released under
GPL.
- Game framework provides the following functionalities:
- A simple and easy-to-use bitmap graphic object and a sound object
- Built-in state control for game and main control loop with overridable
game speed control
- The selection of the full screen mode and the window mode for presenting
the game.
-
Documentations (mostly in Traditional Chinese) for Game Framework
- General
- Class material
- Windows Tutorials
- Android Tutorials
- HTML5 Tutorials
- Teamwork with Git
-
Download the latest version of the game framework
- Windows source code version:
game4.10.zip
(2017-2-23)
- Please download the source code version if you are planning to develop a game
under Windows 8/Windows 10.
- Please follow the following installation instructions to compile and
execute the game framework and its sample program.
- Install Microsoft Visual Studio 2015 C++
(note: earlier versions of Visual Studio, e.g., VS 2008, VS 2005, and VC++6.0 do not
work): see installation
instruction
Download and Install DirectX SDK
from Microsoft (note game4.9 compiles correctly with
February 2010 version of DirectX SDK; the latest version may not always work,
because Microsoft updates DirectX SDK very frequently).
- Download and decompress game4.10.zip.
- Double click game.sln to open the source code.
Setup the DirectX SDK include and library
directories for your Visual Studio 2010.
- Compile
and execute the sample game. If compilation fails, make sure your Visual
Studio and DirectX SDK versions are correct.
- Follow the tutorials above to add new functionalities or objects to the
Game.
- When your game is fully developed, follow the game deployment instructions
above to create setup files for your game.
- Windows executable version: Setup.msi (executable;
8.3 MB; for Windows XP/Windows 7) (2010-03-23)
- Please download the executable version if you are interested only in how the sample
program runs and are NOT planning to use the framework to develop a
new game.
- Installation/execution instruction
- After download, please execute the Setup.msi file to install the
sample program and then click on the icon of the sample program to execute
it.
- Note: this Setup.msi file should work with all language versions of
Windows XP. However, I was unable to test it for languages
other than Traditional Chinese. Please let me know (by sending e-mail to
) should you encounter any problems.
- Android source code version:
android_game2.4.rar
(2018-3-1; for Android 6.0 with Android Studio)
- Please download the source code version if you are planning to develop a
game under Android
- Please follow the following installation instructions to compile and
execute the game framework and its sample program.
- Install Android
Studio, import game framework, and compile/execute game framework
- Follow the Android tutorials above to add new functionalities or objects to
the Game.
- When your game is fully developed, follow the game deployment
instructions above to install the game on the phone
- HTML5 source code version:
html5_game3.3zip (2018-3-1)
- Please download the file and use a browser to execute the sample
game
- Follow the HTML5 tutorials above to add new functionalities or objects to
the Game.
-
Download NTUT Striker developed by former
students of OOP lab
- Setup file for Windows XP:
NTUT
Striker v1.0 Setup.msi (11 MB, 下載次數
)
- Installation/execution instruction:
- After download, please execute the Setup file (.msi file) to install the
game and then double click the game icon (on the desktop) to execute
it.
- Note: NTUT Striker is a flying shooting game and is served as an
example of what an OOP lab team can do in one semester. The source code of
this game was developed by two students in the 2003 OOP lab class
(I have replaced all bitmap graphics used in
this game with new ones to avoid intrusion of copyright).
-
FAQ
- Windows version
- Question 1: console (printf) 能在Game Framework 下使用嗎?
- Answer: TRACE指令可以替代printf,例如TRACE("%d\n", x); 就會把x印出來。當使用debug
mode執行程式時,找一個名為Output的視窗(View->Output),TRACE指令所列印的資料會
顯示在此視窗。
- Question 2: 使用pDC->TextOut(...)顯示文字時,文字的背景可以設定為透明嗎?
- Answer: 顯示文字前先執行pDC->SetBkMode(TRANSPARENT);即可。
- Question 3: Game Framework預設有三種state (init, run, over),但這三種state似乎都是互相獨立的,
有沒有方法可以定義變數,讓三種狀態都可以取用。 例如讓在run狀態時的計分用的int score,可以傳到over的狀態顯示給玩家看。
- Answer: (1) 比較簡單的方法是在Base class,即GameState中加入static的變數(注意是static變數),那麼每個繼承的state都能共用此變數了,但是這樣寫用到static變數有點髒。(2)
比較勤勉的方法是先宣告一個class S,裡面放所有需要共享的變數,然後在Game
(或MyGame)中宣告一個S的變數s,並將s的pointer傳給各個state,這樣各state就可以分享相同的變數了;那麼又怎麼把s傳給各個state呢?先在GameState的變數宣告中增加一個S的pointer,然後利用constructor
(或自己訂一個副程式)的參數代入s的pointer再存起來。
- Question 4: 我的遊戲用到很多很多圖形(CMovingBitmap),不知何故,當載入太多圖形時遊戲會當掉。
- GameFramework有bug,在gamelib.cpp檔的副程式void CMovingBitmap::LoadBitmap(char
*filename, COLORREF color)中,使用到HBITMAP,
再轉換為CBitmap物件,但是使用後漏了釋放,請在此副程式結束前,加一行
bmp->DeleteObject()釋放此物件。
- Question 5: CAnimation這個class有沒有支援deep copy?
- Answer: 沒有,如果需要的話,請自己寫CAnimation的copy constructor。
- Question 6: 我想要做Game的單元測試,怎麼樣才能帶入Google Test (gtest)呢?
- Android version
- Question 1: 我希望畫面能有兩個地方同時被觸控,如何寫code處理這種multi-touch?
- Answer: 當pointerPressed(List<Pointer>
pointers)時,參數其實是一個List,multi-touch的各個點都會出現在pointers這個List裡面。你的程式只要判斷List裡面的每個Pointer,即可達成處理multi-touch的能力。
- HTML5 version
- Question 1: 我的GameLevel的draw副程式為什麼不會被執行到?導致畫面更新不正確。
- Answer: 目前HTML5版的GameFramework有bug,當某GameLevel未attach任何Sprite至rootScene時,draw就不會被呼叫。解決的方法是在GameLevel中至少attach一個Sprite到rootScene,且該Sprite的座標必須在update中不斷變更,那麼GameLevel的draw就會正確被呼叫。
- Question 2: 如何變更遊戲畫面的長寬比?
- Answer: src/game.js第49行that.idealWidth及that.idealHeight設定畫面的長寬比。
-
期中、期末Demo注意事項
- Windows
- Demo用電腦為實驗室教師主機,請參考Create Setup file預先製作安裝檔,demo當天安裝在主機上執行
- 製作Setup file的過程中,有一個步驟建立ProductCode一定要做,更換新的ProductCode,否則大家的ProductCode都相同,會起衝突,無法安裝在同一部Demo主機上。
- 為避免臨時出現相容性問題,安裝檔應該預先在教室主機上試過。在個人NB或PC可以執行,並不表示在教室的主機也可以執行。
- Demo時請開啟全螢幕(遊戲解析度請設定為標準的螢幕解析度,例如640*480)
- Android
- 教師投影機會安裝支援Miracast之設備,請將Android螢幕連結至投影機(例如HTC手機,請使用「設定->HTC
connect->...」。
- 請預先試用Miracast,如果你的手機無法連結Miracast,
請預先向同學商借可以連結的手機。
- HTML5
- Demo使用的瀏覽器為Chrome,Demo時請將Chrome視窗調到最大化
- 共同事項
- 期末demo每組時間限3.5分鐘以內,請快速說明第一次demo及第二次demo已經展出的功能,把大部分時間留給第二次demo後所新增的功能。
-
Download source code of the older Windows versions
- See ReadMe for version differences
-
game4.9.zip (230
KB)
(2016-3-4; for Visual Studio 2015 C++ with DirectX SDK February 2010
version; Windows 8/10)
- game4.9.zip (230
KB)
(2016-3-4; for Visual Studio 2015 C++ with DirectX SDK February
2010 version; Windows 8/10)
- game4.8.zip (260
KB) (2012-05-13; for Visual Studio 2013 C++ with DirectX SDK February
2010 version; Windows XP/7)
- game4.7.zip (289
KB) (2012-03-21; for Visual Studio 2010 C++ with DirectX SDK February
2010 version)
- game4.6.zip (285
KB) (2010-03-23; for Visual Studio 2008 C++ with DirectX SDK February
2010 version)
- game4.5.zip (416 KB) (2010-02-23; for Visual Studio 2008
C++ with DirectX SDK 9.x-August 2006)
- game4.4.zip (446 KB) (2008-02-15; for VC++6.0 with DirectX SDK 8.x or Visual Studio 2005
C++ with DirectX SDK 9.x-August 2006)
- game4.3.zip (418
KB) (2006-09-09; for VC++6.0 with DirectX SDK 8.x or Visual Studio 2005
C++ with DirectX SDK 9.x-August 2006)
- game4.2.zip (453 KB)
(2006-02-08; for VC++6.0 or Visual Studio .net 2003 C++ with DirectX SDK 8.x)
- game4.1.zip
(651 KB) (2004-03-08; for VC++6.0 with DirectX SDK 8.x)
- game3.1.zip (463 KB) (2002-03-04; for VC++6.0
with
DirectX SDK 8.x)
-
Download source code of the older Android versions
-
Download source code of the older HTML5 versions
-