游戏开发:战斗系统与物品编辑器详解
1. 战斗系统优化
1.1 面向敌人机制
在游戏战斗中,攻击背后的敌人是不合理的。游戏应避免这种情况,同时要让角色能正确面向目标。 getTargetDirection() 函数可实现这一功能,它通过比较源点和目标点的 X、Y 坐标,确定源点应朝向的方向,代码如下:
Private Function getTargetDirection(ByVal source As PointF, _
ByVal target As PointF)
Dim direction As Integer = 0
If source.X < target.X - 16 Then
If source.Y < target.Y - 8 Then
direction = 3 'south east
ElseIf source.Y > target.Y + 8 Then
direction = 1 'north east
Else
direction = 2 'east
End If
ElseIf source.X > target.X + 16 Then
If source.Y < target.Y - 8 Then
direction = 5 'south west
ElseIf source.Y > target.Y + 8 Then
超级会员免费看
订阅专栏 解锁全文
425

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



