Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Compiling the code is a very simple procedure. Just open the file (demo01- 01.bb) off the CD in BlitzPlus (or type it into the workspace), save the file (FileSave) onto your computer, and select ProgramRun Program, as shown in Figure | 16 Chapter 1 Getting Started caution Because of margin constraints some of the lines of code may have spread over two lines or more. In a real game all of the code must be on one line or else it won t run. For example if I had written something like the following line ElseIf ImagesOverlap ballimage ball x ball y player2image 740 player2 y This tests to see if the ball has collided with player 2 s image. Typing it into the compiler with the line break would not work. It must be on the same line even though the margins in the book made it appear broken up. Figures 1.7 and 1.8 show the KONG title screen and main screen respectively. Figure 1.7 KONG title screen. Figure 1.8 KONG main screen. Compiling the Code Compiling the code is a very simple procedure. Just open the file demo01-01.bb off the CD in BlitzPlus or type it into the workspace save the file File Save onto your computer and select Program Run Program as shown in Figure 1.9. Well that isn t what you would call a full game. I did not add any special effects or sounds because they aren t very important at this point. The idea is to get a feel for what code looks like and how it is written. You will notice that the meanings of most of the functions are easy to understand because of the function names. This helps in understanding the program. Let me summarize the main parts of a game. The game consists of The initialization section The main loop The shutdown The First Game KONG 17 Figure 1.9 Compiling the game. Initialization sets up variables and functions that are used throughout the game. Declaration is part of initialization and is used to set up variables that will be used later in the program. The game loop is what you see on the screen. Each iteration an iteration is each time the program runs through the loop of the loop is one frame of the game. Usually there are at least 30 frames or iterations per second. See Figure 1.10 for a description of initialization the game loop also known as the main loop .