tailieunhanh - microsoft visual basic game programming for teens phần 5

Làm đầy màn hình với Gạch chương trình con DrawTiles bản sao gạch với hình ảnh bảng màu ngói (suy nghĩ của bảng màu sơn của một họa sĩ như là nguồn gốc của màu sắc tương tự này) vào bộ đệm di chuyển, một hình ảnh bề mặt chỉ hơi lớn hơn so với độ phân giải màn hình. Nó không này có sự chồng chéo gạch có thể xảy ra tại một số nghị quyết. | 140 Chapter 8 Advanced Scrolling Techniques Filling the Screen with Tiles The DrawTiles subroutine copies tiles from the tile palette image think of a painter s paint palette as the source of color in this analogy onto the scroll buffer a surface image that is just slightly larger than the screen resolution. It does this to take into account the tile overlap that may occur at some resolutions. Public Sub DrawTiles Dim tilex As Integer Dim tiley As Integer Dim columns As Integer Dim rows As Integer Dim X As Integer Dim Y As Integer Dim tilenum As Integer calculate starting tile position integer division drops the remainder tilex ScrollX TILEWIDTH tiley ScrollY TILEHEIGHT calculate the number of columns and rows integer division drops the remainder columns WINDOWWIDTH TILEWIDTH rows WINDOWHEIGHT TILEHEIGHT draw tiles onto the scroll buffer surface For Y 0 To rows For X 0 To columns This condition shouldn t be necessary. I will try to resolve this problem and make the change during AR. If tiley Y mapheight Then tiley tiley - 1 tilenum mapdata tiley Y mapwidth tilex X DrawTile tiles tilenum TILEWIDTH TILEHEIGHT 16 scrollbuffer _ X TILEWIDTH Y TILEHEIGHT Next X Next Y End Sub For the sake of consistency let me show you the DrawTile subroutine here because it is called by the preceding subroutine to draw each tile. There is an interesting way to optimize this code that you may consider down the road when you are working on your own Direct Partial-Tile Scrolling 141 complete game. The CopyRects function will draw as many images as you specify in the rectangle and point arrays. While the DrawTiles subroutine calls DrawTile for every single tile a good optimization would be to utilize this advanced capability in CopyRects to draw all of the tiles with a single call. I recommend you only keep this in mind for later as there is no point thinking about optimization this early. Public Sub DrawTile _ ByRef source As Direct3DSurface8 _ ByVal tilenum As Long _ ByVal width As Long

TỪ KHÓA LIÊN QUAN