游戏开发:从绘制位图到地图编辑
1. 绘制位图的核心技术
在游戏开发中,从较大的位图图像中提取一个图块并将其绘制到屏幕上的任意位置是一项核心技术。下面我们将详细介绍实现这一功能的代码和步骤。
1.1 DrawTile 子程序
为了在代码中处理像 RECT 和 POINT 这样的对象,我们创建了 DrawTile 子程序,它可以将源表面的任何图块绘制到屏幕上。以下是 DrawTile 子程序的代码:
Private Sub DrawTile( _
ByRef source As Direct3DSurface8, _
ByVal sourcex As Long, _
ByVal sourcey As Long, _
ByVal width As Long, _
ByVal height As Long, _
ByVal destx As Long, _
ByVal desty As Long)
'create a RECT to describe the source image
Dim sourceRect As DxVBLibA.RECT
'set the upper left corner of the source image
sourceRect.left = sourcex
sourceRect.top = sourcey
'set the bottom right corner of the source image
sourceRect.right = sourcex + width
sourceRect.bottom = s
超级会员免费看
订阅专栏 解锁全文
8

被折叠的 条评论
为什么被折叠?



