tailieunhanh - Game Programming All in One 2 nd Edition phần 7

Các phiên bản mới hoàn toàn của chiến xe tăng hiện có sẵn trong chapter11 \ \ tankwar trên đĩa CD-ROM, bạn có thể tải lên các dự án hoặc chỉ đơn giản là chạy các trò chơi từ vị trí đó nếu bạn muốn. Tôi khuyên bạn nên bạn làm theo theo và thực hiện những thay đổi chính mình vì nó là một kinh nghiệm học tập có giá trị. | Enhancing Tank War 415 Figure Tank War now draws animated explosions in the game loop without pausing the game. Modifying the Tank War Project The complete new version of Tank War is available in chapter11 tankwar on the CD-ROM you can load up the project or simply run the game from that location if you want. I recommend you follow along and make the changes yourself because it is a valuable learning experience. To do so you ll want to open the Tank War project from Chapter 10 to make the following changes. Be sure to copy the and files off the CD-ROM so the new version of the game will work because these bitmap files contain the new animated tanks. Updating First you need to make a few minor changes to the header file. Look for the section of code that defines the sprites and add the new line of code shown in bold. SPRITE mytanks 2 SPRITE tanks 2 SPRITE mybulletS 2 SPRITE bullets 2 SPRITE explosions 2 Next modify the tank_bmp array which contains the bitmap images for the tanks. Scroll down in a little further to find the sprite bitmap definitions and make the change noted in bold. It s a small change to the tank_bmp array just add another dimension to the array as shown. 416 Chapter 11 Timers Interrupt Handlers and Multi-Threading sprite bitmaps BITMAP tank_bmp 2 8 8 BITMAP bullet_bmp BITMAP explode_bmp Now scroll down a little further in to the function prototypes and add the following three function definitions noted in bold function prototypes void animatetank int num void updateexplosion int num void loadsprites void drawtank int num void erasetank int num void movetank int num Updating Now you can make some changes to the source code file which contains all the code for loading moving and drawing the tanks. Add a new function to the top of to accommodate the new animated tanks. new function added in chapter 11 void animatetank int num if tanks num - framecount tanks num - .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.