t'is class is enemy movig,rotation
enemy rotate & move up to player good for IA
a single enemy class
-
- Posts: 41
- Joined: Sat Jan 15, 2005 8:03 pm
- Contact:
-
- Posts: 41
- Joined: Sat Jan 15, 2005 8:03 pm
- Contact:
Imports Irrlicht
Imports Irrlicht.Core
Imports Irrlicht.Scene
Imports Irrlicht.Video
Imports Irrlicht.GUI
Imports Irrlicht.IO
Imports System.Math
Public Class Enemy
Public Sub Move(ByVal Enemy As ISceneNode, ByVal Player As ISceneNode, ByVal Speed As Integer)
Dim Xp, Zp As Single
Xp = Enemy.Position.X : Zp = Enemy.Position.Z
If Enemy.Position.X < Player.Position.X Then Xp = Xp + Speed Else Xp = Xp - Speed
If Enemy.Position.Z < Player.Position.Z Then Zp = Zp + Speed Else Zp = Zp - Speed
Enemy.Position = New Vector3D(Xp, Enemy.Position.Y, Zp)
End Sub
Public Sub GetTargetAngle(ByVal Enemy As ISceneNode, ByVal Player As ISceneNode, ByVal Factor As Single)
Dim angle, v, r As Vector3D
Dim x, y, z As Integer
v = Enemy.AbsolutePosition : r = Player.AbsolutePosition
x = r.X - v.X
y = r.Y - v.Y
z = r.Z - v.Z
angle.Y = Atan2(x, z)
angle.Y *= (180 / PI)
If (angle.Y < 0) Then angle.Y += 360
If (angle.Y >= 360) Then angle.Y -= 360
angle.Y = angle.Y - Factor
Enemy.Rotation = New Vector3D(angle.X, angle.Y, angle.Z)
' Return angle
End Sub
End Class
Imports Irrlicht.Core
Imports Irrlicht.Scene
Imports Irrlicht.Video
Imports Irrlicht.GUI
Imports Irrlicht.IO
Imports System.Math
Public Class Enemy
Public Sub Move(ByVal Enemy As ISceneNode, ByVal Player As ISceneNode, ByVal Speed As Integer)
Dim Xp, Zp As Single
Xp = Enemy.Position.X : Zp = Enemy.Position.Z
If Enemy.Position.X < Player.Position.X Then Xp = Xp + Speed Else Xp = Xp - Speed
If Enemy.Position.Z < Player.Position.Z Then Zp = Zp + Speed Else Zp = Zp - Speed
Enemy.Position = New Vector3D(Xp, Enemy.Position.Y, Zp)
End Sub
Public Sub GetTargetAngle(ByVal Enemy As ISceneNode, ByVal Player As ISceneNode, ByVal Factor As Single)
Dim angle, v, r As Vector3D
Dim x, y, z As Integer
v = Enemy.AbsolutePosition : r = Player.AbsolutePosition
x = r.X - v.X
y = r.Y - v.Y
z = r.Z - v.Z
angle.Y = Atan2(x, z)
angle.Y *= (180 / PI)
If (angle.Y < 0) Then angle.Y += 360
If (angle.Y >= 360) Then angle.Y -= 360
angle.Y = angle.Y - Factor
Enemy.Rotation = New Vector3D(angle.X, angle.Y, angle.Z)
' Return angle
End Sub
End Class
-
- Posts: 18
- Joined: Wed Jun 08, 2005 3:14 am
The formatting is a lot nicer if you use the [code] and [/code] tags. :)
onGameDev - Game development with some "umph"!
Blog of a Wanderer - The trials of a nomadic programmer.
Blog of a Wanderer - The trials of a nomadic programmer.
-
- Posts: 41
- Joined: Sat Jan 15, 2005 8:03 pm
- Contact:
-
- Posts: 18
- Joined: Wed Jun 08, 2005 3:14 am
I didn't ask a question. Rather I was offering a suggestion.karim1a2004 wrote:I did not understand your question
If you put those tags around your code, then it will appear formatted much more nicely. For example:
Code: Select all
Public Sub GetTargetAngle(ByVal Enemy As ISceneNode, ByVal Player As ISceneNode, ByVal Factor As Single)
Dim angle, v, r As Vector3D
Dim x, y, z As Integer
v = Enemy.AbsolutePosition : r = Player.AbsolutePosition
x = r.X - v.X
y = r.Y - v.Y
z = r.Z - v.Z
angle.Y = Atan2(x, z)
angle.Y *= (180 / PI)
If (angle.Y < 0) Then angle.Y += 360
If (angle.Y >= 360) Then angle.Y -= 360
angle.Y = angle.Y - Factor
Enemy.Rotation = New Vector3D(angle.X, angle.Y, angle.Z)
' Return angle
End Sub
onGameDev - Game development with some "umph"!
Blog of a Wanderer - The trials of a nomadic programmer.
Blog of a Wanderer - The trials of a nomadic programmer.