TAILIEUCHUNG - 3D Game Programming All in One- P11

3D Game Programming All in One- P11: 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. | Direct Messaging 207 Now here is where some of the Torque client server magic elbows its way onto the stage. The client will already have a GameConnection to the server and so will already know where to send the message. In order to act on our message the server side needs us to define the TellEveryone message handler which is really just a special purpose function something like this function ServerCmdTellEveryone client msg TellAll client msg Notice the prefix ServerCmd. When the server receives a message from the client via the CommandToServer function it will look in its message handle list which is a list of functions that have the ServerCmd prefix and find the one that matches ServerCmdTellEveryone. It then calls that function setting the first parameter to the GameConnection handle of the client that sent the message. It then sets the rest of the parameters to be the parameters passed in the message from the client which in this case is msg stuffed with the string Hello World . Then we can do what we want with the incoming message. In this case we want to send the message to all of the other clients that are connected to the server and we ll do that by calling the TellAll function. Now we could put the code right here in our ServerCmdTellEveryone message handler but it is a better design approach to break the code out into its own independent function. We ll cover how to do this in the next section. CommandToClient Okay here we are we re the server and we ve received a message from a client. We ve figured out that the message is the TellEveryone message we know which client sent it and we have a string that came along with the message. What we need to do now is define the TellAll function so here is what it could look like function TellAll sender msg count for i 0 i count i client i commandToClient client TellMessage sender msg Our intention here is to forward the message to all of the clients. Whenever a client .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.