Đang chuẩn bị liên kết để tải về tài liệu:
Visual C# Game Programming for Teens phần 5

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

mà bạn nhấp vào dựa trên kích thước của hình ảnh bảng màu và các yếu tố được biết đến như một thực tế rằng có năm gạch qua ngói là 32x32 Khi bạn chọn một ngói, những con số chương trình ra gạch | 170 Chapter 7 Rendering a Dungeon Level scrollPos.Y - steps if scrollPos.Y 0 scrollPos.Y 0 if keyState.down scrollPos.Y steps if scrollPos.Y 127 - 19 32 scrollPos.Y 127 - 19 32 if keyState.left scrollPos.X - steps if scrollPos.X 0 scrollPos.X 0 if keyState.right scrollPos.X steps if scrollPos.X 127 - 25 32 scrollPos.X 127 - 25 32 clear the ground note that this is usually not needed when drawing the game level but this example draws the whole buffer gfxSurface.Clear Color.Black update and draw the tiles drawScrollBuffer print scroll position gfxSurface.DrawString Scroll scrollPos.ToString fontArial Brushes.White 0 0 gfxSurface.DrawString Sub-tile subtile.ToString fontArial Brushes.White 300 0 draw a rect representing the actual scroll area gfxSurface.DrawRectangle Pens.Blue 0 0 801 601 gfxSurface.DrawRectangle Pens.Blue 1 1 801 601 update surface Sub-Tile Scrolling 171 pbSurface.Image bmpSurface public void updateScrollBuffer fill scroll buffer with tiles int tilenum sx sy for int x 0 x 26 x for int y 0 y 20 y sx int scrollPos.X 32 x sy int scrollPos.Y 32 y tilenum tilemap sy 128 sx .tilenum drawTileNumber x y tilenum COLUMNS public void drawTileNumber int x int y int tile int columns int sx tile columns 33 int sy tile columns 33 Rectangle src new Rectangle sx sy 32 32 int dx x 32 int dy y 32 gfxScrollBuffer.DrawImage bmpTiles dx dy src GraphicsUnit.Pixel public void drawScrollBuffer fill scroll buffer only when moving if scrollPos oldScrollPos updateScrollBuffer oldScrollPos scrollPos calculate sub-tile size subtile.X scrollPos.X 32 subtile.Y scrollPos.Y 32 172 Chapter 7 Rendering a Dungeon Level create the source rect Rectangle source new Rectangle int subtile.X int subtile.Y bmpScrollBuffer.Width bmpScrollBuffer.Height draw the scroll viewport gfxSurface.DrawImage bmpScrollBuffer 1 1 source GraphicsUnit.Pixel private void Form1_KeyDown object sender KeyEventArgs e switch e.KeyCode case Keys.Up case Keys.W keyState.up true break case Keys.Down case Keys.S .

Đã 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.