a single enemy class

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
karim1a2004
Posts: 41
Joined: Sat Jan 15, 2005 8:03 pm
Contact:

a single enemy class

Post by karim1a2004 »

t'is class is enemy movig,rotation
enemy rotate & move up to player good for IA

:lol:
karim1a2004
Posts: 41
Joined: Sat Jan 15, 2005 8:03 pm
Contact:

Post by karim1a2004 »

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
HopeDagger
Posts: 18
Joined: Wed Jun 08, 2005 3:14 am

Post by HopeDagger »

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.
karim1a2004
Posts: 41
Joined: Sat Jan 15, 2005 8:03 pm
Contact:

Post by karim1a2004 »

I did not understand your question
:?:
HopeDagger
Posts: 18
Joined: Wed Jun 08, 2005 3:14 am

Post by HopeDagger »

karim1a2004 wrote:I did not understand your question
:?:
I didn't ask a question. Rather I was offering a suggestion. :)

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.
Locked