PHP 5/MySQL Programming- P71

PHP 5/MySQL Programming- P71:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 328 PHP 5 MySQL Programming for the Absolute Beginner figure This query sorts by the power in descending reverse alphabetical order. This code upgrades Lightning Guardian s power to the Super Electric Toe which is presumably a lot better than the ordinary Electric Toe . Generally you should update only one record at a time. You can use a WHERE clause to select which record in the table is updated. Returning to the Adventure Game The adventure game featured at the beginning of this chapter uses a combination of MySQL and PHP code. You learn more about the PHP part in chapter 10 Connecting to Databases within PHP. For now you have enough information to start building the data structure that forms the core of the game. Designing the Data Structure The adventure game is entirely about data and has an incredibly repetitive structure. The same code operates over and over but on different parts of the database. I started the program by sketching out the primary play screen and thinking about what data elements I needed for each screen. I ended up building a table like Table . You can see that I simplified the game so that each choice boils down to seven elements. Each node or decision point consists of an id or room number a room name and a description of the current circumstances. Each node also has 329 Table Data Structure of Enigma Adventure id name description north east south west 0 -nothing- You cannot go that way 1 0 0 0 1 start over You are at a submarine yard looking for the famous Enigma code machine 0 3 0 2 2 sub deck As you step on the submarine deck a guard approaches you. Your only choice is to jump off the sub before you are caught. 15 15 15 15 3 warehouse You wait inside the warehouse. You see a doorway to the east and a box to the south. 0 4 5 0 4 doorway You walked right into a group of guards. It does not look good. 0 19 0 15 5 box You crawl inside the box and wait. Suddenly you feel the box being picked up and carried across the wharf 6 0 0

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.