tailieunhanh - ActionScript 3.0 Game Programming University, Second Edition phần 10

. Sau đó, chúng ta nhìn vào hai phong cách trò chơi trong casino Video Poker và Blackjack. Ngoài việc học tập làm thế nào để đại diện cho một cỗ bài trong Flash, chúng tôi cũng bao gồm các khái niệm về các sự kiện thời gian. Thay vì đối phó bộ thẻ cùng một lúc, chúng tôi sử dụng Thời Gian để giải quyết chúng như là một con người có một tại một thời điểm. | 508 Chapter 14 3D Games Target Practice Racing Game and Dungeon Adventure I ve mentioned charPos and how we use it. Here we set it to a starting position. Then we call zSort to sort the display list in order of distance from the front just as we did in the previous game keep track of virtual position of character charPos new Point 0 0 arrange all walls and coins for distance zSort At the end of the constructor function we have the setup of the three listeners two for the keyboard input and one for the main game function respond to key events keyPressedDown keyPressedUp advance game addEventListener moveGame Here is the addWall function. A new wall is created from the Wall class. It is set in position width equal to the length assigned and rotates to stand up and rotate into position public function addWall x y len rotation var wall Wall new Wall x y 2 len 90 rotation wall wall Main Game Function Because the two keyboard event listener functions are identical to the ones in the previous game let s skip over them. In addition the turnPlayer function is the same as in 3D Racing except the last three lines that turned all the trees to face the front aren t used here. So that brings us to the moveGame function. Because the turning in a game like this is independent of the speed of movement we set turn to a higher value when the left or right arrow key is pressed. We can also go ahead and perform the turn without checking the forward movement Wow eBook 3D Dungeon Adventure 509 public function moveGame e see if turning left or right var turn Number 0 if leftArrow turn 10 else if rightArrow turn -10 turn if turn 0 turnPlayer turn Movement works in the same way as turning. We look at the movePlayer function later if up arrow pressed then .

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.