電子遊戲(electronic game)係一種電腦程式。一個遊戲程式結構大致如下:喺一隻遊戲嘅程式啟動嗰陣,個程式要初始化(initialize)-設定好嗮隻遊戲嘅參數嘅數值、講好嗮要用乜資源等等。初始化咗之後,個程式就要進入遊戲迴圈(game loop)-喺程式編寫上,迴圈(loop)係一類控制流程機制,能夠令一段程式碼只要某啲條件唔達到,就會一路係噉重複行,而相對喺冇迴圈嗰陣,段碼會逐句逐句行,行一次就算[3]。好似係以下呢段食鬼嘅虛擬碼噉,就用咗個 while 迴圈[4][5]:
move_speed = ...
number_of_ghost = ...
... 用若干行 declaration 設定遊戲柞參數嘅數值while player.lives > 0 當玩家有多過 0 條命嗰陣一路做...(「玩家命變咗 0」就係 GAME OVER 條件)
// Process Inputs;睇讀取輸入
JoystickData j = grab raw data from joystick 由手掣嗰度探測玩家撳咗乜掣
// Update Game World;睇遊戲邏輯同人工智能
update player.position based on j 基於玩家撳嘅掣,更新玩家角色嘅位置
foreach Ghost g in world for 每一隻鬼
if player collides with g 如果玩家撞到嗰隻鬼
kill either player or g 玩家就死
else
update AI for g based on player.position 基於隻鬼嘅人工智能,更新佢嘅位置
end
loop
// 喺現實應用上,以上嘅各個動作通常會每個做一個子程式。
...
// Generate outputs;睇遊戲外觀
draw graphics 喺熒光幕上面畫相應嘅影像
update audio ... 同埋整聲效
loop
Valente, L., Conci, A., & Feijó, B. (2005). Real time game loop models for single-player computer games. In Proceedings of the IV Brazilian Symposium on Computer Games and Digital Entertainment (Vol. 89, p. 99).
Kelley, J. F. (1984). An iterative design methodology for user-friendly natural language office information applications. ACM Transactions on Information Systems (TOIS), 2(1), 26-41.
Benvenuto, N., & Tomasin, S. (2005). Iterative design and detection of a DFE in the frequency domain. IEEE Transactions on Communications, 53(11), 1867-1875.
Manker, Jon; Arvola, Mattias (January 2011). "Prototyping in Game Design: Externalization and Internalization of Game Ideas". Proceedings of Hci 2011 - 25Th Bcs Conference on Human Computer Interaction.
Fullerton, T., Chen, J., Santiago, K., Nelson, E., Diamante, V. & Meyers (2006) A. That Cloud Game: Dreaming (and Doing) Innovative Game Design. In Proc. of Sandbox Symposium 2006. ACM Press.
Mahlmann, T., Drachen, A., Togelius, J., Canossa, A., & Yannakakis, G. N. (2010, August). Predicting player behavior in tomb raider: Underworld. In Proceedings of the 2010 IEEE Conference on Computational Intelligence and Games (pp. 178-185). IEEE.
Mikami, K., & Kondo, K. (2017, June). Adaptable Game Experience Based on Player's Performance and EEG. In 2017 Nicograph International (NicoInt) (pp. 1-8). IEEE.
Medler, B., John, M., & Lane, J. (2011, May). Data cracker: developing a visual game analytic tool for analyzing online gameplay. In Proceedings of the SIGCHI conference on human factors in computing systems (pp. 2365-2374).