TAILIEUCHUNG - .NET Game Programming with DirectX 9.0 P2

The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX Foreword Preface Introduction Chapter 1 Chapter 3 Chapter 4 - .Nettrix: GDI+ and Collision Detection Figure .Netterpillars: a screen into 64 zones Chapter 2 - 1-17: DividingArtificial Intelligence and Sprites | Figure 1-17 Dividing a screen into 64 zones If all we want to know is whether a certain zone contains an object disregarding which one we can use bytes instead of arrays to store the zone information where each bit will represent a zone on screen this is called zoning with bits. We can divide our screen in zones according to the number of bits on each variable used 64 8 x 8 zones with a byte 256 16 x 16 zones in an int16 1024 32 x 32 zones in an int32 and so on. Using the zoning with bits method at each game loop we reset the variables and for each object we process any movement. We then calculate the zone of each object multiply the current position of the object by the number of zones on each axis and divide by the width or height of the screen and set the bit corresponding to the result at the x-axis variable and at the y-axis variable accordingly. We have to set a second bit if the sum of the position and the size of the object width for x axis height for y axis lies in another zone. If when checking the variables we see that the bit in both variables is already set then there s an object in our zone so we check all the objects to find out which one it is. Using this method if we have 15 objects on the screen and only one collision we ll have to do only one check against a given number of objects 14 in the worst case of this scenario instead of 15 tests with 14 objects. This method has some drawbacks We don t know which object set the bit so we have to test all the objects looking for the collision. Some ghost objects are created when crossing the bit set for the x zone by one object with the bit set for the y zones by another object as depicted by Figure 1-18. i rrtlE. Figure 1-18 Using zone bits if we have big objects like the bricks there ll be lots of ghost objects. This method is most useful when we want to test a group of objects against other objects for example bullets against enemies on screen if we need to test all the objects against each of the .

TỪ KHÓA LIÊN QUAN
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.