TAILIEUCHUNG - 3D Game Programming All in One- P5

3D Game Programming All in One- P5: During the past several years while working on the Tubettiland “Online Campaign” software and more recently while working on the Tubettiworld game, I figure I’ve received more than a hundred queries from people of all ages about how to get started making games. There were queries from 40-year-olds and 13-year-olds and every age in between. Most e-mails were from guys I would estimate to be in their late teens or early 20s. | Programming Concepts 57 ------------------------------------------------------ Entry point for the program. ------------------------------------------------------ ----------------- Initialization ----------------------- numFruitTypes 5 so we know how many types are in our arrays bananaIdx 0 initialize the values of our index variables appleIdx 1 orangeIdx 2 mangoIdx 3 pearIdx 4 names bananaIdx bananas initialize the fruit name values names appleIdx apples names orangeIdx oranges names mangoIdx mangos names pearIdx pears cost bananaIdx initialize the price values cost appleIdx cost orangeIdx cost mangoIdx cost pearIdx quantity bananaIdx 1 initialize the quantity values quantity appleIdx 3 quantity orangeIdx 4 quantity mangoIdx 1 quantity pearIdx 2 numFruit 0 always a good idea to initialize all variables totalCost 0 even if we know we are going to change them later ----------------- Computation ----------------------- Display the known statistics of the fruit collection Team LRN 58 Chapter 2 Introduction to Programming for index 0 index numFruitTypes index print Cost of @ names index @ @ cost index print Number of @ names index @ @ quantity index count up all the pieces of fruit and display that result for index 0 index numFruitTypes index numFruit numFruit quantity index print Total pieces of Fruit @ numFruit now calculate the total cost for index 0 index numFruitTypes index totalCost totalCost quantity index cost index print Total Price of Fruit @ totalCost Type this program in save it as C 3DGPAi1 book and then run it. Of course you will notice right away that I ve used comments to organize the code into two sections initialization and computation. This was purely arbitrary but it is a good idea to label sections of code in this manner to provide signposts as it were. You should also notice that all the variables in the program are local rather than global in scope. This is more reasonable for a program of this nature where

Đã 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.