手机游戏开发实例(smartphone联机炸弹人)

时间:2011-01-18 06:41:21
【文件属性】:

文件名称:手机游戏开发实例(smartphone联机炸弹人)

文件大小:4.68MB

文件格式:ZIP

更新时间:2011-01-18 06:41:21

相当好的例子

c++ wince sdk AI

smartphone版本 和windows版本

目录
Table of content
I. Introduction.........................................................................................................................................................................5
II. Graphics and Gameplay .................................................................................................................................................7
II.1. Getting Started .............................................................................................................................................................7
II.1.1. First Test................................................................................................................................................................7
II.1.2. Windows Programming and Message Handling essentials ...........................................................................8
II.1.3. Drawing Bitmaps to the screen........................................................................................................................ 14
II.1.4. Sprite movement and user input....................................................................................................................... 18
II.1.5. Additional stuff to do........................................................................................................................................ 22
II.2. Dialogs........................................................................................................................................................................22
II.3. GAPI, Bitmaps and Blitters......................................................................................................................................26
II.3.1. GAPI.................................................................................................................................................................... 26
II.3.2. Bitmaps................................................................................................................................................................ 30
II.3.3. Blitters ................................................................................................................................................................. 33
II.4. Game Design ..............................................................................................................................................................38
II.4.1. Graphics .............................................................................................................................................................. 39
II.4.2. Game Area .......................................................................................................................................................... 39
II.4.3. Bomb handling................................................................................................................................................... 40
II.4.4. Player Sprites...................................................................................................................................................... 42
II.4.5. Computer Player ................................................................................................................................................ 42
II.5. Finishing the game ....................................................................................................................................................43
II.6. Debugging...................................................................................................................................................................44
II.7. Efficient and clean programming on CE devices..................................................................................................45
II.8. Hardware Button Click Sound.................................................................................................................................47
III. Communications............................................................................................................................................................50
III.1. Overview of the libraries ........................................................................................................................................50
III.1.1. Consequences.................................................................................................................................................... 51
III.2. Messages....................................................................................................................................................................53
III.3. Class CNetwork........................................................................................................................................................54
III.3. Class CNetBuffer......................................................................................................................................................56
III.4. DirectPlay .................................................................................................................................................................57
III.4.1. Introduction....................................................................................................................................................... 57
III.4.2. Different kinds of Service Providers.............................................................................................................. 57
III.5. Class CDPNet...........................................................................................................................................................59
III.5.1. DirectPlay Objects and Initialisation............................................................................................................. 60
III.5.2. Sending Data..................................................................................................................................................... 67
III.5.3. Game Abort ....................................................................................................................................................... 67
III.6. IrDATM (Infrared Data Association).....................................................................................................................68
III.6.1. Introduction....................................................................................................................................................... 68
III.6.2. Class CNet......................................................................................................................................................... 70
III.6.3. Initialise the CIRNet object............................................................................................................................ 71
III.6.4. The Recieve Thread......................................................................................................................................... 73
III.6.5. The Send Thread .............................................................................................................................................. 74
III.6.6. The Send Buffer ............................................................................................................................................... 75
III.6.7. The Receive Buffer.......................................................................................................................................... 79
III.6.8. Testing the basic network functions............................................................................................................... 81
III.6.9. Last things todo in the class CIRNet.............................................................................................................. 82
IV. Appendix A: Overview of the message identifiers.................................................................................................84
3
V. Appendix B: Network Statistics for DirectPlay .......................................................................................................85
VI. Appendix C: Configuration of Bluetooth Manager to play SmartBlaser over the Bluetooth Serial Port
Service. ....................................................................................................................................................................................86
VII. LITERATURE.............................................................................................................................................................89
Table of figures
Figure 1: Screenshot of SmartBlaster ________________________________________________________ 5
Figure 2: Communication Infrastructure______________________________________________________ 6
Figure 3: Create new project ______________________________________________________________ 6
Figure 4: screenshot from the running application in „project3“.__________________________________ 18
Figure 5: The Insert Resource dialog. Three different sized empty dialog templates are available. _________ 23
Figure 6: The resource editor. ____________________________________________________________ 25
Figure 7: Under Project – Settings, open the tab “Link” and include gx.lib to the library modules _________ 26
Figure 8: Under Tools – Options, open the tab “Directories”.. ____________________________________ 27
Figure 9: Output of the sample application on the Smartphone. ___________________________________ 28
Figure 10: Output of the sample application on the PocketPC..____________________________________ 28
Figure 11 a): fast blitter function b): colour keying____________________________________________ 38
Figure 12: and at last the sprites get drawn with colour keying being used.___________________________ 38
Figure 13: The block bitmap______________________________________________________________ 39
Figure 14 bombs triggered by bombs _______________________________________________________ 41
Figure 15: Error file logging calls to new and delete___________________________________________ 46
Figure 16: Activate the Platform SDK library for Visual Studio ___________________________________ 50
Figure 17: Configuration of COM ports for the bluetooth serial sevice______________________________ 52
Figure 18: Enumeration of the available DirectPlay Service Providers______________________________ 58
Figure 19 : Message flow during network session______________________________________________ 66
Figure 20: different IrDa layers___________________________________________________________ 69
Figure 21: pointer position in send and recv buffers______________________________________________ 78
Figure 22: DirectPlay Network Statistic _____________________________________________________ 85
Figure 23: Configaration of Smartblaster____________________________________________________ 86
Figure 24: Configuration of computer "DUDDLE"_____________________________________________ 87
Figure 25: Configuration of computer "BONGO" ______________________________________________ 88
Table of code fragments
Code fragment 1: Extract from the file “Blaster_CE.h” in “project3\Blaster_CE” _____________________ 14
Code fragment 2: Extract from the file “Blaster_CE.cpp” in “project3\Blaster_CE” ___________________ 15
Code fragment 3: The file “resource.h” in project3 “project3\Blaster_CE” __________________________ 15
Code fragment 4: Extract from the file “Blaster_CE.rc” in project3\Blaster_CE” _____________________ 15
Code fragment 5: The function “LoadBitmaps” in “project3\Blaster_CE”.___________________________ 16
Code fragment 6: The function “DrawGame” in “project3\Blaster_CE”.____________________________ 17
Code fragment 9: Extract from the file „Blaster_CE.h“ in project4_________________________________ 18
Code fragment 10: Extract of the function “DrawGame“ in project4 _______________________________ 19
Code fragment 11: The function DoKeydownMain in project4a ___________________________________ 20
Code fragment 12: Initialising the GAPI input functionality and retrieving keycode information ___________ 20
Code fragment 13: The modified message loop in project4b ______________________________________ 21
4
Code fragment 14: Open a dialog box_______________________________________________________ 23
Code fragment 15: Example of a dialog procedure_____________________________________________ 24
Code fragment 17: Creating and using a font _________________________________________________ 25
Code fragment 18: The function ”LoadBitmap“ _______________________________________________ 33
Code fragment 19: The first blitter method ___________________________________________________ 34
Code fragment 20: The Flip method switching between primary and secondary surface_________________ 35
Code fragment 22: A faster blit.___________________________________________________________ 36
Code fragment 23: Modified LoadBitmap function _____________________________________________ 36
Code fragment 24: The faster blit for landscape displays ________________________________________ 37
Code fragment 25: Draw the background bitmap to the background buffer. __________________________ 37
Code fragment 28: The process function for the game. __________________________________________ 44
Code fragment 29: Stop the click with a device management function. ______________________________ 47
Code fragment 30: Query the registry before stopping the click tone. _______________________________ 49
Code fragment 31: Restore old click tone setting. ______________________________________________ 49
Code fragment 32: An example of a send method.. _____________________________________________ 59
Code fragment 35: Summary of the CDPServer constructor ______________________________________ 61
Code fragment 37: Summary of the function InitDirectPlayClient().________________________________ 62
Code fragment 38: Information required to enumerate hosts______________________________________ 62
Code fragment 39: Summary of CDPClient:: SessionsDlgEnumHosts _______________________________ 63
Code fragment 40: Summary of SessionsDlgNoteEnumResponse() _________________________________ 64
Code fragment 42: Client connects to a host (function SessionsDlgJoinGame) ________________________ 65
Code fragment 43: Example of how to the server sends data to all direct play clients ___________________ 67
Code fragment 44: Example of how to the clint sends data to the server _____________________________ 67
Code fragment 45: The Thread used to initialise or reconnect a network connection. ___________________ 70
Code fragment 46: The receive thread ______________________________________________________ 74
Code fragment 47: The send thread ________________________________________________________ 75
Code fragment 48: Example using GetNextMsg and RealeaseNexttMsg to produce a message ____________ 76
Code fragment 49: GetNextMsg returns a pointer to the next free message in the send buffer _____________ 76
Code fragment 50: ReleaseNextMsg releases dwSize bytes to be sent by adjusting the write pointer ________ 76
Code fragment 52: The send thread writes incoming data in the receive buffer and increments the pointers __ 79
Code fragment 53: Process the messages contained in the receive buffer ____________________________ 80
Code fragment 54: Handle incomplete messages_______________________________________________ 81
Code fragment 56: When detecting a socket error in one of the threads, the threads will be stopped and the reconnection
process will be initialised._______________________________________________________ 83


网友评论